From e251cf95eed73baf2a466e88f6d7ebdb398fb918 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 11 Jul 2018 15:19:24 -0400 Subject: [PATCH 001/209] Initial checkin Initial checkin using new rep --- PySimpleGUI.py | 1666 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1666 insertions(+) create mode 100644 PySimpleGUI.py diff --git a/PySimpleGUI.py b/PySimpleGUI.py new file mode 100644 index 000000000..995c6f5c9 --- /dev/null +++ b/PySimpleGUI.py @@ -0,0 +1,1666 @@ +#!/usr/bin/env Python3 +import tkinter as tk +from tkinter import filedialog +from tkinter import ttk +import tkinter.scrolledtext as tkst +import tkinter.font +from random import randint +import datetime +import sys +import textwrap + + +# ----====----====----==== Constants the use CAN safely change ====----====----====----# +DEFAULT_WINDOW_ICON = '' +DEFAULT_ELEMENT_SIZE = (45,1) # In CHARACTERS +DEFAULT_MARGINS = (10,5) # Margins for each LEFT/RIGHT margin is first term +DEFAULT_ELEMENT_PADDING = (5,3) # Padding between elements (row, col) in pixels +DEFAULT_AUTOSIZE_TEXT = False +DEFAULT_FONT = ("Helvetica", 10) + +DEFAULT_BORDER_WIDTH = 7 +DEFAULT_AUTOCLOSE_TIME = 3 # time in seconds to show an autoclose form +MAX_SCROLLED_TEXT_BOX_HEIGHT = 50 +#################### COLOR STUFF #################### +BLUES = ("#082567","#0A37A3","#00345B") +PURPLES = ("#480656","#4F2398","#380474") +GREENS = ("#01826B","#40A860","#96D2AB", "#00A949","#003532") +YELLOWS = ("#F3FB62", "#F0F595") +TANS = ("#FFF9D5","#F4EFCF","#DDD8BA") +NICE_BUTTON_COLORS = ((GREENS[3], TANS[0]), ('#000000','#FFFFFF'),('#FFFFFF', '#000000'), (YELLOWS[0], PURPLES[1]), + (YELLOWS[0], GREENS[3]), (YELLOWS[0], BLUES[2])) +# DEFAULT_BUTTON_COLOR = (YELLOWS[0], PURPLES[0]) # (Text, Background) or (Color "on", Color) as a way to remember +# DEFAULT_BUTTON_COLOR = (GREENS[3], TANS[0]) # Foreground, Background (None, None) == System Default +DEFAULT_BUTTON_COLOR = (YELLOWS[0], GREENS[4]) # Foreground, Background (None, None) == System Default +# DEFAULT_BUTTON_COLOR = (YELLOWS[0], PURPLES[2]) # Foreground, Background (None, None) == System Default +DEFAULT_ERROR_BUTTON_COLOR =("#FFFFFF", "#FF0000") +DEFAULT_CANCEL_BUTTON_COLOR = (GREENS[3], TANS[0]) +BarColor=() +# DEFAULT_PROGRESS_BAR_COLOR = (GREENS[2], GREENS[0]) # a nice green progress bar +DEFAULT_PROGRESS_BAR_COLOR = (GREENS[3], GREENS[3]) # a nice green progress bar +# DEFAULT_PROGRESS_BAR_COLOR = (BLUES[1], BLUES[1]) # a nice green progress bar +# DEFAULT_PROGRESS_BAR_COLOR = (BLUES[0], BLUES[0]) # a nice green progress bar +# DEFAULT_PROGRESS_BAR_COLOR = (PURPLES[1],PURPLES[0]) # a nice purple progress bar +DEFAULT_PROGRESS_BAR_SIZE = (30,25) # Size of Progress Bar (characters for length, pixels for width) +DEFAULT_PROGRESS_BAR_BORDER_WIDTH=8 +DEFAULT_PROGRESS_BAR_RELIEF = tk.SUNKEN +DEFAULT_PROGRESS_BAR_STYLE = 'default' +DEFAULT_METER_ORIENTATION = 'Horizontal' +# DEFAULT_METER_ORIENTATION = 'Vertical' +# ----====----====----==== Constants the user should NOT f-with ====----====----====----# +ThisRow = 555666777 # magic number +# Progress Bar Relief Choices +# -relief +RAISED='raised' +SUNKEN='sunken' +FLAT='flat' +RIDGE='ridge' +GROOVE='groove' +SOLID = 'solid' + +PROGRESS_BAR_STYLES = ('default','winnative', 'clam', 'alt', 'classic', 'vista', 'xpnative') +# DEFAULT_WINDOW_ICON = '' +MESSAGE_BOX_LINE_WIDTH = 60 + +# a shameful global variable. This represents the top-level window information. Needed because opening a second window is different than opening the first. +class MyWindows(): + def __init__(self): + self.NumOpenWindows = 0 + self.user_defined_icon = None + +_my_windows = MyWindows() # terrible hack using globals... means need a class for collecing windows + +# ====================================================================== # +# One-liner functions that are handy as f_ck # +# ====================================================================== # +def RGB(red,green,blue): return '#%02x%02x%02x' % (red,green,blue) + +# ====================================================================== # +# Enums for types # +# ====================================================================== # +# ------------------------- Button types ------------------------- # +#todo Consider removing the Submit, Cancel types... they are just 'RETURN' type in reality +#uncomment this line and indent to go back to using Enums +# class ButtonType(Enum): +BROWSE_FOLDER = 1 +BROWSE_FILE = 2 +CLOSES_WIN = 5 +READ_FORM = 7 + +# ------------------------- Element types ------------------------- # +# class ElementType(Enum): +TEXT = 1 +INPUT_TEXT = 20 +INPUT_COMBO = 21 +INPUT_RADIO = 5 +INPUT_MULTILINE = 7 +INPUT_CHECKBOX = 8 +INPUT_SPIN = 9 +BUTTON = 3 +OUTPUT = 300 +PROGRESS_BAR = 200 +BLANK = 100 + +# ------------------------- MsgBox Buttons Types ------------------------- # +MSG_BOX_YES_NO = 1 +MSG_BOX_CANCELLED = 2 +MSG_BOX_ERROR = 3 +MSG_BOX_OK_CANCEL = 4 +MSG_BOX_OK = 0 + +# ---------------------------------------------------------------------- # +# Cascading structure.... Objects get larger # +# Button # +# Element # +# Row # +# Form # +# ---------------------------------------------------------------------- # +# ------------------------------------------------------------------------- # +# Element CLASS # +# ------------------------------------------------------------------------- # +class Element(): + def __init__(self, Type, Scale=(None, None), Size=(None, None), AutoSizeText=None, Font=None): + self.Size = Size + self.Type = Type + self.AutoSizeText = AutoSizeText + self.Scale = Scale + self.Pad = DEFAULT_ELEMENT_PADDING + self.Font = Font + + self.TKStringVar = None + self.TKIntVar = None + self.TKText = None + self.TKEntry = None + + self.ParentForm=None + self.TextInputDefault = None + self.Position = (0,0) # Default position Row 0, Col 0 + return + + def __del__(self): + try: + self.TKStringVar.__del__() + except: + pass + try: + self.TKIntVar.__del__() + except: + pass + try: + self.TKText.__del__() + except: + pass + try: + self.TKEntry.__del__() + except: + pass + +# ---------------------------------------------------------------------- # +# Input Class # +# ---------------------------------------------------------------------- # +class InputText(Element): + + def __init__(self, DefaultText = '', Scale=(None, None), Size=(None, None), AutoSizeText=None): + self.DefaultText = DefaultText + super().__init__(INPUT_TEXT, Scale, Size, AutoSizeText) + return + + def ReturnKeyHandler(self, event): + MyForm = self.ParentForm + # search through this form and find the first button that will exit the form + for row in MyForm.Rows: + for element in row.Elements: + if element.Type == BUTTON: + if element.BType == CLOSES_WIN or element.BType == READ_FORM: + element.ButtonCallBack() + return + def __del__(self): + super().__del__() + +# ---------------------------------------------------------------------- # +# Combo # +# ---------------------------------------------------------------------- # +class InputCombo(Element): + + def __init__(self, Values, Scale=(None, None), Size=(None, None), AutoSizeText=None): + self.Values = Values + self.TKComboBox = None + super().__init__(INPUT_COMBO, Scale, Size, AutoSizeText) + return + + def __del__(self): + try: + self.TKComboBox.__del__() + except: + pass + super().__del__() + +# ---------------------------------------------------------------------- # +# Radio # +# ---------------------------------------------------------------------- # +class Radio(Element): + def __init__(self, Text, GroupID, Default=False, Scale=(None, None), Size=(None, None), AutoSizeText=None,Font=None): + self.InitialState = Default + self.Text = Text + self.TKRadio = None + self.GroupID = GroupID + self.Value = None + super().__init__(INPUT_RADIO, Scale, Size, AutoSizeText, Font) + return + + def __del__(self): + try: + self.TKRadio.__del__() + except: + pass + super().__del__() + +# ---------------------------------------------------------------------- # +# Checkbox # +# ---------------------------------------------------------------------- # +class Checkbox(Element): + def __init__(self, Text, Default=False, Scale=(None, None), Size=(None, None), AutoSizeText=None, Font=None): + self.Text = Text + self.InitialState = Default + self.Value = None + self.TKCheckbox = None + + super().__init__(INPUT_CHECKBOX, Scale, Size, AutoSizeText, Font) + return + + def __del__(self): + try: + self.TKCheckbox.__del__() + except: + pass + super().__del__() + +# ---------------------------------------------------------------------- # +# Spin # +# ---------------------------------------------------------------------- # + +class Spin(Element): + # Values = None + # TKSpinBox = None + def __init__(self, Values, Scale=(None, None), Size=(None, None), AutoSizeText=None, Font=None, InitialValue=None): + self.Values = Values + self.DefaultValue = InitialValue + self.TKSpinBox = None + super().__init__(INPUT_SPIN, Scale, Size, AutoSizeText, Font=Font) + return + + def __del__(self): + try: + self.TKSpinBox.__del__() + except: + pass + super().__del__() + +# ---------------------------------------------------------------------- # +# Multiline # +# ---------------------------------------------------------------------- # +class Multiline(Element): + def __init__(self, DefaultText='', EnterSubmits = False, Scale=(None, None), Size=(None, None), AutoSizeText=None): + self.DefaultText = DefaultText + self.EnterSubmits = EnterSubmits + super().__init__(INPUT_MULTILINE, Scale, Size, AutoSizeText) + return + + def ReturnKeyHandler(self, event): + MyForm = self.ParentForm + # search through this form and find the first button that will exit the form + for row in MyForm.Rows: + for element in row.Elements: + if element.Type == BUTTON: + if element.BType == CLOSES_WIN or element.BType == READ_FORM: + element.ButtonCallBack() + return + + def __del__(self): + super().__del__() + +# ---------------------------------------------------------------------- # +# Text # +# ---------------------------------------------------------------------- # +class Text(Element): + def __init__(self, Text, Scale=(None, None), Size=(None, None), AutoSizeText=None, Font=None, TextColor=None): + self.DisplayText = Text + self.TextColor = TextColor if TextColor else 'black' + # self.Font = Font if Font else DEFAULT_FONT + super().__init__(TEXT, Scale, Size, AutoSizeText, Font=Font if Font else DEFAULT_FONT) + return + + def Update(self, NewValue): + self.DisplayText=NewValue + stringvar = self.TKStringVar + stringvar.set(NewValue) + + def __del__(self): + super().__del__() + + +# ---------------------------------------------------------------------- # +# TKProgressBar # +# Emulate the TK ProgressBar using canvas and rectangles +# ---------------------------------------------------------------------- # + +class TKProgressBar(): + def __init__(self, root, Max, Length=400, Width=20, Highlightt=0, Relief='sunken', Borderwidth=4, Orientation='horizontal', BarColor=DEFAULT_PROGRESS_BAR_COLOR): + self.Length = Length + self.Width = Width + self.Max = Max + self.Orientation = Orientation + self.Count = None + self.PriorCount = 0 + if Orientation[0].lower() == 'h': + self.TKCanvas = tk.Canvas(root, width=Length, height=Width, highlightt=Highlightt, relief=Relief, borderwidth=Borderwidth) + self.TKRect = self.TKCanvas.create_rectangle(0, 0, -(Length * 1.5), Width * 1.5, fill=BarColor[0], tags='bar') + # self.canvas.pack(padx='10') + else: + self.TKCanvas = tk.Canvas(root, width=Width, height=Length, highlightt=Highlightt, relief=Relief, borderwidth=Borderwidth) + self.TKRect = self.TKCanvas.create_rectangle(Width * 1.5, 2 * Length + 40, 0, Length * .5, fill=BarColor[0], tags='bar') + # self.canvas.pack() + + def Update(self,Count): + if Count > self.Max: return + if self.Orientation[0].lower() == 'h': + try: + if Count != self.PriorCount: + delta = Count - self.PriorCount + self.TKCanvas.move(self.TKRect, delta*(self.Length / self.Max), 0) + if 0: self.TKCanvas.update() + except: + return False # the window was closed by the user on us + else: + try: + if Count != self.PriorCount: + delta = Count - self.PriorCount + self.TKCanvas.move(self.TKRect, 0, delta*(-self.Length / self.Max)) + if 0: self.TKCanvas.update() + except: + return False # the window was closed by the user on us + self.PriorCount = Count + return True + + def __del__(self): + try: + self.TKCanvas.__del__() + self.TKRect.__del__() + except: + pass + +# ---------------------------------------------------------------------- # +# Output # +# New Type of Widget that's a Text Widget in disguise # +# ---------------------------------------------------------------------- # +class TKOutput(tk.Frame): + ''' Demonstrate python interpreter output in Tkinter Text widget +type python expression in the entry, hit DoIt and see the results +in the text pane.''' + # previous_stderr = None + # previous_stdout = None + def __init__(self, parent, width, height, bd): + tk.Frame.__init__(self, parent) + self.output = tk.Text(parent, width=width, height=height, bd=bd) + + self.vsb = tk.Scrollbar(parent, orient="vertical", command=self.output.yview) + self.vsb.pack(side="right", fill="y") + self.output.configure(yscrollcommand=self.vsb.set) + self.output.pack(side="left", fill="both", expand=True) + self.previous_stdout = sys.stdout + self.previous_stderr = sys.stderr + + sys.stdout = self + sys.stderr = self + self.pack() + + def write(self, txt): + try: + self.output.insert(tk.END, str(txt)) + self.output.see(tk.END) + except: + pass + + def Close(self): + sys.stdout = self.previous_stdout + sys.stderr = self.previous_stderr + + def flush(self): + sys.stdout = self.previous_stdout + sys.stderr = self.previous_stderr + + def __del__(self): + sys.stdout = self.previous_stdout + +class Output(Element): + def __init__(self, Scale=(None, None), Size=(None, None)): + self.TKOut = None + super().__init__(OUTPUT, Scale, Size) + + def __del__(self): + try: + self.TKOut.__del__() + except: + pass + super().__del__() + +# ---------------------------------------------------------------------- # +# Button Class # +# ---------------------------------------------------------------------- # +class Button(Element): + def __init__(self, ButtonType=CLOSES_WIN, Target=(None, None), Text ='', FileTypes=(("ALL Files", "*.*"),), Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None, Font=None): + self.BType = ButtonType + self.FileTypes = FileTypes + self.TKButton = None + self.Target = Target + self.Text = Text + self.ButtonColor = ButtonColor if ButtonColor else DEFAULT_BUTTON_COLOR + self.UserData = None + super().__init__(BUTTON, Scale, Size, AutoSizeText, Font=Font) + return + + # ------- Button Callback ------- # + def ButtonCallBack(self): + global _my_windows + # Buttons modify targets or return from the form + # If modifying target, get the element object at the target and modify its StrVar + target = self.Target + if target[0] == ThisRow: + target = [self.Position[0], target[1]] + if target[1] < 0: + target[1] = self.Position[1] + target[1] + strvar = None + if target[0] != None: + target_element = self.ParentForm.GetElementAtLocation(target) + try: + strvar = target_element.TKStringVar + except: pass + else: + strvar = None + filetypes = [] if self.FileTypes is None else self.FileTypes + if self.BType == BROWSE_FOLDER: + folder_name = tk.filedialog.askdirectory() # show the 'get folder' dialog box + try: + strvar.set(folder_name) + except: pass + elif self.BType == BROWSE_FILE: + file_name = tk.filedialog.askopenfilename(filetypes=filetypes) # show the 'get file' dialog box + strvar.set(file_name) + elif self.BType == CLOSES_WIN: # this is a return type button so GET RESULTS and destroy window + # first, get the results table built + # modify the Results table in the parent FlexForm object + r,c = self.Position + self.ParentForm.Results[r][c] = True # mark this button's location in results + # if the form is tabbed, must collect all form's results and destroy all forms + if self.ParentForm.IsTabbedForm: + self.ParentForm.UberParent.Close() + else: + self.ParentForm.Close() + self.ParentForm.TKroot.quit() + if self.ParentForm.NonBlocking: + self.ParentForm.TKroot.destroy() + _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 + elif self.BType == READ_FORM: # LEAVE THE WINDOW OPEN!! DO NOT CLOSE + # first, get the results table built + # modify the Results table in the parent FlexForm object + r,c = self.Position + self.ParentForm.Results[r][c] = True # mark this button's location in results + self.ParentForm.TKroot.quit() # kick the users out of the mainloop + return + + def ReturnKeyHandler(self, event): + MyForm = self.ParentForm + # search through this form and find the first button that will exit the form + for row in MyForm.Rows: + for element in row.Elements: + if element.Type == BUTTON: + if element.BType == CLOSES_WIN or element.BType == READ_FORM: + element.ButtonCallBack() + return + + def __del__(self): + try: + self.TKButton.__del__() + except: + pass + super().__del__() + +# ---------------------------------------------------------------------- # +# ProgreessBar # +# ---------------------------------------------------------------------- # +class ProgressBar(Element): + def __init__(self, MaxValue, Orientation=None, Target=(None,None), Scale=(None, None), Size=(None, None), AutoSizeText=None, BarColor=(None,None), Style=None, BorderWidth=None, Relief=None): + self.MaxValue = MaxValue + self.TKProgressBar = None + self.Cancelled = False + self.NotRunning = True + self.Orientation = Orientation if Orientation else DEFAULT_METER_ORIENTATION + self.BarColor = BarColor + self.BarStyle = Style if Style else DEFAULT_PROGRESS_BAR_STYLE + self.Target = Target + self.BorderWidth = BorderWidth if BorderWidth else DEFAULT_PROGRESS_BAR_BORDER_WIDTH + self.Relief = Relief if Relief else DEFAULT_PROGRESS_BAR_RELIEF + self.BarExpired = False + super().__init__(PROGRESS_BAR, Scale, Size, AutoSizeText) + return + + def UpdateBar(self, CurrentCount): + if self.ParentForm.TKrootDestroyed: + return False + target = self.Target + if target[0] != None: # if there's a target, get it and update the strvar + target_element = self.ParentForm.GetElementAtLocation(target) + strvar = target_element.TKStringVar + rc = strvar.set(self.TextToDisplay) + # update the progress bar counter + # self.TKProgressBar['value'] = self.CurrentValue + + self.TKProgressBar.Update(CurrentCount) + try: + self.ParentForm.TKroot.update() + except: + _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 + return False + return True + + def __del__(self): + try: + self.TKProgressBar.__del__() + except: + pass + super().__del__() + +# ------------------------------------------------------------------------- # +# Row CLASS # +# ------------------------------------------------------------------------- # +class Row(): + def __init__(self, AutoSizeText = None): + self.AutoSizeText = AutoSizeText # Setting to override the form's policy on autosizing. + self.Elements = [] # List of Elements in this Rrow + return + + # ------------------------- AddElement ------------------------- # + def AddElement(self, element): + self.Elements.append(element) + return + + # ------------------------- Print ------------------------- # + def __str__(self): + outstr = '' + for i, element in enumerate(self.Elements): + outstr += 'Element #%i = %s'%(i,element) + # outstr += f'Element #{i} = {element}' + return outstr + +# ------------------------------------------------------------------------- # +# FlexForm CLASS # +# ------------------------------------------------------------------------- # +class FlexForm: + ''' + Display a user defined for and return the filled in data + ''' + def __init__(self, title, DefaultElementSize=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), AutoSizeText=DEFAULT_AUTOSIZE_TEXT, Scale=(None, None),Size=(None, None), Location=(None, None), ButtonColor=None, Font=None, ProgressBarColor=(None,None), IsTabbedForm=False,BorderDepth=None, AutoClose=False, AutoCloseDuration=DEFAULT_AUTOCLOSE_TIME, Icon=DEFAULT_WINDOW_ICON): + self.AutoSizeText = AutoSizeText + self.Title = title + self.Rows = [] # a list of ELEMENTS for this row + self.DefaultElementSize = DefaultElementSize + self.Size = Size + self.Scale = Scale + self.Location = Location + self.ButtonColor = ButtonColor if ButtonColor else DEFAULT_BUTTON_COLOR + self.IsTabbedForm = IsTabbedForm + self.ParentWindow = None + self.Font = Font if Font else DEFAULT_FONT + self.RadioDict = {} + self.BorderDepth = BorderDepth + self.WindowIcon = Icon if not _my_windows.user_defined_icon else _my_windows.user_defined_icon + self.AutoClose = AutoClose + self.NonBlocking = False + self.TKroot = None + self.TKrootDestroyed = False + self.TKAfterID = None + self.ProgressBarColor = ProgressBarColor + self.AutoCloseDuration = AutoCloseDuration + self.UberParent = None + self.RootNeedsDestroying = False + self.Shown = False + self.ReturnValues = None + + # ------------------------- Add ONE Row to Form ------------------------- # + def AddRow(self, *args,AutoSizeText=None): + ''' Parms are a variable number of Elements ''' + NumRows = len(self.Rows) # number of existing rows is our row number + CurrentRowNumber = NumRows # this row's number + CurrentRow = Row(AutoSizeText) # start with a blank row and build up + # ------------------------- Add the elements to a row ------------------------- # + for i, element in enumerate(args): # Loop through list of elements and add them to the row + element.Position = (CurrentRowNumber, i) + CurrentRow.Elements.append(element) + CurrentRow.AutoSizeText = AutoSizeText + # ------------------------- Append the row to list of Rows ------------------------- # + self.Rows.append(CurrentRow) + + # ------------------------- Add Multiple Rows to Form ------------------------- # + def AddRows(self,rows): + for row in rows: + self.AddRow(*row) + + def LayoutAndShow(self,rows): + self.AddRows(rows) + self.Show() + return self.ReturnValues + + # ------------------------- ShowForm THIS IS IT! ------------------------- # + def Show(self, NonBlocking=False): + self.Shown = True + # Compute num rows & num cols (it'll come in handy debugging) + self.NumRows = len(self.Rows) + self.NumCols = max(len(row.Elements) for row in self.Rows) + self.NonBlocking=NonBlocking + + # -=-=-=-=-=-=-=-=- RUN the GUI -=-=-=-=-=-=-=-=- ## + StartupTK(self) + return self.ReturnValues + + # ------------------------- SetIcon - set the window's fav icon ------------------------- # + def SetIcon(self, Icon): + self.WindowIcon = Icon + try: + self.TKroot.iconbitmap(Icon) + except: pass + + def GetElementAtLocation(self,Location): + (row_num,col_num) = Location + row = self.Rows[row_num] + element = row.Elements[col_num] + return element + + def GetDefaultElementSize(self): + return self.DefaultElementSize + + def AutoCloseAlarmCallback(self): + try: + if self.UberParent: + window = self.UberParent + else: + window = self + if window: + window.Close() + self.TKroot.quit() + self.RootNeedsDestroying = True + except: + pass + + def Read(self): + if self.TKrootDestroyed: return None + if not self.TKrootDestroyed and not self.Shown: + self.Show() + elif not self.TKrootDestroyed: + self.TKroot.mainloop() + if self.RootNeedsDestroying: + self.TKroot.destroy() + return(BuildResults(self)) + + def OutputFlush(self, Message=''): + if self.TKrootDestroyed: return None + if Message: + print(Message) + try: + self.TKroot.update() + except: + self.TKrootDestroyed = True + return(BuildResults(self)) + + def Close(self): + try: + self.TKroot.update() + except: pass + results = BuildResults(self) + if self.TKrootDestroyed: + return results + self.TKrootDestroyed = True + self.RootNeedsDestroying = True + return results + + def OnClosingCallback(self): + return + + def __enter__(self): + return self + + def __exit__(self, *a): + self.__del__() + return self + + def __del__(self): + for row in self.Rows: + for element in row.Elements: + element.__del__() + try: + del(self.TKroot) + except: + pass + +# ------------------------------------------------------------------------- # +# UberForm CLASS # +# Used to make forms into TABS (it's trick) # +# ------------------------------------------------------------------------- # +class UberForm(): + FormList = None # list of all the forms in this window + FormReturnValues = None + TKroot = None # tk root for the overall window + TKrootDestroyed = False + def __init__(self): + self.FormList = [] + self.FormReturnValues = [] + self.TKroot = None + self.TKrootDestroyed = False + + def AddForm(self, Form): + self.FormList.append(Form) + + def Close(self): + self.FormReturnValues = [] + for form in self.FormList: + form.Close() + self.FormReturnValues.append(form.ReturnValues) + if not self.TKrootDestroyed: + self.TKrootDestroyed = True + self.TKroot.destroy() + + def __del__(self): + return + +# ====================================================================== # +# BUTTON Lazy Functions # +# ====================================================================== # + +# ------------------------- INPUT TEXT Element lazy functions ------------------------- # +def In(DefaultText = '', Scale=(None, None), Size=(None, None), AutoSizeText=None): + return InputText(DefaultText=DefaultText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText) + +def Input(DefaultText = '', Scale=(None, None), Size=(None, None), AutoSizeText=None): + return InputText(DefaultText=DefaultText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText) + +# ------------------------- TEXT Element lazy functions ------------------------- # +def Txt(DisplayText, Scale=(None, None), Size=(None, None), AutoSizeText=None, Font=None, TextColor=None): + return Text(DisplayText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, Font=Font, TextColor=TextColor) + +def T(DisplayText, Scale=(None, None), Size=(None, None), AutoSizeText=None, Font=None, TextColor=None): + return Text(DisplayText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, Font=Font, TextColor=TextColor) + +# ------------------------- FOLDER BROWSE Element lazy function ------------------------- # +def FolderBrowse(Target=(ThisRow, -1), DisplayText='Browse', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None): + return Button(BROWSE_FOLDER, Target=Target, Text=DisplayText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) + +# ------------------------- FILE BROWSE Element lazy function ------------------------- # +def FileBrowse(Target=(ThisRow, -1), FileTypes=(("ALL Files", "*.*"),),ButtonText='Browse',Scale=(None, None),Size=(None, None), AutoSizeText=None, ButtonColor=None): + return Button(BROWSE_FILE, Target, Text=ButtonText, FileTypes=FileTypes, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) + +# ------------------------- SUBMIT BUTTON Element lazy function ------------------------- # +def Submit(ButtonText='Submit', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None): + return Button(CLOSES_WIN, Text=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) + +# ------------------------- OK BUTTON Element lazy function ------------------------- # +def OK(ButtonText='OK', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None): + return Button(CLOSES_WIN, Text=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) + +# ------------------------- YES BUTTON Element lazy function ------------------------- # +def Ok(ButtonText='Ok', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None): + return Button(CLOSES_WIN, Text=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) + +# ------------------------- CANCEL BUTTON Element lazy function ------------------------- # +def Cancel(ButtonText='Cancel', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None, Font=None): + return Button(CLOSES_WIN, Text=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor, Font=Font) + +# ------------------------- YES BUTTON Element lazy function ------------------------- # +def Yes(ButtonText='Yes', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None): + return Button(CLOSES_WIN, Text=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) + +# ------------------------- NO BUTTON Element lazy function ------------------------- # +def No(ButtonText='No', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None): + return Button(CLOSES_WIN, Text=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) + +# ------------------------- GENERIC BUTTON Element lazy function ------------------------- # +# this is the only button that REQUIRES button text field +def SimpleButton(Text, Scale=(None, None),Size=(None, None), AutoSizeText=None, ButtonColor=None, Font=None): + return Button(CLOSES_WIN, Text=Text, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor, Font=Font) + +# ------------------------- GENERIC BUTTON Element lazy function ------------------------- # +# this is the only button that REQUIRES button text field +def ReadFormButton(ButtonText, Scale=(None, None),Size=(None, None), AutoSizeText=None, ButtonColor=None, Font=None): + return Button(READ_FORM, Text=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor, Font=Font) + +#------------------------------------------------------------------------------------------------------# +# ------- FUNCTION InitializeResults. Sets up form results matrix ------- # +def InitializeResults(form): + # initial results for elements are: + # TEXT - None + # INPUT - Initial value + # Button - False + results = [] + return_vals = [] + for row_num,row in enumerate(form.Rows): + r = [] + for element in row.Elements: + if element.Type == TEXT: + r.append(None) + elif element.Type == INPUT_TEXT: + r.append(element.TextInputDefault) + return_vals.append(None) + elif element.Type == INPUT_MULTILINE: + r.append(element.TextInputDefault) + return_vals.append(None) + elif element.Type == BUTTON: + r.append(False) + elif element.Type == PROGRESS_BAR: + r.append(None) + elif element.Type == INPUT_CHECKBOX: + r.append(element.InitialState) + return_vals.append(element.InitialState) + elif element.Type == INPUT_RADIO: + r.append(element.InitialState) + return_vals.append(element.InitialState) + elif element.Type == INPUT_COMBO: + r.append(element.TextInputDefault) + return_vals.append(None) + elif element.Type == INPUT_SPIN: + r.append(element.TextInputDefault) + return_vals.append(None) + results.append(r) + form.Results=results + form.ReturnValues = (None, return_vals) + return + +#===== Radio Button RadVar encoding and decoding =====# +#===== The value is simply the row * 1000 + col =====# +def DecodeRadioRowCol(RadValue): + row = RadValue//1000 + col = RadValue%1000 + return row,col + +def EncodeRadioRowCol(Row, Col): + RadValue = Row*1000 + Col + return RadValue + +# ------- FUNCTION BuildResults. Form exiting so build the results to pass back ------- # +# format of return values is +# (Button Pressed, input_values) +def BuildResults(form): + # Results for elements are: + # TEXT - Nothing + # INPUT - Read value from TK + # Button - Button Text and position as a Tuple + + # Get the initialized results so we don't have to rebuild + results=form.Results + button_pressed_text = None + input_values = [] + for row_num,row in enumerate(form.Rows): + for col_num, element in enumerate(row.Elements): + if element.Type == INPUT_TEXT: + value=element.TKStringVar.get() + results[row_num][col_num] = value + input_values.append(value) + elif element.Type == INPUT_CHECKBOX: + value=element.TKIntVar.get() + results[row_num][col_num] = value + input_values.append(value != 0) + elif element.Type == INPUT_RADIO: + RadVar=element.TKIntVar.get() + this_rowcol = EncodeRadioRowCol(row_num,col_num) + value = RadVar == this_rowcol + results[row_num][col_num] = value + input_values.append(value) + elif element.Type == BUTTON: + if results[row_num][col_num] is True: + button_pressed_text = element.Text + results[row_num][col_num] = False + elif element.Type == INPUT_COMBO: + value=element.TKStringVar.get() + results[row_num][col_num] = value + input_values.append(value) + elif element.Type == INPUT_SPIN: + try: + value=element.TKStringVar.get() + except: + value = 0 + results[row_num][col_num] = value + input_values.append(value) + elif element.Type == INPUT_MULTILINE: + try: + value=element.TKText.get(1.0, tk.END) + element.TKText.delete('1.0', tk.END) + except: + value = None + results[row_num][col_num] = value + input_values.append(value) + + return_value = (button_pressed_text,input_values) + form.ReturnValues = return_value + form.ResultsBuilt = True + return return_value + + +# ------------------------------------------------------------------------------------------------------------------ # +# ===================================== TK CODE STARTS HERE ====================================================== # +# ------------------------------------------------------------------------------------------------------------------ # +def ConvertFlexToTK(MyFlexForm): + master = MyFlexForm.TKroot + # only set title on non-tabbed forms + if not MyFlexForm.IsTabbedForm: + master.title(MyFlexForm.Title) + font = MyFlexForm.Font + InitializeResults(MyFlexForm) + border_depth = MyFlexForm.BorderDepth if MyFlexForm.BorderDepth is not None else DEFAULT_BORDER_WIDTH + # --------------------------------------------------------------------------- # + # **************** Use FlexForm to build the tkinter window ********** ----- # + # Building is done row by row. # + # --------------------------------------------------------------------------- # + focus_set = False + ######################### LOOP THROUGH ROWS ######################### + # *********** ------- Loop through ROWS ------- ***********# + for row_num, flex_row in enumerate(MyFlexForm.Rows): + ######################### LOOP THROUGH ELEMENTS ON ROW ######################### + # *********** ------- Loop through ELEMENTS ------- ***********# + # *********** Make TK Row ***********# + tk_row_frame = tk.Frame(master) + for col_num, element in enumerate(flex_row.Elements): + element.ParentForm = MyFlexForm # save the button's parent form object + if MyFlexForm.Font and (element.Font == DEFAULT_FONT or not element.Font): + font = MyFlexForm.Font + elif element.Font is not None: + font = element.Font + # ------- Determine Auto-Size setting on a cascading basis ------- # + if element.AutoSizeText is not None: # if element overide + auto_size_text = element.AutoSizeText + elif flex_row.AutoSizeText is not None: # if Row override + auto_size_text = flex_row.AutoSizeText + elif MyFlexForm.AutoSizeText is not None: # if form override + auto_size_text = MyFlexForm.AutoSizeText + else: + auto_size_text = DEFAULT_AUTOSIZE_TEXT + # Determine Element size + element_size = element.Size + if (element_size == (None, None)): # user did not specify a size + element_size = MyFlexForm.DefaultElementSize + else: auto_size_text = False # if user has specified a size then it shouldn't autosize + # Apply scaling... Element scaling is higher priority than form level + if element.Scale != (None, None): + element_size = (int(element_size[0] * element.Scale[0]), int(element_size[1] * element.Scale[1])) + elif MyFlexForm.Scale != (None, None): + element_size = (int(element_size[0] * MyFlexForm.Scale[0]), int(element_size[1] * MyFlexForm.Scale[1])) + # ------------------------- TEXT element ------------------------- # + element_type = element.Type + if element_type == TEXT: + display_text = element.DisplayText # text to display + if auto_size_text is False: + width, height=element_size + else: + lines = display_text.split('\n') + max_line_len = max([len(l) for l in lines]) + num_lines = len(lines) + if max_line_len > element_size[0]: # if text exceeds element size, the will have to wrap + width = element_size[0] + else: + width=max_line_len + height=num_lines + # ---===--- LABEL widget create and place --- # + stringvar = tk.StringVar() + element.TKStringVar = stringvar + stringvar.set(display_text) + tktext_label = tk.Label(tk_row_frame,anchor=tk.NW, textvariable=stringvar, width=width, height=height, justify=tk.LEFT, bd=border_depth, fg=element.TextColor) + # tktext_label = tk.Label(tk_row_frame,anchor=tk.NW, text=display_text, width=width, height=height, justify=tk.LEFT, bd=border_depth) + # Set wrap-length for text (in PIXELS) == PAIN IN THE ASS + wraplen = tktext_label.winfo_reqwidth() # width of widget in Pixels + tktext_label.configure( anchor=tk.NW, font=font, wraplen=wraplen*2 ) # set wrap to width of widget + tktext_label.pack(side=tk.LEFT) + # ------------------------- BUTTON element ------------------------- # + elif element_type == BUTTON: + element.Location = (row_num, col_num) + btext = element.Text + btype = element.BType + if auto_size_text is False: width=element_size[0] + else: width = 0 + height=element_size[1] + lines = btext.split('\n') + max_line_len = max([len(l) for l in lines]) + num_lines = len(lines) + if element.ButtonColor != (None, None)and element.ButtonColor != DEFAULT_BUTTON_COLOR: + bc = element.ButtonColor + elif MyFlexForm.ButtonColor != (None, None) and MyFlexForm.ButtonColor != DEFAULT_BUTTON_COLOR: + bc = MyFlexForm.ButtonColor + else: + bc = DEFAULT_BUTTON_COLOR + if bc == 'Random' or bc == 'random': + bc = GetRandomColorPair() + tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height,command=element.ButtonCallBack, justify=tk.LEFT, foreground=bc[0], background=bc[1], bd=border_depth) + element.TKButton = tkbutton # not used yet but save the TK button in case + wraplen = tkbutton.winfo_reqwidth() # width of widget in Pixels + tkbutton.configure(wraplength=wraplen, font=font) # set wrap to width of widget + tkbutton.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) + if not focus_set and btype == CLOSES_WIN: + focus_set = True + element.TKButton.bind('', element.ReturnKeyHandler) + element.TKButton.focus_set() + MyFlexForm.TKroot.focus_force() + # ------------------------- INPUT (Single Line) element ------------------------- # + elif element_type == INPUT_TEXT: + default_text = element.DefaultText + element.TKStringVar = tk.StringVar() + element.TKStringVar.set(default_text) + element.TKEntry = tk.Entry(tk_row_frame, width=element_size[0], textvariable=element.TKStringVar, bd=border_depth, font=font) + element.TKEntry.bind('', element.ReturnKeyHandler) + element.TKEntry.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) + if not focus_set: + focus_set = True + element.TKEntry.focus_set() + # ------------------------- COMBO BOX (Drop Down) element ------------------------- # + elif element_type == INPUT_COMBO: + max_line_len = max([len(str(l)) for l in element.Values]) + if auto_size_text is False: width=element_size[0] + else: width = max_line_len + element.TKStringVar = tk.StringVar() + element.TKCombo = ttk.Combobox(tk_row_frame, width=width, textvariable=element.TKStringVar,font=font ) + element.TKCombo['values'] = element.Values + element.TKCombo.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) + element.TKCombo.current(0) + # ------------------------- INPUT MULTI LINE element ------------------------- # + elif element_type == INPUT_MULTILINE: + default_text = element.DefaultText + width, height = element_size + element.TKText = tk.scrolledtext.ScrolledText(tk_row_frame, width=width, height=height, wrap='word', bd=border_depth,font=font) + element.TKText.insert(1.0, default_text) # set the default text + element.TKText.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) + if element.EnterSubmits: + element.TKText.bind('', element.ReturnKeyHandler) + if not focus_set: + focus_set = True + element.TKText.focus_set() + # ------------------------- INPUT CHECKBOX element ------------------------- # + elif element_type == INPUT_CHECKBOX: + width = 0 if auto_size_text else element_size[0] + default_value = element.InitialState + element.TKIntVar = tk.IntVar() + element.TKIntVar.set(default_value) + element.TKCheckbutton = tk.Checkbutton(tk_row_frame, anchor=tk.NW, text=element.Text, width=width, variable=element.TKIntVar, bd=border_depth, font=font) + element.TKCheckbutton.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) + # ------------------------- PROGRESS BAR element ------------------------- # + elif element_type == PROGRESS_BAR: + # save this form because it must be 'updated' (refreshed) solely for the purpose of updating bar + width = element_size[0] + fnt = tkinter.font.Font() + char_width = fnt.measure('A') # single character width + progress_length = width*char_width + progress_width = element_size[1] + direction = element.Orientation + if element.BarColor == 'Random' or element.BarColor == 'random': + bar_color = GetRandomColorPair() + elif element.BarColor != (None, None): # if element has a bar color, use it + bar_color = element.BarColor + else: + bar_color = DEFAULT_PROGRESS_BAR_COLOR + element.TKProgressBar = TKProgressBar(tk_row_frame, element.MaxValue, progress_length, progress_width, Orientation=direction, BarColor=bar_color, Borderwidth=element.BorderWidth, Relief=element.Relief) + s = ttk.Style() + element.TKProgressBar.TKCanvas.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) + # ------------------------- INPUT RADIO BUTTON element ------------------------- # + elif element_type == INPUT_RADIO: + width = 0 if auto_size_text else element_size[0] + default_value = element.InitialState + ID = element.GroupID + # see if ID has already been placed + value = EncodeRadioRowCol(row_num, col_num) # value to set intvar to if this radio is selected + if ID in MyFlexForm.RadioDict: + RadVar = MyFlexForm.RadioDict[ID] + else: + RadVar = tk.IntVar() + MyFlexForm.RadioDict[ID] = RadVar + element.TKIntVar = RadVar # store the RadVar in Radio object + if default_value: # if this radio is the one selected, set RadVar to match + element.TKIntVar.set(value) + element.TKRadio = tk.Radiobutton(tk_row_frame, anchor=tk.NW, text=element.Text, width=width, + variable=element.TKIntVar, value=value, bd=border_depth, font=font) + element.TKRadio.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) + # ------------------------- INPUT SPIN Box element ------------------------- # + elif element_type == INPUT_SPIN: + width, height = element_size + width = 0 if auto_size_text else element_size[0] + element.TKStringVar = tk.StringVar() + element.TKSpinBox = tk.Spinbox(tk_row_frame, values=element.Values, textvariable=element.TKStringVar, width=width, bd=border_depth) + element.TKStringVar.set(element.DefaultValue) + element.TKSpinBox.configure(font=font) # set wrap to width of widget + element.TKSpinBox.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) + # ------------------------- OUTPUT element ------------------------- # + elif element_type == OUTPUT: + width, height = element_size + element.TKOut = TKOutput(tk_row_frame, width=width, height=height, bd=border_depth) + #............................DONE WITH ROW pack the row of widgets ..........................# + # done with row, pack the row of widgets + tk_row_frame.grid(row=row_num+2, sticky=tk.W, padx=DEFAULT_MARGINS[0]) + if not MyFlexForm.IsTabbedForm: + MyFlexForm.TKroot.configure(padx=DEFAULT_MARGINS[0], pady=DEFAULT_MARGINS[1]) + else: MyFlexForm.ParentWindow.configure(padx=DEFAULT_MARGINS[0], pady=DEFAULT_MARGINS[1]) + #....................................... DONE creating and laying out window ..........................# + if MyFlexForm.IsTabbedForm: + master = MyFlexForm.ParentWindow + screen_width = master.winfo_screenwidth() # get window info to move to middle of screen + screen_height = master.winfo_screenheight() + if MyFlexForm.Location != (None, None): + loc = MyFlexForm.Location + x,y = MyFlexForm.Location + else: + master.update_idletasks() # don't forget + win_width = master.winfo_width() + win_height = master.winfo_height() + x = screen_width/2 -win_width/2 + y = screen_height/2 - win_height/2 + if y+win_height > screen_height: + y = screen_height-win_height + if x+win_width > screen_width: + x = screen_width-win_width + + move_string = '+%i+%i'%(int(x),int(y)) + master.geometry(move_string) + master.update_idletasks() # don't forget + return + +# ----====----====----====----====----==== STARTUP TK ====----====----====----====----====----# +def ShowTabbedForm(Title, *args,AutoClose=False, AutoCloseDuration=DEFAULT_AUTOCLOSE_TIME,FavIcon=DEFAULT_WINDOW_ICON): + global _my_windows + + uber = UberForm() + root = tk.Tk() + uber.TKroot = root + if Title is not None: + root.title(Title) + if not len(args): + ('******************* SHOW TABBED FORMS ERROR .... no arguments') + return + tab_control = ttk.Notebook(root) + for num,x in enumerate(args): + form, rows, tab_name = x + form.AddRows(rows) + tab = ttk.Frame(tab_control) # Create tab 1 + tab_control.add(tab, text=tab_name) # Add tab 1 + # tab_control.configure(text='new text') + tab_control.grid(row=0, sticky=tk.W) + form.TKTabControl = tab_control + form.TKroot = tab + form.IsTabbedForm = True + form.ParentWindow = root + ConvertFlexToTK(form) + form.UberParent = uber + uber.AddForm(form) + uber.FormReturnValues.append(form.ReturnValues) + + # dangerous?? or clever? use the final form as a callback for autoclose + id = root.after(AutoCloseDuration*1000, form.AutoCloseAlarmCallback) if AutoClose else 0 + icon = FavIcon if not _my_windows.user_defined_icon else _my_windows.user_defined_icon + try: uber.TKroot.iconbitmap(icon) + except: pass + + root.mainloop() + + if id: root.after_cancel(id) + uber.TKrootDestroyed = True + return uber.FormReturnValues + +# ----====----====----====----====----==== STARTUP TK ====----====----====----====----====----# +def StartupTK(MyFlexForm): + global _my_windows + + ow = _my_windows.NumOpenWindows + root = tk.Tk() if not ow else tk.Toplevel() + _my_windows.NumOpenWindows += 1 + + MyFlexForm.TKroot = root + # root.protocol("WM_DELETE_WINDOW", MyFlexForm.DestroyedCallback()) + # root.bind('', MyFlexForm.DestroyedCallback()) + ConvertFlexToTK(MyFlexForm) + MyFlexForm.SetIcon(MyFlexForm.WindowIcon) + + if MyFlexForm.AutoClose: + duration = DEFAULT_AUTOCLOSE_TIME if MyFlexForm.AutoCloseDuration is None else MyFlexForm.AutoCloseDuration + MyFlexForm.TKAfterID = root.after(duration*1000, MyFlexForm.AutoCloseAlarmCallback) + if MyFlexForm.NonBlocking: + MyFlexForm.TKroot.protocol("WM_WINDOW_DESTROYED", MyFlexForm.OnClosingCallback()) + pass + else: # it's a blocking form + MyFlexForm.TKroot.mainloop() + _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 + if MyFlexForm.RootNeedsDestroying: + MyFlexForm.TKroot.destroy() + MyFlexForm.RootNeedsDestroying = False + + return + +# ==============================_GetNumLinesNeeded ==# +# Helper function for determining how to wrap text # +# ===================================================# +def _GetNumLinesNeeded(text, max_line_width): + if max_line_width == 0: + return 1 + lines = text.split('\n') + num_lines = len(lines) # number of original lines of text + max_line_len = max([len(l) for l in lines]) # longest line + lines_used = [] + for L in lines: + lines_used.append(len(L)//max_line_width + (len(L) % max_line_width > 0)) # fancy math to round up + total_lines_needed = sum(lines_used) + return total_lines_needed + +# ------------------------------------------------------------------------------------------------------------------ # +# ===================================== Upper PySimpleGUI ============================================================== # +# Pre-built dialog boxes for all your needs # +# ------------------------------------------------------------------------------------------------------------------ # + +# ==================================== MSG BOX =====# +# Display a message wrapping at 60 characters # +# Exits via an OK button2 press # +# Returns nothing # +# ===================================================# +def MsgBox(*args, ButtonColor=None, ButtonType=MSG_BOX_OK, AutoClose=False, AutoCloseDuration=None, Icon=DEFAULT_WINDOW_ICON, LineWidth=MESSAGE_BOX_LINE_WIDTH, Font=None): + ''' + + :param args: + :param ButtonColor: + :param ButtonType: + :param AutoClose: + :param AutoCloseDuration: + :param Icon: + :param LineWidth: + :param Font: + :return: + ''' + if not args: return + with FlexForm(args[0], AutoSizeText=True, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Icon=Icon, Font=Font) as form: + max_line_total, total_lines = 0,0 + for message in args: + # fancy code to check if string and convert if not is not need. Just always convert to string :-) + # if not isinstance(message, str): message = str(message) + message = str(message) + message_wrapped = textwrap.fill(message, LineWidth) + message_wrapped_lines = message_wrapped.count('\n')+1 + longest_line_len = max([len(l) for l in message.split('\n')]) + width_used = min(longest_line_len, LineWidth) + max_line_total = max(max_line_total, width_used) + # height = _GetNumLinesNeeded(message, width_used) + height = message_wrapped_lines + form.AddRow(Text(message_wrapped, Size=(width_used, height), AutoSizeText=True),) + total_lines += height + + pad = max_line_total-15 if max_line_total > 15 else 1 + pad =1 + # show either an OK or Yes/No depending on paramater + if ButtonType is MSG_BOX_YES_NO: + form.AddRow(Text('', Size=(pad,1), AutoSizeText=False), Yes(ButtonColor=ButtonColor), No(ButtonColor=ButtonColor)) + (button_text, values) = form.Show() + return button_text == 'Yes' + elif ButtonType is MSG_BOX_CANCELLED: + form.AddRow(Text('', Size=(pad,1), AutoSizeText=False), SimpleButton('Cancelled', ButtonColor=ButtonColor)) + elif ButtonType is MSG_BOX_ERROR: + form.AddRow(Text('', Size=(pad,1), AutoSizeText=False), SimpleButton('ERROR', Size=(5,1), ButtonColor=ButtonColor)) + elif ButtonType is MSG_BOX_OK_CANCEL: + form.AddRow(Text('', Size=(pad,1), AutoSizeText=False), SimpleButton('OK', Size=(5,1), ButtonColor=ButtonColor), + SimpleButton('Cancel', Size=(5, 1), ButtonColor=ButtonColor)) + else: + form.AddRow(Text('', Size=(pad,1), AutoSizeText=False), SimpleButton('OK', Size=(5,1), ButtonColor=ButtonColor)) + + button, values = form.Show() + return button + +# ============================== MsgBoxAutoClose====# +# Lazy function. Same as calling MsgBox with parms # +# ===================================================# +def MsgBoxAutoClose(*args, ButtonColor=None,AutoClose=True, AutoCloseDuration=DEFAULT_AUTOCLOSE_TIME, Font=None): + MsgBox(*args, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Font=Font) + return + + +# ============================== MsgBoxError =====# +# Like MsgBox but presents RED BUTTONS # +# ===================================================# +def MsgBoxError(*args, ButtonColor=DEFAULT_ERROR_BUTTON_COLOR,AutoClose=False, AutoCloseDuration=None, Font=None): + MsgBox(*args, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Font=Font) + return + +# ============================== MsgBoxCancel =====# +# Like MsgBox but presents RED BUTTONS # +# ===================================================# +def MsgBoxCancel(*args,ButtonColor=DEFAULT_CANCEL_BUTTON_COLOR,AutoClose=False, AutoCloseDuration=None, Font=None): + MsgBox(*args, ButtonType=MSG_BOX_CANCELLED, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Font=Font) + return + +# ============================== MsgBoxOK =====# +# Like MsgBox but only 1 button # +# ===================================================# +def MsgBoxOK(*args,ButtonColor=('white', 'black'),AutoClose=False, AutoCloseDuration=None, Font=None): + MsgBox(*args, ButtonType=MSG_BOX_OK, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Font=Font) + return + +# ============================== MsgBoxCancel =====# +# Like MsgBox but presents RED BUTTONS # +# ===================================================# +def MsgBoxOKCancel(*args,ButtonColor=None,AutoClose=False, AutoCloseDuration=None, Font=None): + result = MsgBox(*args, ButtonType=MSG_BOX_OK_CANCEL, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Font=Font) + return result + +# ==================================== YesNoBox=====# +# Like MsgBox but presents Yes and No buttons # +# Returns True if Yes was pressed else False # +# ===================================================# +def YesNoBox(*args,ButtonColor=None,AutoClose=False, AutoCloseDuration=None, Font=None): + result = MsgBox(*args,ButtonType=MSG_BOX_YES_NO, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Font=Font) + return result + +# ============================== PROGRESS METER ========================================== # + +def ConvertArgsToSingleString(*args): + max_line_total, width_used , total_lines, = 0,0,0 + single_line_message = '' + # loop through args and built a SINGLE string from them + for message in args: + # fancy code to check if string and convert if not is not need. Just always convert to string :-) + # if not isinstance(message, str): message = str(message) + message = str(message) + longest_line_len = max([len(l) for l in message.split('\n')]) + width_used = min(longest_line_len, MESSAGE_BOX_LINE_WIDTH) + max_line_total = max(max_line_total, width_used) + lines_needed = _GetNumLinesNeeded(message, width_used) + total_lines += lines_needed + single_line_message += message + '\n' + return single_line_message, width_used, total_lines + + +# ============================== ProgressMeter =====# +# ===================================================# +def ProgressMeter(Title, MaxValue, *args, Orientation=None, BarColor=DEFAULT_PROGRESS_BAR_COLOR, ButtonColor=None,Size=DEFAULT_PROGRESS_BAR_SIZE, Scale=(None, None), BorderWidth=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): + ''' + Create and show a form on tbe caller's behalf. + :param Title: + :param MaxValue: + :param args: ANY number of arguments the caller wants to display + :param Orientation: + :param BarColor: + :param Size: + :param Scale: + :param Style: + :param StyleOffset: + :return: ProgressBar object that is in the form + ''' + orientation = DEFAULT_METER_ORIENTATION if Orientation is None else Orientation + target = (0,0) if orientation[0].lower() == 'h' else (0,1) + bar2 = ProgressBar(MaxValue, Orientation=orientation, Size=Size, BarColor=BarColor, Scale=Scale, Target=target, BorderWidth=BorderWidth) + form = FlexForm(Title, AutoSizeText=True) + + # Form using a horizontal bar + if orientation[0].lower() == 'h': + single_line_message, width, height = ConvertArgsToSingleString(*args) + bar2.TextToDisplay = single_line_message + bar2.MaxValue = MaxValue + bar2.CurrentValue = 0 + form.AddRow(Text(single_line_message,Size=(width+20, height+3), AutoSizeText=True)) + form.AddRow((bar2)) + form.AddRow((Cancel(ButtonColor=ButtonColor))) + else: + single_line_message, width, height = ConvertArgsToSingleString(*args) + bar2.TextToDisplay = single_line_message + bar2.MaxValue = MaxValue + bar2.CurrentValue = 0 + form.AddRow(bar2, Text(single_line_message,Size=(width+20, height+3), AutoSizeText=True)) + form.AddRow((Cancel(ButtonColor=ButtonColor))) + + form.NonBlocking = True + form.Show(NonBlocking = True) + return bar2 + +# ============================== ProgressMeterUpdate =====# +def ProgressMeterUpdate(bar, Value, *args): + ''' + Update the progress meter for a form + :param form: class ProgressBar + :param Value: int + :return: True if not cancelled, OK....False if Error + ''' + global _my_windows + if bar == None: return False + if bar.BarExpired: return False + message, w, h = ConvertArgsToSingleString(*args) + + + bar.TextToDisplay = message + bar.CurrentValue = Value + rc = bar.UpdateBar(Value) + if Value >= bar.MaxValue or not rc: + bar.BarExpired = True + bar.ParentForm.Close() + if bar.ParentForm.RootNeedsDestroying: + try: + bar.ParentForm.TKroot.destroy() + _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 + except: pass + bar.ParentForm.RootNeedsDestroying = False + bar.ParentForm.__del__() + return False + + return rc + +# ============================== EASY PROGRESS METER ========================================== # +# class to hold the easy meter info (a global variable essentialy) +class EasyProgressMeterDataClass(): + def __init__(self, Title='', CurrentValue=1, MaxValue=10, StartTime=None, StatMessages=()): + self.Title = Title + self.CurrentValue = CurrentValue + self.MaxValue = MaxValue + self.StartTime = StartTime + self.StatMessages = StatMessages + self.ParentForm = None + self.MeterID = None + + # =========================== COMPUTE PROGRESS STATS ======================# + def ComputeProgressStats(self): + utc = datetime.datetime.utcnow() + time_delta = utc - self.StartTime + total_seconds = time_delta.total_seconds() + if not total_seconds: + total_seconds = 1 + try: + time_per_item = total_seconds / self.CurrentValue + except: + time_per_item = 1 + seconds_remaining = (self.MaxValue - self.CurrentValue) * time_per_item + time_remaining = str(datetime.timedelta(seconds=seconds_remaining)) + time_remaining_short = (time_remaining).split(".")[0] + time_delta_short = str(time_delta).split(".")[0] + total_time = time_delta + datetime.timedelta(seconds=seconds_remaining) + total_time_short = str(total_time).split(".")[0] + self.StatMessages = [ + '{} of {}'.format(self.CurrentValue, self.MaxValue), + '{} %'.format(100*self.CurrentValue//self.MaxValue), + '', + ' {:6.2f} Iterations per Second'.format(self.CurrentValue/total_seconds), + ' {:6.2f} Seconds per Iteration'.format(total_seconds/(self.CurrentValue if self.CurrentValue else 1)), + '', + '{} Elapsed Time'.format(time_delta_short), + '{} Time Remaining'.format(time_remaining_short), + '{} Estimated Total Time'.format(total_time_short)] + return + + +# ============================== EasyProgressMeter =====# +def EasyProgressMeter(Title, CurrentValue, MaxValue,*args, Orientation=None, BarColor=DEFAULT_PROGRESS_BAR_COLOR, ButtonColor=None, Size=DEFAULT_PROGRESS_BAR_SIZE, Scale=(None, None),BorderWidth=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): + ''' + A ONE-LINE progress meter. Add to your code where ever you need a meter. No need for a second + function call before your loop. You've got enough code to write! + :param Title: Title will be shown on the window + :param CurrentValue: Current count of your items + :param MaxValue: Max value your count will ever reach. This indicates it should be closed + :param args: VARIABLE number of arguements... you request it, we'll print it no matter what the item! + :param Orientation: + :param BarColor: + :param Size: + :param Scale: + :param Style: + :param StyleOffset: + :return: False if should stop the meter + ''' + # STATIC VARIABLE! + # This is a very clever form of static variable using a function attribute + # If the variable doesn't yet exist, then it will create it and initialize with the 3rd parameter + EasyProgressMeter.EasyProgressMeterData = getattr(EasyProgressMeter, 'EasyProgressMeterData', EasyProgressMeterDataClass()) + # if no meter currently running + if EasyProgressMeter.EasyProgressMeterData.MeterID is None: # Starting a new meter + if int(CurrentValue) >= int(MaxValue): + return False + del(EasyProgressMeter.EasyProgressMeterData) + EasyProgressMeter.EasyProgressMeterData = EasyProgressMeterDataClass(Title, 1, int(MaxValue), datetime.datetime.utcnow(), []) + EasyProgressMeter.EasyProgressMeterData.ComputeProgressStats() + message = "\n".join([line for line in EasyProgressMeter.EasyProgressMeterData.StatMessages]) + EasyProgressMeter.EasyProgressMeterData.MeterID = ProgressMeter(Title, int(MaxValue), message, *args, Orientation=Orientation, BarColor=BarColor, Size=Size, Scale=Scale, ButtonColor=ButtonColor,BorderWidth=BorderWidth) + EasyProgressMeter.EasyProgressMeterData.ParentForm = EasyProgressMeter.EasyProgressMeterData.MeterID.ParentForm + return True + # if exactly the same values as before, then ignore. + if EasyProgressMeter.EasyProgressMeterData.MaxValue == MaxValue and EasyProgressMeter.EasyProgressMeterData.CurrentValue == CurrentValue: + return True + if EasyProgressMeter.EasyProgressMeterData.MaxValue != int(MaxValue): + EasyProgressMeter.EasyProgressMeterData.MeterID = None + EasyProgressMeter.EasyProgressMeterData.ParentForm = None + del(EasyProgressMeter.EasyProgressMeterData) + EasyProgressMeter.EasyProgressMeterData = EasyProgressMeterDataClass() # setup a new progress meter + return True # HAVE to return TRUE or else the new meter will thing IT is failing when it hasn't + EasyProgressMeter.EasyProgressMeterData.CurrentValue = int(CurrentValue) + EasyProgressMeter.EasyProgressMeterData.MaxValue = int(MaxValue) + EasyProgressMeter.EasyProgressMeterData.ComputeProgressStats() + message = '' + for line in EasyProgressMeter.EasyProgressMeterData.StatMessages: + message = message + str(line) + '\n' + message = "\n".join(EasyProgressMeter.EasyProgressMeterData.StatMessages) + rc = ProgressMeterUpdate(EasyProgressMeter.EasyProgressMeterData.MeterID, CurrentValue,*args, message ) + # if counter >= max then the progress meter is all done. Indicate none running + if CurrentValue >= EasyProgressMeter.EasyProgressMeterData.MaxValue or not rc: + EasyProgressMeter.EasyProgressMeterData.MeterID = None + del(EasyProgressMeter.EasyProgressMeterData) + EasyProgressMeter.EasyProgressMeterData = EasyProgressMeterDataClass() # setup a new progress meter + return False # even though at the end, return True so don't cause error with the app + return rc # return whatever the update told us + + +def EasyProgressMeterCancel(Title, *args): + EasyProgressMeter.EasyProgressMeterData = getattr(EasyProgressMeter, 'EasyProgressMeterData', EasyProgressMeterDataClass()) + if EasyProgressMeter.EasyProgressMeterData.MeterID is not None: + # tell the normal meter update that we're at max value which will close the meter + rc = EasyProgressMeter(Title, EasyProgressMeter.EasyProgressMeterData.MaxValue, EasyProgressMeter.EasyProgressMeterData.MaxValue, ' *** CANCELLING ***', 'Caller requested a cancel', *args) + return rc + return True + + +def GetRandomColor(): + nums = randint(0,255), randint(0,255), randint(0,255) + color_code ='#' + ''.join('{:02X}'.format(a) for a in nums) + return color_code + + +def GetRandomColorPair(): + fg = GetRandomColor() + bg = GetComplimentaryHex(fg) + color_code = (fg, bg) + return color_code + +# input is #RRGGBB +# output is #RRGGBB +def GetComplimentaryHex(color): + # strip the # from the beginning + color = color[1:] + # convert the string into hex + color = int(color, 16) + # invert the three bytes + # as good as substracting each of RGB component by 255(FF) + comp_color = 0xFFFFFF ^ color + # convert the color back to hex by prefixing a # + comp_color = "#%06X" % comp_color + # return the result + return comp_color + +# ======================== Scrolled Text Box =====# +# ===================================================# +def ScrolledTextBox(*args, ButtonColor=None, YesNo=False, AutoClose=False, AutoCloseDuration=None, Height=None): + if not args: return + with FlexForm(args[0], AutoSizeText=True, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration) as form: + max_line_total, max_line_width, total_lines, height = 0,0,0,0 + complete_output = '' + for message in args: + # fancy code to check if string and convert if not is not need. Just always convert to string :-) + # if not isinstance(message, str): message = str(message) + message = str(message) + longest_line_len = max([len(l) for l in message.split('\n')]) + width_used = min(longest_line_len, MESSAGE_BOX_LINE_WIDTH) + max_line_total = max(max_line_total, width_used) + max_line_width = MESSAGE_BOX_LINE_WIDTH + lines_needed = _GetNumLinesNeeded(message, width_used) + height += lines_needed + complete_output += message + '\n' + total_lines += lines_needed + height = MAX_SCROLLED_TEXT_BOX_HEIGHT if height > MAX_SCROLLED_TEXT_BOX_HEIGHT else height + if Height: + height = Height + form.AddRow(Multiline(complete_output, Size=(max_line_width, height)), AutoSizeText=True) + pad = max_line_total-15 if max_line_total > 15 else 1 + # show either an OK or Yes/No depending on paramater + if YesNo: + form.AddRow(Text('', Size=(pad,1), AutoSizeText=False), Yes(), No()) + (button_text, values) = form.Show() + return button_text == 'Yes' + else: + form.AddRow(Text('', Size=(pad,1), AutoSizeText=False), SimpleButton('OK', Size=(5,1), ButtonColor=ButtonColor)) + form.Show() + + +# ---------------------------------------------------------------------- # +# GetPathBox # +# Pre-made dialog that looks like this roughly # +# MESSAGE # +# __________________________ # +# |__________________________| (BROWSE) # +# (SUBMIT) (CANCEL) # +# RETURNS two values: # +# True/False, path # +# (True if Submit was pressed, false otherwise) # +# ---------------------------------------------------------------------- # +def GetPathBox(Title, Message, DefaultPath='', ButtonColor=None, Size=DEFAULT_ELEMENT_SIZE): + with FlexForm(Title, AutoSizeText=True, ButtonColor=ButtonColor) as form: + layout = [[Text(Message,AutoSizeText=True)], + [InputText(DefaultText=DefaultPath, Size=Size), FolderBrowse()], + [Submit(), Cancel()]] + + (button, input_values) = form.LayoutAndShow(layout) + if button != 'Submit': + return False,None + else: + path = input_values[0] + return True, path + +# ============================== GetFileBox =========# +# Like the Get folder box but for files # +# ===================================================# +def GetFileBox(Title, Message, DefaultPath='',FileTypes=(("ALL Files", "*.*"),), ButtonColor=None): + with FlexForm(Title, AutoSizeText=True, ButtonColor=ButtonColor) as form: + layout = [[Text(Message,AutoSizeText=True)], + [InputText(DefaultText=DefaultPath), FileBrowse(FileTypes=FileTypes)], + [Submit(), Cancel()]] + + (button, input_values) = form.LayoutAndShow(layout) + if button != 'Submit': + return False,None + else: + path = input_values[0] + return True, path + + + +# ============================== GetTextBox =========# +# Get a single line of text # +# ===================================================# +def GetTextBox(Title, Message, Default='', ButtonColor=None): + with FlexForm(Title, AutoSizeText=True, ButtonColor=ButtonColor) as form: + layout = [[Text(Message,AutoSizeText=True)], + [InputText(DefaultText=Default)], + [Submit(), Cancel()]] + + (button, input_values) = form.LayoutAndShow(layout) + if button != 'Submit': + return False,None + else: + return True, input_values[0] + + +# ============================== SetGlobalIcon ======# +# Sets the icon to be used by default # +# ===================================================# +def SetGlobalIcon(Icon): + global _my_windows + + try: + with open(Icon, 'r') as icon_file: + pass + except: + raise FileNotFoundError + + _my_windows.user_defined_icon = Icon + return True + + +# ============================== SetGlobalIcon ======# +# Sets the icon to be used by default # +# ===================================================# +def SetButtonColor(foreground, background): + global DEFAULT_BUTTON_COLOR + + DEFAULT_BUTTON_COLOR = (foreground, background) + + +# ============================== sprint ======# +# Is identical to the Scrolled Text Box # +# Provides a crude 'print' mechanism but in a # +# GUI environment # +# ============================================# +sprint=ScrolledTextBox From 258939af56622ebfba0af60a2918c8fa4f740d39 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 11 Jul 2018 15:25:04 -0400 Subject: [PATCH 002/209] readme checkin Initial readme checkin --- readme.md | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 readme.md diff --git a/readme.md b/readme.md new file mode 100644 index 000000000..d00912653 --- /dev/null +++ b/readme.md @@ -0,0 +1,130 @@ +# PySimpleGUI + +... is a simple GUI, but also powerfully customizable. It's simple from the programmer's view point. The idea is to make adding a GUI to a Python program be a simple and trivial task. + +I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? + +Python itself doesn't have a SIMPLE solution... nor did the *many* GUI packages I tried. Most tried to do TOO MUCH, making it impossible for users to get started quickly. Others were just plain broken, requiring multiple files or other packages. + +The PySimpleGUI solution is focused on the developer. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. + +You can add a GUI to your command line with a single line of code. With 3 or 4 lines of code you can add a fully custom designed GUI. + +The customization power comes from the form/dialog box builder that enables users to experience all of the normal GUI widgets without having to write a lot of code. + +Features include: + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Checkboxes + Radio Buttons + Icons + Multi-line Text Input + Scrollable Output + Progress Bar + Async/Non-Blocking Windows + Persistent Windows + Redirect Python Output/Errors to scrolling Window + 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + + +## Getting Started with PySimpleGUI + +To use `import PySimpleGUI as SG` + +For examples download + + DisplayHash.py - Shows you how to use the most basic functionality + ColorDemo.py - COLORS are a big part of the fun of a GUI, right? + + HowDoI.py - More advanced 'Chat-style' windows that don't close with button clicks + + +### Prerequisites + +Python 3 +tkinter + +Should run on all Python platforms that have tkinter running on them. Has been thoroughly tested on Windows. While not tested elsewhere, should work on Linux, Mac, Pi, etc. + +### Installing + + pip install PySimpleGUI + or +Simply download the file - PySimpleGUI.py and import it into your code + +## Running the tests + + +## Deployment + +PySimpleGUI can be broken down into 2 types of API's: + * High Level single call functions + * Custom form functions + + +**High Level API Calls** + +The classic "input a value, print result" example. +Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. +This code prompts user to input a line of text and then displays that text in a messages box: + + import PySimpleGUI_local as SG + + rc = SG.GetTextBox('Title', 'Please input something') + SG.MsgBox('Results', 'The value returned from GetTextBox', rc) + +![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) + +![MsgBox](https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg) + + +**Custom Form API Calls** +Here is a complete form - design, display, return information straight into caller's variables + + # ------- Form design ------- # + layout = [[Text('The SHA-1 Hash for the file')], + [InputText(), FileBrowse()], + [Submit(), Cancel()]] + # ------- Form show ------- # + (button, (source_filename,)) = FlexForm('Display A Hash in GooeyGUI', AutoSizeText=True).LayoutAndShow(layout) + +Important initial concepts + Return information from FlexForm, SG's primary form builder interface, is in this format: + + (button, (value1, value2, ...)) + +Don't forget all those ()'s of your values won't be coreectly assigned. + +If you have a SINGLE value being returned, it is written this way: + + (button, (value1,)) + +Forgetting the comma will mess you up but good + +## Built With + + +## Contributing + +A MikeTheWatchGuy production... entirely responsible for this code + +## Versioning + +1.0.9 - July 10, 2018 - Initial Release + + +## Authors + + +## License + +This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details + +## Acknowledgments + +* Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence From f35fa97dfe0a7eaf1ee46f7ddad7e62cf1f516b8 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 11 Jul 2018 19:18:34 -0400 Subject: [PATCH 003/209] Uploaded to PyPi --- PySimpleGUI.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 995c6f5c9..333ab230a 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1309,7 +1309,7 @@ def MsgBoxOKCancel(*args,ButtonColor=None,AutoClose=False, AutoCloseDuration=Non # Like MsgBox but presents Yes and No buttons # # Returns True if Yes was pressed else False # # ===================================================# -def YesNoBox(*args,ButtonColor=None,AutoClose=False, AutoCloseDuration=None, Font=None): +def MsgBoxYesNo(*args,ButtonColor=None,AutoClose=False, AutoCloseDuration=None, Font=None): result = MsgBox(*args,ButtonType=MSG_BOX_YES_NO, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Font=Font) return result @@ -1586,7 +1586,7 @@ def ScrolledTextBox(*args, ButtonColor=None, YesNo=False, AutoClose=False, AutoC # True/False, path # # (True if Submit was pressed, false otherwise) # # ---------------------------------------------------------------------- # -def GetPathBox(Title, Message, DefaultPath='', ButtonColor=None, Size=DEFAULT_ELEMENT_SIZE): +def GetPathBox(Title, Message, DefaultPath='', ButtonColor=None, Size=(None,None)): with FlexForm(Title, AutoSizeText=True, ButtonColor=ButtonColor) as form: layout = [[Text(Message,AutoSizeText=True)], [InputText(DefaultText=DefaultPath, Size=Size), FolderBrowse()], @@ -1602,10 +1602,10 @@ def GetPathBox(Title, Message, DefaultPath='', ButtonColor=None, Size=DEFAULT_EL # ============================== GetFileBox =========# # Like the Get folder box but for files # # ===================================================# -def GetFileBox(Title, Message, DefaultPath='',FileTypes=(("ALL Files", "*.*"),), ButtonColor=None): +def GetFileBox(Title, Message, DefaultPath='',FileTypes=(("ALL Files", "*.*"),), ButtonColor=None, Size=(None,None)): with FlexForm(Title, AutoSizeText=True, ButtonColor=ButtonColor) as form: layout = [[Text(Message,AutoSizeText=True)], - [InputText(DefaultText=DefaultPath), FileBrowse(FileTypes=FileTypes)], + [InputText(DefaultText=DefaultPath, Size=Size), FileBrowse(FileTypes=FileTypes)], [Submit(), Cancel()]] (button, input_values) = form.LayoutAndShow(layout) @@ -1616,14 +1616,13 @@ def GetFileBox(Title, Message, DefaultPath='',FileTypes=(("ALL Files", "*.*"),), return True, path - # ============================== GetTextBox =========# # Get a single line of text # # ===================================================# -def GetTextBox(Title, Message, Default='', ButtonColor=None): +def GetTextBox(Title, Message, Default='', ButtonColor=None, Size=(None, None)): with FlexForm(Title, AutoSizeText=True, ButtonColor=ButtonColor) as form: layout = [[Text(Message,AutoSizeText=True)], - [InputText(DefaultText=Default)], + [InputText(DefaultText=Default, Size=Size)], [Submit(), Cancel()]] (button, input_values) = form.LayoutAndShow(layout) From 4aa9d6299c892f2e0ac11d413fa93a82aab0a387 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 11 Jul 2018 19:20:35 -0400 Subject: [PATCH 004/209] Readme update Big update --- readme.md | 295 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 211 insertions(+), 84 deletions(-) diff --git a/readme.md b/readme.md index d00912653..26a375385 100644 --- a/readme.md +++ b/readme.md @@ -1,130 +1,257 @@ -# PySimpleGUI -... is a simple GUI, but also powerfully customizable. It's simple from the programmer's view point. The idea is to make adding a GUI to a Python program be a simple and trivial task. +# PySimpleGUI + +This really is a simple GUI, but also powerfully customizable. -I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? +![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) -Python itself doesn't have a SIMPLE solution... nor did the *many* GUI packages I tried. Most tried to do TOO MUCH, making it impossible for users to get started quickly. Others were just plain broken, requiring multiple files or other packages. +I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? + +Python itself doesn't have a simple solution... nor did the *many* GUI packages I tried. Most tried to do TOO MUCH, making it impossible for users to get started quickly. Others were just plain broken, requiring multiple files or other packages that were missing. + +The PySimpleGUI solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. + +You can add a GUI to your command line with a single line of code. With 3 or 4 lines of code you can add a fully customized GUI. + +The customization power comes from the form/dialog box builder that enables users to experience all of the normal GUI widgets without having to write a lot of code. + +Features of PySimpleGUI include: + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Checkboxes + Radio Buttons + Icons + Multi-line Text Input + Scroll-able Output + Progress Bar + Async/Non-Blocking Windows + Tabbed forms + Persistent Windows + Redirect Python Output/Errors to scrolling Window + 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + + +## Getting Started with PySimpleGUI + +### Installing + + pip install PySimpleGUI + or +Simply download the file - PySimpleGUI.py and import it into your code + + +### Prerequisites + +Python 3 +tkinter + +Should run on all Python platforms that have tkinter running on them. Has been thoroughly tested on Windows. While not tested elsewhere, should work on Linux, Mac, Pi, etc. + +### Using + +To us in your code, simply import.... + `import PySimpleGUI as SG` + +Then use either "high level" API calls or build your own forms. + + SG.MsgBox('This is my first message box') +![simple msgbox](https://user-images.githubusercontent.com/13696193/42597824-1749b160-8528-11e8-9114-374bf9731b30.jpg) + +Yes, it's just that easy to have a window appear on the screen using Python. + +## APIs + +PySimpleGUI can be broken down into 2 types of API's: + * High Level single call functions + * Custom form functions + + +### Python Language Features + + There are a couple of Python language features that PySimpleGUI utilizes heavily that should be understood first... + * Variable number of arguments to a function call + * Optional parameters to a function call + +#### Variable Number of Arguments -The PySimpleGUI solution is focused on the developer. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. + The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. + + SG.MsgBox('Variable number of parameters example', my_variable, second_variable, "etc") -You can add a GUI to your command line with a single line of code. With 3 or 4 lines of code you can add a fully custom designed GUI. +Each new item begins on a new line in the Message Box + ![variablearguments](https://user-images.githubusercontent.com/13696193/42598375-022bc51e-852a-11e8-8f77-4d664ae1a560.jpg) + +#### Optional Parameters to a Function Call + +This feature of the Python language is utilized ***heavily*** as a method of customizing forms and part of forms. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. -The customization power comes from the form/dialog box builder that enables users to experience all of the normal GUI widgets without having to write a lot of code. +Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't have to be specified on each and every call. -Features include: - Text - Single Line Input - Buttons including these types: - File Browse - Folder Browse - Non-closing return - Close form - Checkboxes - Radio Buttons - Icons - Multi-line Text Input - Scrollable Output - Progress Bar - Async/Non-Blocking Windows - Persistent Windows - Redirect Python Output/Errors to scrolling Window - 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + def MsgBox(*args, + ButtonColor=None, + ButtonType=MSG_BOX_OK, + AutoClose=False, + AutoCloseDuration=None, + Icon=DEFAULT_WINDOW_ICON, + LineWidth=MESSAGE_BOX_LINE_WIDTH, + Font=None): +If the caller wanted to change the button color to be black on yellow, the call would look something like this: -## Getting Started with PySimpleGUI + SG.MsgBox('This box has a custom button color', + ButtonColor=('black', 'yellow')) -To use `import PySimpleGUI as SG` +![custombuttoncolor](https://user-images.githubusercontent.com/13696193/42599212-84f3fe2e-852c-11e8-8a60-4aad669a1fd6.jpg) -For examples download - - DisplayHash.py - Shows you how to use the most basic functionality - ColorDemo.py - COLORS are a big part of the fun of a GUI, right? - - HowDoI.py - More advanced 'Chat-style' windows that don't close with button clicks - +### High Level API Calls -### Prerequisites +The classic "input a value, print result" example. +Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. +This code prompts user to input a line of text and then displays that text in a messages box: + + import PySimpleGUI_local as SG + + rc = SG.GetTextBox('Title', 'Please input something') + SG.MsgBox('Results', 'The value returned from GetTextBox', rc) + +![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) + +![MsgBox](https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg) + +#### Message Boxes +In addition to MsgBox, you'll find a several API calls that are shortcuts to common messages boxes. You can achieve similar results by calling MsgBox with the correct parameters. -Python 3 -tkinter +The differences tend to be the number and types of buttons. Here are the calls and the windows that are created. -Should run on all Python platforms that have tkinter running on them. Has been thoroughly tested on Windows. While not tested elsewhere, should work on Linux, Mac, Pi, etc. + import PySimpleGUI as SG -### Installing + `SG.MsgBoxOK('This is an OK MsgBox')` + ![msgboxok](https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg) - pip install PySimpleGUI - or -Simply download the file - PySimpleGUI.py and import it into your code + SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') -## Running the tests +![msgboxokcancel](https://user-images.githubusercontent.com/13696193/42599858-8e8eff22-852e-11e8-8d5c-3fe99237eb7f.jpg) + SG.MsgBoxCancel('This is a Cancel MsgBox') +![msgboxcancel](https://user-images.githubusercontent.com/13696193/42599857-8e53dc4e-852e-11e8-8e83-6a8cccf8e706.jpg) -## Deployment + SG.MsgBoxYesNo('This is a Yes No MsgBox') +![msgboxyesno](https://user-images.githubusercontent.com/13696193/42599856-8e304540-852e-11e8-975d-fb2b62e94300.jpg) -PySimpleGUI can be broken down into 2 types of API's: - * High Level single call functions - * Custom form functions - + SG.MsgBoxError('This is an error MsgBox') +![msgbox error](https://user-images.githubusercontent.com/13696193/42599853-8df8e078-852e-11e8-90dc-7815d69bff7e.jpg) -**High Level API Calls** + SG.MsgBoxAutoClose('This is an autoclose MsgBox') -The classic "input a value, print result" example. -Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. -This code prompts user to input a line of text and then displays that text in a messages box: +![msgbox autoclose](https://user-images.githubusercontent.com/13696193/42599855-8e147572-852e-11e8-8c23-7ec771909062.jpg) - import PySimpleGUI_local as SG - - rc = SG.GetTextBox('Title', 'Please input something') - SG.MsgBox('Results', 'The value returned from GetTextBox', rc) + SG.ScrolledTextBox(my_text, Height=10) -![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) +![scrolledtextbox](https://user-images.githubusercontent.com/13696193/42600800-a44f4562-8531-11e8-8c21-51dd70316879.jpg) + +Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing text scrolling past on your display, you can capture that text and present it in a scrolled interface. + +#### High Level User Input -![MsgBox](https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg) +There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. + - GetTextBox + - GetFileBox + - GetFolderBox + `submit_clicked, value = SG.GetTextBox('Title', 'Please enter anything')` -**Custom Form API Calls** -Here is a complete form - design, display, return information straight into caller's variables +![gettextbox](https://user-images.githubusercontent.com/13696193/42600399-1ef66a5e-8530-11e8-9bc4-78ea839213cd.jpg) - # ------- Form design ------- # - layout = [[Text('The SHA-1 Hash for the file')], - [InputText(), FileBrowse()], - [Submit(), Cancel()]] - # ------- Form show ------- # - (button, (source_filename,)) = FlexForm('Display A Hash in GooeyGUI', AutoSizeText=True).LayoutAndShow(layout) + submit_clicked, value = SG.GetFileBox('Title', 'Choose a file') -Important initial concepts - Return information from FlexForm, SG's primary form builder interface, is in this format: - - (button, (value1, value2, ...)) +![getfilebox](https://user-images.githubusercontent.com/13696193/42600398-1ed8a122-8530-11e8-9f74-88b101efcea4.jpg) -Don't forget all those ()'s of your values won't be coreectly assigned. + submit_clicked, value = SG.GetPathBox('Title', 'Choose a folder') -If you have a SINGLE value being returned, it is written this way: +![getfolderbox](https://user-images.githubusercontent.com/13696193/42600397-1ea7cef8-8530-11e8-8d43-e1000c0933cd.jpg) - (button, (value1,)) -Forgetting the comma will mess you up but good -## Built With +### Custom Form API Calls +This is the FUN part of the programming of this GUI. In order to really get the most out of the API, you should be using an IDE that supports auto complete or will show you the definition of the function. This will make customizing go smoother. +It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. Let's start with a basic Browse for a file and do something with it. -## Contributing +# COPY THIS DESIGN PATTERN! -A MikeTheWatchGuy production... entirely responsible for this code + with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + [SG.InputText(), SG.FileBrowse()], + [SG.Submit(), SG.Cancel()]] + (button, (source_filename, )) = form.LayoutAndShow(form_rows) -## Versioning +This context manager contains all of the code needed to specify, show and retrieve results for this form: +![sha hash](https://user-images.githubusercontent.com/13696193/42603149-a56acf3a-853a-11e8-91de-771efd3a65a8.jpg) -1.0.9 - July 10, 2018 - Initial Release - +It's important to use the "with" context manager. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. -## Authors +You will use this design pattern or code template for all of your "normal" (blocking) types of input forms. +PySimpleGUI's goal with the API is to be easy on the programmer. An attempt was made to make the program's code visually match the window on the screen. The way this is done is that a GUI is broken up into "Rows". Then each row is broke up into "Elements" or "Widgets". Each element is specified by names such as Text, Button, Checkbox, etc. -## License +Some elements are shortcuts, again meant to make it easy on the programmer. Rather than writing a `Button`, with name = "Submit", etc, the caller simply writes `Submit`. -This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details +Going through each line of code -## Acknowledgments + with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: +This creates a new form, storing it in the variable `form`. + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], +The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. + + [SG.InputText(), SG.FileBrowse()], +Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. + + [SG.Submit(), SG.Cancel()]] + +The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its valueso the caller. + + (button, (source_filename, )) = form.LayoutAndShow(form_rows) +This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field. + +# Return values + + Return information from FlexForm, SG's primary form builder interface, is in this format: + + (button, (value1, value2, ...)) + +Don't forget all those ()'s of your values won't be coreectly assigned. + +If you have a SINGLE value being returned, it is written this way: + + (button, (value1,)) + +Forgetting the comma will mess you up but good + +## Built With + + +## Contributing + +A MikeTheWatchGuy production... entirely responsible for this code + +## Versioning + +1.0.9 - July 10, 2018 - Initial Release + + +## Authors + + +## License + +This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details + +## Acknowledgments + * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence From 1c00e051effb0f4f84894b7c7214356fdb380a56 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 11 Jul 2018 19:27:49 -0400 Subject: [PATCH 005/209] Demo Hash a File --- DemoDisplayHash1and256.py | 103 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 DemoDisplayHash1and256.py diff --git a/DemoDisplayHash1and256.py b/DemoDisplayHash1and256.py new file mode 100644 index 000000000..1aa0f902f --- /dev/null +++ b/DemoDisplayHash1and256.py @@ -0,0 +1,103 @@ +#!Python 3 +import hashlib +import PySimpleGUI as SG + + ######################################################################### +# DisplayHash # +# A PySimpleGUI demo app that displays SHA1 hash for user browsed file # +# Useful and a recipe for GUI success # + ######################################################################### + +# ====____====____==== FUNCTION compute_hash_for_file(filename) ====____====____==== # +# Reads a file, computes the Hash # +# ---------------------------------------------------------------------------------- # +def compute_sha1_hash_for_file(filename): + try: + x = open(filename, "rb").read() + except: + return 0 + + m = hashlib.sha1() + m.update(x) + f_sha = m.hexdigest() + + return f_sha + + +# ====____====____==== FUNCTION compute_hash_for_file(filename) ====____====____==== # +# Reads a file, computes the Hash # +# ---------------------------------------------------------------------------------- # +def compute_sha256_hash_for_file(filename): + try: + f = open(filename, "rb") + x = f.read() + except: + return 0 + + m = hashlib.sha256() + m.update(x) + f_sha = m.hexdigest() + + return f_sha + + + # ====____====____==== Uses A GooeyGUI GUI ====____====____== # +# Get the filename, display the hash, dirt simple all around # + # ----------------------------------------------------------- # + +# ---------------------------------------------------------------------- # +# Compute and display SHA1 hash # +# Builds and displays the form using the most basic building blocks # +# ---------------------------------------------------------------------- # +def HashManuallyBuiltGUI(): + # ------- Form design ------- # + with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + [SG.InputText(), SG.FileBrowse()], + [SG.Submit(), SG.Cancel()]] + (button, (source_filename, )) = form.LayoutAndShow(form_rows) + + if button == 'Submit': + if source_filename != '': + hash_sha1 = compute_sha1_hash_for_file(source_filename).upper() + hash_sha256 = compute_sha256_hash_for_file(source_filename).upper() + SG.MsgBox( 'Display A Hash in PySimpleGUI', 'The SHA-1 Hash for the file\n', source_filename, hash_sha1, 'SHA-256 is', hash_sha256, LineWidth=75) + else: SG.MsgBoxError('Display A Hash in PySimpleGUI', 'Illegal filename') + else: + SG.MsgBoxError('Display A Hash in PySimpleGUI', '* Cancelled *') + + +# ---------------------------------------------------------------------- # +# Compute and display SHA1 hash # +# This one cheats and uses the higher-level Get A File pre-made func # +# Hey, it's a really common operation so why not? # +# ---------------------------------------------------------------------- # +def HashMostCompactGUI(): + # ------- INPUT GUI portion ------- # + + rc, source_filename = SG.GetFileBox('Display A Hash Using PySimpleGUI', + 'Display a Hash code for file of your choice') + + # ------- OUTPUT GUI results portion ------- # + if rc == True: + hash = compute_sha1_hash_for_file(source_filename).upper() + SG.MsgBox('Display Hash - Compact GUI', 'The SHA-1 Hash for the file\n', source_filename, hash) + else: + SG.MsgBox('Display Hash - Compact GUI', '* Cancelled *') + + +# ---------------------------------------------------------------------- # +# Our main calls two GUIs that act identically but use different calls # +# ---------------------------------------------------------------------- # +def main(): + # HashMostCompactGUI() + HashManuallyBuiltGUI() + +# ====____====____==== Pseudo-MAIN program ====____====____==== # +# This is our main-alike piece of code # +# + Starts up the GUI # +# + Gets values from GUI # +# + Runs DeDupe_folder based on GUI inputs # +# ------------------------------------------------------------- # +if __name__ == '__main__': + main() From a372c955624daf3bab3495e34afc355bbc35a8fe Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 11 Jul 2018 19:50:59 -0400 Subject: [PATCH 006/209] More readme --- readme.md | 103 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 69 insertions(+), 34 deletions(-) diff --git a/readme.md b/readme.md index 26a375385..c7743cffc 100644 --- a/readme.md +++ b/readme.md @@ -219,39 +219,74 @@ The last line of the `form_rows` variable assignment contains a Submit and a Can (button, (source_filename, )) = form.LayoutAndShow(form_rows) This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field. -# Return values +## Return values + + Return information from FlexForm, SG's primary form builder interface, is in this format: + + (button, (value1, value2, ...)) + +Don't forget all those ()'s of your values won't be coreectly assigned. + +If you have a SINGLE value being returned, it is written this way: + + (button, (value1,)) + +Forgetting the comma will mess you up but good + +## All Widgets / Elements +This code utilizes as many of the elements in one form as possible. + + with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: + layout = [[Text('Here they all are!', Size=(30,1), Font=("Helvetica", 25), TextColor='red')], + [Text('Here is some text with font sizing', Font=("Helvetica", 15))], + [InputText()], + [Checkbox('My first checkbox!'), Checkbox('My second checkbox!', Default=True)], + [Radio('My first Radio!', "RADIO1", Default=True), Radio('My second checkbox!', "RADIO1")], + [Multiline(DefaultText='This is the DEFAULT text should you decide not to type anything', Scale=(2, 10))], + [InputCombo(['choice 1', 'choice 2'], Size=(20, 3))], + [Text('_' * 90, Size=(60, 1))], + [Text('Choose Source and Destination Folders', Size=(35,1))], + [Text('Source Folder', Size=(15, 1), AutoSizeText=False), InputText('Source'), FolderBrowse()], + [Text('Destination Folder', Size=(15, 1), AutoSizeText=False), InputText('Dest'), FolderBrowse()], + [SimpleButton('Your Button with any text you want')], + [SimpleButton('Big Text', Size=(12,1), Font=("Helvetica", 20))], + [Submit(), Cancel()]] + + (button, (values)) = form.LayoutAndShow(layout) + + + + + MsgBox('Results', 'You clicked {}'.format(button),'The values returned from form', values , Font = ("Helvetica", 15)) + +This is a somewhat complex form with quite a bit of custom sizing to make things line up well. This is code you only have to write once. When looking at the code, remember that what you're seeing is a list of lists. Each row contains a list of Graphical Elements that are used to create the form. + +![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) + +Clicking Submit caused the form call to return and the call to MsgBox is made to display the results. +![results](https://user-images.githubusercontent.com/13696193/42604952-502f64e6-8543-11e8-8045-bc10d38c5fd4.jpg) + + +## Built With + + +## Contributing + +A MikeTheWatchGuy production... entirely responsible for this code + +## Versioning + +1.0.9 - July 10, 2018 - Initial Release + + +## Authors + + +## License + +This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details + +## Acknowledgments - Return information from FlexForm, SG's primary form builder interface, is in this format: - - (button, (value1, value2, ...)) - -Don't forget all those ()'s of your values won't be coreectly assigned. - -If you have a SINGLE value being returned, it is written this way: - - (button, (value1,)) - -Forgetting the comma will mess you up but good - -## Built With - - -## Contributing - -A MikeTheWatchGuy production... entirely responsible for this code - -## Versioning - -1.0.9 - July 10, 2018 - Initial Release - - -## Authors - - -## License - -This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details - -## Acknowledgments - * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence + From 96cf4fc9fc86c15e10159d707ee26c5db0706a9c Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 11 Jul 2018 22:31:28 -0400 Subject: [PATCH 007/209] Update readme.md --- readme.md | 97 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/readme.md b/readme.md index c7743cffc..bb8d48a79 100644 --- a/readme.md +++ b/readme.md @@ -84,6 +84,7 @@ PySimpleGUI can be broken down into 2 types of API's: SG.MsgBox('Variable number of parameters example', my_variable, second_variable, "etc") Each new item begins on a new line in the Message Box + ![variablearguments](https://user-images.githubusercontent.com/13696193/42598375-022bc51e-852a-11e8-8f77-4d664ae1a560.jpg) #### Optional Parameters to a Function Call @@ -221,37 +222,37 @@ This is the code that **displays** the form, collects the information and return ## Return values - Return information from FlexForm, SG's primary form builder interface, is in this format: - - (button, (value1, value2, ...)) - -Don't forget all those ()'s of your values won't be coreectly assigned. - -If you have a SINGLE value being returned, it is written this way: - - (button, (value1,)) - -Forgetting the comma will mess you up but good + Return information from FlexForm, SG's primary form builder interface, is in this format: + + (button, (value1, value2, ...)) + +Don't forget all those ()'s of your values won't be coreectly assigned. + +If you have a SINGLE value being returned, it is written this way: + + (button, (value1,)) + +Forgetting the comma will mess you up but good ## All Widgets / Elements This code utilizes as many of the elements in one form as possible. - with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: - layout = [[Text('Here they all are!', Size=(30,1), Font=("Helvetica", 25), TextColor='red')], - [Text('Here is some text with font sizing', Font=("Helvetica", 15))], - [InputText()], - [Checkbox('My first checkbox!'), Checkbox('My second checkbox!', Default=True)], - [Radio('My first Radio!', "RADIO1", Default=True), Radio('My second checkbox!', "RADIO1")], - [Multiline(DefaultText='This is the DEFAULT text should you decide not to type anything', Scale=(2, 10))], - [InputCombo(['choice 1', 'choice 2'], Size=(20, 3))], - [Text('_' * 90, Size=(60, 1))], - [Text('Choose Source and Destination Folders', Size=(35,1))], - [Text('Source Folder', Size=(15, 1), AutoSizeText=False), InputText('Source'), FolderBrowse()], - [Text('Destination Folder', Size=(15, 1), AutoSizeText=False), InputText('Dest'), FolderBrowse()], - [SimpleButton('Your Button with any text you want')], - [SimpleButton('Big Text', Size=(12,1), Font=("Helvetica", 20))], - [Submit(), Cancel()]] - + with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: + layout = [[Text('Here they all are!', Size=(30,1), Font=("Helvetica", 25), TextColor='red')], + [Text('Here is some text with font sizing', Font=("Helvetica", 15))], + [InputText()], + [Checkbox('My first checkbox!'), Checkbox('My second checkbox!', Default=True)], + [Radio('My first Radio!', "RADIO1", Default=True), Radio('My second checkbox!', "RADIO1")], + [Multiline(DefaultText='This is the DEFAULT text should you decide not to type anything', Scale=(2, 10))], + [InputCombo(['choice 1', 'choice 2'], Size=(20, 3))], + [Text('_' * 90, Size=(60, 1))], + [Text('Choose Source and Destination Folders', Size=(35,1))], + [Text('Source Folder', Size=(15, 1), AutoSizeText=False), InputText('Source'), FolderBrowse()], + [Text('Destination Folder', Size=(15, 1), AutoSizeText=False), InputText('Dest'), FolderBrowse()], + [SimpleButton('Your Button with any text you want')], + [SimpleButton('Big Text', Size=(12,1), Font=("Helvetica", 20))], + [Submit(), Cancel()]] + (button, (values)) = form.LayoutAndShow(layout) @@ -267,26 +268,26 @@ Clicking Submit caused the form call to return and the call to MsgBox is made to ![results](https://user-images.githubusercontent.com/13696193/42604952-502f64e6-8543-11e8-8045-bc10d38c5fd4.jpg) -## Built With - - -## Contributing - -A MikeTheWatchGuy production... entirely responsible for this code - -## Versioning - -1.0.9 - July 10, 2018 - Initial Release - - -## Authors - - -## License - -This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details - -## Acknowledgments - +## Built With + + +## Contributing + +A MikeTheWatchGuy production... entirely responsible for this code + +## Versioning + +1.0.9 - July 10, 2018 - Initial Release + + +## Authors + + +## License + +This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details + +## Acknowledgments + * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence From 0b28fa3a917c83d2101bee375a0aadd816948156 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 11 Jul 2018 22:32:26 -0400 Subject: [PATCH 008/209] Update readme.md --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index bb8d48a79..26d529c63 100644 --- a/readme.md +++ b/readme.md @@ -132,6 +132,7 @@ The differences tend to be the number and types of buttons. Here are the calls import PySimpleGUI as SG `SG.MsgBoxOK('This is an OK MsgBox')` + ![msgboxok](https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg) SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') From 713557e7346b6282510e0a95142d9aaad1c1d102 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 11 Jul 2018 22:35:08 -0400 Subject: [PATCH 009/209] Fix formatting --- readme.md | 74 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/readme.md b/readme.md index c7743cffc..7fe614dbe 100644 --- a/readme.md +++ b/readme.md @@ -84,45 +84,46 @@ PySimpleGUI can be broken down into 2 types of API's: SG.MsgBox('Variable number of parameters example', my_variable, second_variable, "etc") Each new item begins on a new line in the Message Box + ![variablearguments](https://user-images.githubusercontent.com/13696193/42598375-022bc51e-852a-11e8-8f77-4d664ae1a560.jpg) - + #### Optional Parameters to a Function Call - + This feature of the Python language is utilized ***heavily*** as a method of customizing forms and part of forms. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. -Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't have to be specified on each and every call. +Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't have to be specified on each and every call. - def MsgBox(*args, - ButtonColor=None, - ButtonType=MSG_BOX_OK, - AutoClose=False, - AutoCloseDuration=None, - Icon=DEFAULT_WINDOW_ICON, + def MsgBox(*args, + ButtonColor=None, + ButtonType=MSG_BOX_OK, + AutoClose=False, + AutoCloseDuration=None, + Icon=DEFAULT_WINDOW_ICON, LineWidth=MESSAGE_BOX_LINE_WIDTH, Font=None): If the caller wanted to change the button color to be black on yellow, the call would look something like this: - SG.MsgBox('This box has a custom button color', + SG.MsgBox('This box has a custom button color', ButtonColor=('black', 'yellow')) ![custombuttoncolor](https://user-images.githubusercontent.com/13696193/42599212-84f3fe2e-852c-11e8-8a60-4aad669a1fd6.jpg) -### High Level API Calls +### High Level API Calls + +The classic "input a value, print result" example. +Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. +This code prompts user to input a line of text and then displays that text in a messages box: + + import PySimpleGUI_local as SG + + rc = SG.GetTextBox('Title', 'Please input something') + SG.MsgBox('Results', 'The value returned from GetTextBox', rc) + +![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) + +![MsgBox](https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg) -The classic "input a value, print result" example. -Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. -This code prompts user to input a line of text and then displays that text in a messages box: - - import PySimpleGUI_local as SG - - rc = SG.GetTextBox('Title', 'Please input something') - SG.MsgBox('Results', 'The value returned from GetTextBox', rc) - -![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) - -![MsgBox](https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg) - #### Message Boxes In addition to MsgBox, you'll find a several API calls that are shortcuts to common messages boxes. You can achieve similar results by calling MsgBox with the correct parameters. @@ -131,6 +132,7 @@ The differences tend to be the number and types of buttons. Here are the calls import PySimpleGUI as SG `SG.MsgBoxOK('This is an OK MsgBox')` + ![msgboxok](https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg) SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') @@ -158,9 +160,9 @@ Take a moment to look at that last one. It's such a simple API call and yet the #### High Level User Input -There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. +There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. - GetTextBox - - GetFileBox + - GetFileBox - GetFolderBox `submit_clicked, value = SG.GetTextBox('Title', 'Please enter anything')` @@ -184,10 +186,10 @@ It's both not enjoyable nor helpful to immediately jump into tweaking each and e # COPY THIS DESIGN PATTERN! - with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], - [SG.InputText(), SG.FileBrowse()], - [SG.Submit(), SG.Cancel()]] + with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + [SG.InputText(), SG.FileBrowse()], + [SG.Submit(), SG.Cancel()]] (button, (source_filename, )) = form.LayoutAndShow(form_rows) This context manager contains all of the code needed to specify, show and retrieve results for this form: @@ -195,21 +197,21 @@ This context manager contains all of the code needed to specify, show and retrie It's important to use the "with" context manager. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. -You will use this design pattern or code template for all of your "normal" (blocking) types of input forms. +You will use this design pattern or code template for all of your "normal" (blocking) types of input forms. -PySimpleGUI's goal with the API is to be easy on the programmer. An attempt was made to make the program's code visually match the window on the screen. The way this is done is that a GUI is broken up into "Rows". Then each row is broke up into "Elements" or "Widgets". Each element is specified by names such as Text, Button, Checkbox, etc. +PySimpleGUI's goal with the API is to be easy on the programmer. An attempt was made to make the program's code visually match the window on the screen. The way this is done is that a GUI is broken up into "Rows". Then each row is broke up into "Elements" or "Widgets". Each element is specified by names such as Text, Button, Checkbox, etc. Some elements are shortcuts, again meant to make it easy on the programmer. Rather than writing a `Button`, with name = "Submit", etc, the caller simply writes `Submit`. Going through each line of code - with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: -This creates a new form, storing it in the variable `form`. + with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: +This creates a new form, storing it in the variable `form`. - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. - [SG.InputText(), SG.FileBrowse()], + [SG.InputText(), SG.FileBrowse()], Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. [SG.Submit(), SG.Cancel()]] From bc9857887515cf60f427100b113cb005ffa7f28c Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 12 Jul 2018 12:57:28 -0400 Subject: [PATCH 010/209] Update readme.md --- readme.md | 139 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 110 insertions(+), 29 deletions(-) diff --git a/readme.md b/readme.md index 26d529c63..65f85c176 100644 --- a/readme.md +++ b/readme.md @@ -6,8 +6,10 @@ This really is a simple GUI, but also powerfully customizable. ![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? + +With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a much more pleasant experience than opening a dos Window. -Python itself doesn't have a simple solution... nor did the *many* GUI packages I tried. Most tried to do TOO MUCH, making it impossible for users to get started quickly. Others were just plain broken, requiring multiple files or other packages that were missing. +Python itself doesn't have a simple GUI solution... nor did the *many* GUI packages I tried. Most tried to do TOO MUCH, making it impossible for users to get started quickly. Others were just plain broken, requiring multiple files or other packages that were missing. The PySimpleGUI solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. @@ -15,26 +17,29 @@ You can add a GUI to your command line with a single line of code. With 3 or 4 The customization power comes from the form/dialog box builder that enables users to experience all of the normal GUI widgets without having to write a lot of code. -Features of PySimpleGUI include: - Text - Single Line Input - Buttons including these types: - File Browse - Folder Browse - Non-closing return - Close form - Checkboxes - Radio Buttons - Icons - Multi-line Text Input - Scroll-able Output - Progress Bar - Async/Non-Blocking Windows - Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling Window - 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) - + +> Features of PySimpleGUI include: +> Text +> Single Line Input +> Buttons including these types: File Browse Folder Browse Non-closing return Close form +> Checkboxes +> Radio Buttons +> Icons +> Multi-line Text Input +> Scroll-able Output +> Progress Bar +> Async/Non-Blocking Windows +> Tabbed forms +> Persistent Windows +> Redirect Python Output/Errors to scrolling Window +> 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + + +An example of many widgets used on a single form. A little further down you'll find the FIFTEEN lines of code required to create this complex form. +![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) + + + ## Getting Started with PySimpleGUI @@ -156,11 +161,11 @@ The differences tend to be the number and types of buttons. Here are the calls ![scrolledtextbox](https://user-images.githubusercontent.com/13696193/42600800-a44f4562-8531-11e8-8c21-51dd70316879.jpg) -Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing text scrolling past on your display, you can capture that text and present it in a scrolled interface. +Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. #### High Level User Input -There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. +There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. If you need only 1 value, then perhaps one of these high level functions will work. - GetTextBox - GetFileBox - GetFolderBox @@ -179,12 +184,13 @@ There are 3 very basic user input high-level function calls. It's expected that -### Custom Form API Calls +# Custom Form API Calls + This is the FUN part of the programming of this GUI. In order to really get the most out of the API, you should be using an IDE that supports auto complete or will show you the definition of the function. This will make customizing go smoother. It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. Let's start with a basic Browse for a file and do something with it. -# COPY THIS DESIGN PATTERN! +## COPY THIS DESIGN PATTERN! with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], @@ -231,9 +237,14 @@ Don't forget all those ()'s of your values won't be coreectly assigned. If you have a SINGLE value being returned, it is written this way: - (button, (value1,)) - -Forgetting the comma will mess you up but good + (button, (value1,)) = form.LayoutAndShow(form_rows) + Another way of parsing the return values is to store the list of values into a variable that is then referenced. + + (button, (value)) = form.LayoutAndShow(form_rows) + value1 = values[0] + value2 = values[1] + ... + ## All Widgets / Elements This code utilizes as many of the elements in one form as possible. @@ -265,9 +276,75 @@ This is a somewhat complex form with quite a bit of custom sizing to make things ![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) -Clicking Submit caused the form call to return and the call to MsgBox is made to display the results. +Clicking the Submit button caused the form call to return. The call to MsgBox resulted in this dialog box. ![results](https://user-images.githubusercontent.com/13696193/42604952-502f64e6-8543-11e8-8045-bc10d38c5fd4.jpg) +One important aspect of this example is the return codes: + + (button, (values)) = form.LayoutAndShow(layout) +The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. + +You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes. These return `bool`. + + + +# Building Custom Forms +You will find it much easier to write code using PySimpleGUI is you use features that show you documentation about the API call you are making. In PyCharm 2 commands are helpful. + +> Control-Q (when cursor is on function name) brings up a box with the +> function definition +> Control-P (when cursor inside function call "()") +> shows a list of parameters and their default values + +## Synchronous Forms +The most common use of PySimpleGUI is to display and collect information from the user. The most straightforward way to do this is using a "blocking" GUI call. Execution is "blocked" while waiting for the user to close the GUI form/dialog box. +You've already seen a number of examples above that use blocking forms. Anytime you see a context manager used (see the `with` statement) it's most likely a blocking form. You can examine the show calls to be sure. If the form is a non-blocking form, it must indicate that in the call to `form.show`. + +NON-BLOCKING form call: + + form.Show(NonBlocking=True) + +### Beginning a Form +The first step is to create the form object using the desired form customization. + + with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: +Let's go through the options available when creating a form. + + def __init__(self, title, + DefaultElementSize=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), + AutoSizeText=DEFAULT_AUTOSIZE_TEXT, + Scale=(None, None), + Size=(None, None), + Location=(None, None), + ButtonColor=None,Font=None, + ProgressBarColor=(None,None), + IsTabbedForm=False, + BorderDepth=None, + AutoClose=False, + AutoCloseDuration=DEFAULT_AUTOCLOSE_TIME, + Icon=DEFAULT_WINDOW_ICON): + + +#### Sizes +Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. + +Sizes can be set at the element level, or in this case, the size variables apply to all elements in the form. Setting `Size=(20,1)` in the form creation call will set all elements in the form to that size. +In addition to `size` there is a `scale` option. Scale will take the Element's size and scale it up or down depending on the scale value. `scale=(1,1)` doesn't change the Element's size. `scale=(2,1)` will set the Element's size to be twice as wide as the size setting. + +#### FlexForm - form-level variables overview +A summary of the variables that can be changed when a FlexForm is created + +> DefaultElementSize - set default size for all elements in the form +> AutoSizeText - true/false autosizing turned on / off +> Scale - set scale value for all elements +> ButtonColor - default button color (foreground, background) +> Font - font name and size for all text items +> ProgressBarColor - progress bar colors +> IsTabbedForm - true/false indicates form is a tabbed or normal form +> BorderDepth - style setting for buttons, input fields +> AutoClose - true/false indicates if form will automatically close +> AutoCloseDuration - how long in seconds before closing form +> Icon - filename for icon that's displayed on the window on taskbar ## Built With @@ -292,3 +369,7 @@ This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence + + + + From 2be7824fcdc98923407ec1f4b05d3c750b61a961 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 12 Jul 2018 12:58:48 -0400 Subject: [PATCH 011/209] Update readme.md --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index 65f85c176..b12d8f844 100644 --- a/readme.md +++ b/readme.md @@ -36,6 +36,7 @@ The customization power comes from the form/dialog box builder that enables user An example of many widgets used on a single form. A little further down you'll find the FIFTEEN lines of code required to create this complex form. + ![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) From 2449e0527e9c583ac350c589dea28d46e3de9818 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 12 Jul 2018 13:27:34 -0400 Subject: [PATCH 012/209] Update readme.md --- readme.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/readme.md b/readme.md index b12d8f844..b08b0a0b7 100644 --- a/readme.md +++ b/readme.md @@ -369,8 +369,3 @@ This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md ## Acknowledgments * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence - - - - - From 4f0c4e171fb759364b37fdc338f3b95e93dbc71d Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 13 Jul 2018 09:18:47 -0400 Subject: [PATCH 013/209] Update readme.md --- readme.md | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 98 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index b08b0a0b7..8e0947066 100644 --- a/readme.md +++ b/readme.md @@ -7,7 +7,7 @@ This really is a simple GUI, but also powerfully customizable. I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? -With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a much more pleasant experience than opening a dos Window. +With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. Python itself doesn't have a simple GUI solution... nor did the *many* GUI packages I tried. Most tried to do TOO MUCH, making it impossible for users to get started quickly. Others were just plain broken, requiring multiple files or other packages that were missing. @@ -329,9 +329,13 @@ Let's go through the options available when creating a form. #### Sizes Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. +The default Element size for PySimpleGUI is `(45,1)`. + Sizes can be set at the element level, or in this case, the size variables apply to all elements in the form. Setting `Size=(20,1)` in the form creation call will set all elements in the form to that size. + In addition to `size` there is a `scale` option. Scale will take the Element's size and scale it up or down depending on the scale value. `scale=(1,1)` doesn't change the Element's size. `scale=(2,1)` will set the Element's size to be twice as wide as the size setting. + #### FlexForm - form-level variables overview A summary of the variables that can be changed when a FlexForm is created @@ -347,9 +351,96 @@ A summary of the variables that can be changed when a FlexForm is created > AutoCloseDuration - how long in seconds before closing form > Icon - filename for icon that's displayed on the window on taskbar -## Built With - - + +## Elements +"Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. + +> Text +> Single Line Input +> Buttons including these types: File Browse Folder Browse Non-closing return Close form +> Checkboxes +> Radio Buttons +> Multi-line Text Input +> Scroll-able Output +> Progress Bar +> Async/Non-Blocking Windows +> Tabbed forms +> Persistent Windows +> Redirect Python Output/Errors to scrolling Window +> 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + + +### Output Elements +Building a form is simply making lists of Elements. Each list is a row in the overall GUI dialog box. The definition looks something like this: + + layout = [ [row 1 element, row 1 element], + [row 2 element, row 2 element, row 2 element] ] +The code is a crude representation of the GUI, laid out in text. +#### Text Element + + layout = [[SG.Text('This is what a Text Element looks like')]] + + + ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) + + +The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. + + Text(Text, + Scale=(None, None), + Size=(None, None), + AutoSizeText=None, + Font=None, + TextColor=None) + +Some commonly used elements have 'shorthand' versions of the functions to make the code more compact. The functions `T` and `Txt` are the same as calling `Text`. + +**Fonts** in PySimpleGUI are always in this format: + + (font_name, point_size) + +The default font setting is + + ("Helvetica", 10) + +**Colos** in PySimpleGUI are always in this format: + + (foreground, background) + +The values foreground and background can be the color names or the hex value formatted as a string: + + "#RRGGBB" + +#### Multiline Text Element + + layout = [[SG.Multiline('This is what a Multi-line Text Element looks like', Size=(45,5))]] +![multiline text](https://user-images.githubusercontent.com/13696193/42670464-0824c754-8629-11e8-9741-6ed08f924618.jpg) +This Element doubles as both an input and output Element. The `DefaultText` optional parameter is used to indicate what to output to the window. + + Multiline(DefaultText='', + EnterSubmits = False, + Scale=(None, None), + Size=(None, None), + AutoSizeText=None) + +> DefaultText - Text to display in the text box +>EnterSubmits - Bool. If True, pressing Enter key submits form +>Scale - Element's scale +>Size - Element's size +>AutoSizeText - Bool. Change width to match size of text + +### Input Elements + These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `Size` is specified in the Element). +#### Text Input Element + + layout = [[SG.InputText('Default text')]] +![inputtext](https://user-images.githubusercontent.com/13696193/42693515-610a716c-867d-11e8-9a00-7e7fcf771230.jpg) + + def InputText(DefaultText = '', + Scale=(None, None), + Size=(None, None), + AutoSizeText=None) + ## Contributing A MikeTheWatchGuy production... entirely responsible for this code @@ -369,3 +460,6 @@ This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md ## Acknowledgments * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence + + + From fe2a5b1dba000ca81d46f310b9bf503a22160f89 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 13 Jul 2018 10:24:35 -0400 Subject: [PATCH 014/209] More Readme --- readme.md | 436 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 321 insertions(+), 115 deletions(-) diff --git a/readme.md b/readme.md index 5c20f75cd..cfb44a7b3 100644 --- a/readme.md +++ b/readme.md @@ -6,58 +6,65 @@ This really is a simple GUI, but also powerfully customizable. ![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? - -Python itself doesn't have a simple solution... nor did the *many* GUI packages I tried. Most tried to do TOO MUCH, making it impossible for users to get started quickly. Others were just plain broken, requiring multiple files or other packages that were missing. - -The PySimpleGUI solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. - -You can add a GUI to your command line with a single line of code. With 3 or 4 lines of code you can add a fully customized GUI. - -The customization power comes from the form/dialog box builder that enables users to experience all of the normal GUI widgets without having to write a lot of code. - -Features of PySimpleGUI include: - Text - Single Line Input - Buttons including these types: - File Browse - Folder Browse - Non-closing return - Close form - Checkboxes - Radio Buttons - Icons - Multi-line Text Input - Scroll-able Output - Progress Bar - Async/Non-Blocking Windows - Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling Window - 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) - - -## Getting Started with PySimpleGUI - -### Installing - - pip install PySimpleGUI - or -Simply download the file - PySimpleGUI.py and import it into your code - - -### Prerequisites - -Python 3 -tkinter - -Should run on all Python platforms that have tkinter running on them. Has been thoroughly tested on Windows. While not tested elsewhere, should work on Linux, Mac, Pi, etc. - + +With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. + +Python itself doesn't have a simple GUI solution... nor did the *many* GUI packages I tried. Most tried to do TOO MUCH, making it impossible for users to get started quickly. Others were just plain broken, requiring multiple files or other packages that were missing. + +The PySimpleGUI solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. + +You can add a GUI to your command line with a single line of code. With 3 or 4 lines of code you can add a fully customized GUI. And for you Machine Learning folks out there, a **single line** progress meter call that you can drop into any loop. + +![progress meter 2](https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg) + + + The customization is via the form/dialog box builder that enables users to experience all of the normal GUI widgets without having to write a lot of code. + + +> Features of PySimpleGUI include: +> Text +> Single Line Input +> Buttons including these types: File Browse Folder Browse Non-closing return Close form +> Checkboxes +> Radio Buttons +> Icons +> Multi-line Text Input +> Scroll-able Output +> Progress Bar +> Async/Non-Blocking Windows +> Tabbed forms +> Persistent Windows +> Redirect Python Output/Errors to scrolling Window +> 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + + +An example of many widgets used on a single form. A little further down you'll find the FIFTEEN lines of code required to create this complex form. + +![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) + + +## Getting Started with PySimpleGUI + +### Installing + + pip install PySimpleGUI + or +Simply download the file - PySimpleGUI.py and import it into your code + + +### Prerequisites + +Python 3 +tkinter + +Should run on all Python platforms that have tkinter running on them. Has been thoroughly tested on Windows. While not tested elsewhere, should work on Linux, Mac, Pi, etc. + ### Using To us in your code, simply import.... - `import PySimpleGUI as SG` + `import PySimpleGUI as SG` -Then use either "high level" API calls or build your own forms. +Then use either "high level" API calls or build your own forms. SG.MsgBox('This is my first message box') ![simple msgbox](https://user-images.githubusercontent.com/13696193/42597824-1749b160-8528-11e8-9114-374bf9731b30.jpg) @@ -65,22 +72,22 @@ Then use either "high level" API calls or build your own forms. Yes, it's just that easy to have a window appear on the screen using Python. ## APIs - -PySimpleGUI can be broken down into 2 types of API's: - * High Level single call functions - * Custom form functions - + +PySimpleGUI can be broken down into 2 types of API's: + * High Level single call functions + * Custom form functions + ### Python Language Features There are a couple of Python language features that PySimpleGUI utilizes heavily that should be understood first... - * Variable number of arguments to a function call + * Variable number of arguments to a function call * Optional parameters to a function call - + #### Variable Number of Arguments The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. - + SG.MsgBox('Variable number of parameters example', my_variable, second_variable, "etc") Each new item begins on a new line in the Message Box @@ -132,11 +139,7 @@ The differences tend to be the number and types of buttons. Here are the calls import PySimpleGUI as SG `SG.MsgBoxOK('This is an OK MsgBox')` -<<<<<<< HEAD -======= - ->>>>>>> 0b28fa3a917c83d2101bee375a0aadd816948156 ![msgboxok](https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg) SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') @@ -160,11 +163,11 @@ The differences tend to be the number and types of buttons. Here are the calls ![scrolledtextbox](https://user-images.githubusercontent.com/13696193/42600800-a44f4562-8531-11e8-8c21-51dd70316879.jpg) -Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing text scrolling past on your display, you can capture that text and present it in a scrolled interface. +Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. #### High Level User Input -There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. +There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. If you need only 1 value, then perhaps one of these high level functions will work. - GetTextBox - GetFileBox - GetFolderBox @@ -181,14 +184,28 @@ There are 3 very basic user input high-level function calls. It's expected that ![getfolderbox](https://user-images.githubusercontent.com/13696193/42600397-1ea7cef8-8530-11e8-8d43-e1000c0933cd.jpg) +#### Progress Meter! +We all have loops in our code. 'Isn't it joyful waiting, watching a counter scrolling past in a text window? How about one line of code to get a progress meter, that contains statistics about your code? +![progress meter 3](https://user-images.githubusercontent.com/13696193/42696332-dca3ca6e-8685-11e8-846b-6bee8362ee5f.jpg) + + EasyProgressMeter(Title, + CurrentValue, + MaxValue, + *args, + Orientation=None, + BarColor=DEFAULT_PROGRESS_BAR_COLOR, + ButtonColor=None, + Size=DEFAULT_PROGRESS_BAR_SIZE, + Scale=(None, None), + BorderWidth=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): +# Custom Form API Calls -### Custom Form API Calls This is the FUN part of the programming of this GUI. In order to really get the most out of the API, you should be using an IDE that supports auto complete or will show you the definition of the function. This will make customizing go smoother. It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. Let's start with a basic Browse for a file and do something with it. -# COPY THIS DESIGN PATTERN! +## COPY THIS DESIGN PATTERN! with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], @@ -201,7 +218,9 @@ This context manager contains all of the code needed to specify, show and retrie It's important to use the "with" context manager. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. -You will use this design pattern or code template for all of your "normal" (blocking) types of input forms. +You will use this design pattern or code template for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. + +> Copy, Paste, Run. PySimpleGUI's goal with the API is to be easy on the programmer. An attempt was made to make the program's code visually match the window on the screen. The way this is done is that a GUI is broken up into "Rows". Then each row is broke up into "Elements" or "Widgets". Each element is specified by names such as Text, Button, Checkbox, etc. @@ -220,44 +239,49 @@ Now we're on the second row of the form. On this row there are 2 elements. The [SG.Submit(), SG.Cancel()]] -The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its valueso the caller. +The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its value to the caller. (button, (source_filename, )) = form.LayoutAndShow(form_rows) This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field. ## Return values - Return information from FlexForm, SG's primary form builder interface, is in this format: - - (button, (value1, value2, ...)) - -Don't forget all those ()'s of your values won't be coreectly assigned. - -If you have a SINGLE value being returned, it is written this way: - - (button, (value1,)) - -Forgetting the comma will mess you up but good + Return information from FlexForm, SG's primary form builder interface, is in this format: + + (button, (value1, value2, ...)) + +Don't forget all those ()'s of your values won't be coreectly assigned. + +If you have a SINGLE value being returned, it is written this way: + + (button, (value1,)) = form.LayoutAndShow(form_rows) + Another way of parsing the return values is to store the list of values into a variable that is then referenced. + + (button, (value)) = form.LayoutAndShow(form_rows) + value1 = values[0] + value2 = values[1] + ... + ## All Widgets / Elements This code utilizes as many of the elements in one form as possible. - with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: - layout = [[Text('Here they all are!', Size=(30,1), Font=("Helvetica", 25), TextColor='red')], - [Text('Here is some text with font sizing', Font=("Helvetica", 15))], - [InputText()], - [Checkbox('My first checkbox!'), Checkbox('My second checkbox!', Default=True)], - [Radio('My first Radio!', "RADIO1", Default=True), Radio('My second checkbox!', "RADIO1")], - [Multiline(DefaultText='This is the DEFAULT text should you decide not to type anything', Scale=(2, 10))], - [InputCombo(['choice 1', 'choice 2'], Size=(20, 3))], - [Text('_' * 90, Size=(60, 1))], - [Text('Choose Source and Destination Folders', Size=(35,1))], - [Text('Source Folder', Size=(15, 1), AutoSizeText=False), InputText('Source'), FolderBrowse()], - [Text('Destination Folder', Size=(15, 1), AutoSizeText=False), InputText('Dest'), FolderBrowse()], - [SimpleButton('Your Button with any text you want')], - [SimpleButton('Big Text', Size=(12,1), Font=("Helvetica", 20))], - [Submit(), Cancel()]] - + with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: + layout = [[Text('Here they all are!', Size=(30,1), Font=("Helvetica", 25), TextColor='red')], + [Text('Here is some text with font sizing', Font=("Helvetica", 15))], + [InputText()], + [Checkbox('My first checkbox!'), Checkbox('My second checkbox!', Default=True)], + [Radio('My first Radio!', "RADIO1", Default=True), Radio('My second checkbox!', "RADIO1")], + [Multiline(DefaultText='This is the DEFAULT text should you decide not to type anything', Scale=(2, 10))], + [InputCombo(['choice 1', 'choice 2'], Size=(20, 3))], + [Text('_' * 90, Size=(60, 1))], + [Text('Choose Source and Destination Folders', Size=(35,1))], + [Text('Source Folder', Size=(15, 1), AutoSizeText=False), InputText('Source'), FolderBrowse()], + [Text('Destination Folder', Size=(15, 1), AutoSizeText=False), InputText('Dest'), FolderBrowse()], + [SimpleButton('Your Button with any text you want')], + [SimpleButton('Big Text', Size=(12,1), Font=("Helvetica", 20))], + [Submit(), Cancel()]] + (button, (values)) = form.LayoutAndShow(layout) @@ -269,30 +293,212 @@ This is a somewhat complex form with quite a bit of custom sizing to make things ![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) -Clicking Submit caused the form call to return and the call to MsgBox is made to display the results. +Clicking the Submit button caused the form call to return. The call to MsgBox resulted in this dialog box. ![results](https://user-images.githubusercontent.com/13696193/42604952-502f64e6-8543-11e8-8045-bc10d38c5fd4.jpg) +One important aspect of this example is the return codes: + + (button, (values)) = form.LayoutAndShow(layout) +The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. + +You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. + + + +# Building Custom Forms +You will find it much easier to write code using PySimpleGUI is you use features that show you documentation about the API call you are making. In PyCharm 2 commands are helpful. + +> Control-Q (when cursor is on function name) brings up a box with the +> function definition +> Control-P (when cursor inside function call "()") +> shows a list of parameters and their default values + +## Synchronous Forms +The most common use of PySimpleGUI is to display and collect information from the user. The most straightforward way to do this is using a "blocking" GUI call. Execution is "blocked" while waiting for the user to close the GUI form/dialog box. +You've already seen a number of examples above that use blocking forms. Anytime you see a context manager used (see the `with` statement) it's most likely a blocking form. You can examine the show calls to be sure. If the form is a non-blocking form, it must indicate that in the call to `form.show`. + +NON-BLOCKING form call: + + form.Show(NonBlocking=True) + +### Beginning a Form +The first step is to create the form object using the desired form customization. + + with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: +Let's go through the options available when creating a form. + + def __init__(self, title, + DefaultElementSize=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), + AutoSizeText=DEFAULT_AUTOSIZE_TEXT, + Scale=(None, None), + Size=(None, None), + Location=(None, None), + ButtonColor=None,Font=None, + ProgressBarColor=(None,None), + IsTabbedForm=False, + BorderDepth=None, + AutoClose=False, + AutoCloseDuration=DEFAULT_AUTOCLOSE_TIME, + Icon=DEFAULT_WINDOW_ICON): + + +#### Sizes +Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. + +The default Element size for PySimpleGUI is `(45,1)`. + +Sizes can be set at the element level, or in this case, the size variables apply to all elements in the form. Setting `Size=(20,1)` in the form creation call will set all elements in the form to that size. + +In addition to `size` there is a `scale` option. Scale will take the Element's size and scale it up or down depending on the scale value. `scale=(1,1)` doesn't change the Element's size. `scale=(2,1)` will set the Element's size to be twice as wide as the size setting. + + +#### FlexForm - form-level variables overview +A summary of the variables that can be changed when a FlexForm is created + +> DefaultElementSize - set default size for all elements in the form +> AutoSizeText - true/false autosizing turned on / off +> Scale - set scale value for all elements +> ButtonColor - default button color (foreground, background) +> Font - font name and size for all text items +> ProgressBarColor - progress bar colors +> IsTabbedForm - true/false indicates form is a tabbed or normal form +> BorderDepth - style setting for buttons, input fields +> AutoClose - true/false indicates if form will automatically close +> AutoCloseDuration - how long in seconds before closing form +> Icon - filename for icon that's displayed on the window on taskbar + + +## Elements +"Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. + +> Text +> Single Line Input +> Buttons including these types: File Browse Folder Browse Non-closing return Close form +> Checkboxes +> Radio Buttons +> Multi-line Text Input +> Scroll-able Output +> Progress Bar +> Async/Non-Blocking Windows +> Tabbed forms +> Persistent Windows +> Redirect Python Output/Errors to scrolling Window +> 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + + +### Output Elements +Building a form is simply making lists of Elements. Each list is a row in the overall GUI dialog box. The definition looks something like this: + + layout = [ [row 1 element, row 1 element], + [row 2 element, row 2 element, row 2 element] ] +The code is a crude representation of the GUI, laid out in text. +#### Text Element + + layout = [[SG.Text('This is what a Text Element looks like')]] + + + ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) + + +The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. + + Text(Text, + Scale=(None, None), + Size=(None, None), + AutoSizeText=None, + Font=None, + TextColor=None) + +Some commonly used elements have 'shorthand' versions of the functions to make the code more compact. The functions `T` and `Txt` are the same as calling `Text`. + +**Fonts** in PySimpleGUI are always in this format: + + (font_name, point_size) + +The default font setting is + + ("Helvetica", 10) + +**Colos** in PySimpleGUI are always in this format: + + (foreground, background) + +The values foreground and background can be the color names or the hex value formatted as a string: + + "#RRGGBB" + +#### Multiline Text Element + + layout = [[SG.Multiline('This is what a Multi-line Text Element looks like', Size=(45,5))]] +![multiline text](https://user-images.githubusercontent.com/13696193/42670464-0824c754-8629-11e8-9741-6ed08f924618.jpg) +This Element doubles as both an input and output Element. The `DefaultText` optional parameter is used to indicate what to output to the window. + + Multiline(DefaultText='', + EnterSubmits = False, + Scale=(None, None), + Size=(None, None), + AutoSizeText=None) + +> DefaultText - Text to display in the text box +>EnterSubmits - Bool. If True, pressing Enter key submits form +>Scale - Element's scale +>Size - Element's size +>AutoSizeText - Bool. Change width to match size of text + +### Input Elements + These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `Size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. + +#### Text Input Element + + layout = [[SG.InputText('Default text')]] +![inputtext](https://user-images.githubusercontent.com/13696193/42693515-610a716c-867d-11e8-9a00-7e7fcf771230.jpg) + + def InputText(DefaultText = '', + Scale=(None, None), + Size=(None, None), + AutoSizeText=None) +Shorthand functions that are equivalent to `InputText` are `Input` and `In` + +#### Combo Element +Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. + + layout = [[SG.InputCombo(['choice 1', 'choice 2'])]] + +![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) + + InputCombo(Values, + Scale=(None, None), + Size=(None, None), + AutoSizeText=None) + + +## Contributing + +A MikeTheWatchGuy production... entirely responsible for this code + +## Versioning + +1.0.9 - July 10, 2018 - Initial Release + + ## Code Condition +> Make it run +> Make it right +> Make it fast + +It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor on hiding implementation details, naming conventions, PEP 8. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. + +## Authors + + +## License + +This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details + +## Acknowledgments -## Built With - - -## Contributing - -A MikeTheWatchGuy production... entirely responsible for this code - -## Versioning - -1.0.9 - July 10, 2018 - Initial Release - - -## Authors - - -## License - -This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details - -## Acknowledgments - * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence + + + + From 46e56434a39bcd98d4683aa3da3a3126999e6f13 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 13 Jul 2018 10:45:55 -0400 Subject: [PATCH 015/209] Update readme.md --- readme.md | 367 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 227 insertions(+), 140 deletions(-) diff --git a/readme.md b/readme.md index 8e0947066..d8cf3cebf 100644 --- a/readme.md +++ b/readme.md @@ -8,20 +8,28 @@ This really is a simple GUI, but also powerfully customizable. I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. - + Python itself doesn't have a simple GUI solution... nor did the *many* GUI packages I tried. Most tried to do TOO MUCH, making it impossible for users to get started quickly. Others were just plain broken, requiring multiple files or other packages that were missing. - -The PySimpleGUI solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. - -You can add a GUI to your command line with a single line of code. With 3 or 4 lines of code you can add a fully customized GUI. - -The customization power comes from the form/dialog box builder that enables users to experience all of the normal GUI widgets without having to write a lot of code. - + +The PySimpleGUI solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. + +You can add a GUI to your command line with a single line of code. With 3 or 4 lines of code you can add a fully customized GUI. And for you Machine Learning folks out there, a **single line** progress meter call that you can drop into any loop. + +![progress meter 2](https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg) + + + The customization is via the form/dialog box builder that enables users to experience all of the normal GUI widgets without having to write a lot of code. + + > Features of PySimpleGUI include: > Text > Single Line Input -> Buttons including these types: File Browse Folder Browse Non-closing return Close form +> Buttons including these types: +> File Browse +> Folder Browse +> Non-closing return +> Close form > Checkboxes > Radio Buttons > Icons @@ -35,35 +43,50 @@ The customization power comes from the form/dialog box builder that enables user > 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) +> Features of PySimpleGUI include: +> Text +> Single Line Input +> Buttons including these types: File Browse Folder Browse Non-closing return Close form +> Checkboxes +> Radio Buttons +> Icons +> Multi-line Text Input +> Scroll-able Output +> Progress Bar +> Async/Non-Blocking Windows +> Tabbed forms +> Persistent Windows +> Redirect Python Output/Errors to scrolling Window +> 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + + An example of many widgets used on a single form. A little further down you'll find the FIFTEEN lines of code required to create this complex form. ![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) +## Getting Started with PySimpleGUI + +### Installing + + pip install PySimpleGUI + or +Simply download the file - PySimpleGUI.py and import it into your code + + +### Prerequisites + +Python 3 +tkinter + +Should run on all Python platforms that have tkinter running on them. Has been thoroughly tested on Windows. While not tested elsewhere, should work on Linux, Mac, Pi, etc. - -## Getting Started with PySimpleGUI - -### Installing - - pip install PySimpleGUI - or -Simply download the file - PySimpleGUI.py and import it into your code - - -### Prerequisites - -Python 3 -tkinter - -Should run on all Python platforms that have tkinter running on them. Has been thoroughly tested on Windows. While not tested elsewhere, should work on Linux, Mac, Pi, etc. - ### Using To us in your code, simply import.... - `import PySimpleGUI as SG` + `import PySimpleGUI as SG` -Then use either "high level" API calls or build your own forms. +Then use either "high level" API calls or build your own forms. SG.MsgBox('This is my first message box') ![simple msgbox](https://user-images.githubusercontent.com/13696193/42597824-1749b160-8528-11e8-9114-374bf9731b30.jpg) @@ -71,65 +94,79 @@ Then use either "high level" API calls or build your own forms. Yes, it's just that easy to have a window appear on the screen using Python. ## APIs - -PySimpleGUI can be broken down into 2 types of API's: - * High Level single call functions - * Custom form functions - + +PySimpleGUI can be broken down into 2 types of API's: + * High Level single call functions + * Custom form functions + ### Python Language Features There are a couple of Python language features that PySimpleGUI utilizes heavily that should be understood first... - * Variable number of arguments to a function call + * Variable number of arguments to a function call * Optional parameters to a function call - + #### Variable Number of Arguments The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. - + SG.MsgBox('Variable number of parameters example', my_variable, second_variable, "etc") Each new item begins on a new line in the Message Box ![variablearguments](https://user-images.githubusercontent.com/13696193/42598375-022bc51e-852a-11e8-8f77-4d664ae1a560.jpg) - + #### Optional Parameters to a Function Call - + This feature of the Python language is utilized ***heavily*** as a method of customizing forms and part of forms. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. -Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't have to be specified on each and every call. +Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't have to be specified on each and every call. - def MsgBox(*args, - ButtonColor=None, - ButtonType=MSG_BOX_OK, - AutoClose=False, - AutoCloseDuration=None, - Icon=DEFAULT_WINDOW_ICON, - LineWidth=MESSAGE_BOX_LINE_WIDTH, - Font=None): + + Features of PySimpleGUI include: + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Checkboxes + Radio Buttons + Icons + Multi-line Text Input + Scroll-able Output + Progress Bar + Async/Non-Blocking Windows + Tabbed forms + Persistent Windows + Redirect Python Output/Errors to scrolling Window + 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + + If the caller wanted to change the button color to be black on yellow, the call would look something like this: - SG.MsgBox('This box has a custom button color', + SG.MsgBox('This box has a custom button color', ButtonColor=('black', 'yellow')) ![custombuttoncolor](https://user-images.githubusercontent.com/13696193/42599212-84f3fe2e-852c-11e8-8a60-4aad669a1fd6.jpg) -### High Level API Calls +### High Level API Calls + +The classic "input a value, print result" example. +Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. +This code prompts user to input a line of text and then displays that text in a messages box: + + import PySimpleGUI_local as SG + + rc = SG.GetTextBox('Title', 'Please input something') + SG.MsgBox('Results', 'The value returned from GetTextBox', rc) + +![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) + +![MsgBox](https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg) -The classic "input a value, print result" example. -Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. -This code prompts user to input a line of text and then displays that text in a messages box: - - import PySimpleGUI_local as SG - - rc = SG.GetTextBox('Title', 'Please input something') - SG.MsgBox('Results', 'The value returned from GetTextBox', rc) - -![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) - -![MsgBox](https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg) - #### Message Boxes In addition to MsgBox, you'll find a several API calls that are shortcuts to common messages boxes. You can achieve similar results by calling MsgBox with the correct parameters. @@ -138,7 +175,7 @@ The differences tend to be the number and types of buttons. Here are the calls import PySimpleGUI as SG `SG.MsgBoxOK('This is an OK MsgBox')` - + ![msgboxok](https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg) SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') @@ -162,13 +199,13 @@ The differences tend to be the number and types of buttons. Here are the calls ![scrolledtextbox](https://user-images.githubusercontent.com/13696193/42600800-a44f4562-8531-11e8-8c21-51dd70316879.jpg) -Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. +Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. #### High Level User Input There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. If you need only 1 value, then perhaps one of these high level functions will work. - GetTextBox - - GetFileBox + - GetFileBox - GetFolderBox `submit_clicked, value = SG.GetTextBox('Title', 'Please enter anything')` @@ -183,7 +220,30 @@ There are 3 very basic user input high-level function calls. It's expected that ![getfolderbox](https://user-images.githubusercontent.com/13696193/42600397-1ea7cef8-8530-11e8-8d43-e1000c0933cd.jpg) +#### Progress Meter! +We all have loops in our code. 'Isn't it joyful waiting, watching a counter scrolling past in a text window? How about one line of code to get a progress meter, that contains statistics about your code? +![progress meter 3](https://user-images.githubusercontent.com/13696193/42696332-dca3ca6e-8685-11e8-846b-6bee8362ee5f.jpg) + + EasyProgressMeter(Title, + CurrentValue, + MaxValue, + *args, + Orientation=None, + BarColor=DEFAULT_PROGRESS_BAR_COLOR, + ButtonColor=None, + Size=DEFAULT_PROGRESS_BAR_SIZE, + Scale=(None, None), + BorderWidth=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): +Here's the one-line Progress Meter in action! + + for i in range(1,10000): + SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') + +That line of code resulted in this window popping up and updating. +![progress meter 5](https://user-images.githubusercontent.com/13696193/42696912-a5c958b8-8687-11e8-9a7d-a390a465407a.jpg) + +A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. # Custom Form API Calls @@ -193,10 +253,10 @@ It's both not enjoyable nor helpful to immediately jump into tweaking each and e ## COPY THIS DESIGN PATTERN! - with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], - [SG.InputText(), SG.FileBrowse()], - [SG.Submit(), SG.Cancel()]] + with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + [SG.InputText(), SG.FileBrowse()], + [SG.Submit(), SG.Cancel()]] (button, (source_filename, )) = form.LayoutAndShow(form_rows) This context manager contains all of the code needed to specify, show and retrieve results for this form: @@ -204,68 +264,70 @@ This context manager contains all of the code needed to specify, show and retrie It's important to use the "with" context manager. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. -You will use this design pattern or code template for all of your "normal" (blocking) types of input forms. +You will use this design pattern or code template for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. + +> Copy, Paste, Run. -PySimpleGUI's goal with the API is to be easy on the programmer. An attempt was made to make the program's code visually match the window on the screen. The way this is done is that a GUI is broken up into "Rows". Then each row is broke up into "Elements" or "Widgets". Each element is specified by names such as Text, Button, Checkbox, etc. +PySimpleGUI's goal with the API is to be easy on the programmer. An attempt was made to make the program's code visually match the window on the screen. The way this is done is that a GUI is broken up into "Rows". Then each row is broke up into "Elements" or "Widgets". Each element is specified by names such as Text, Button, Checkbox, etc. Some elements are shortcuts, again meant to make it easy on the programmer. Rather than writing a `Button`, with name = "Submit", etc, the caller simply writes `Submit`. Going through each line of code - with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: -This creates a new form, storing it in the variable `form`. + with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: +This creates a new form, storing it in the variable `form`. - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. - [SG.InputText(), SG.FileBrowse()], + [SG.InputText(), SG.FileBrowse()], Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. [SG.Submit(), SG.Cancel()]] -The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its valueso the caller. +The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its value to the caller. (button, (source_filename, )) = form.LayoutAndShow(form_rows) This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field. ## Return values - Return information from FlexForm, SG's primary form builder interface, is in this format: - - (button, (value1, value2, ...)) - -Don't forget all those ()'s of your values won't be coreectly assigned. - -If you have a SINGLE value being returned, it is written this way: - + Return information from FlexForm, SG's primary form builder interface, is in this format: + + (button, (value1, value2, ...)) + +Don't forget all those ()'s of your values won't be coreectly assigned. + +If you have a SINGLE value being returned, it is written this way: + (button, (value1,)) = form.LayoutAndShow(form_rows) Another way of parsing the return values is to store the list of values into a variable that is then referenced. - (button, (value)) = form.LayoutAndShow(form_rows) + (button, (value)) = form.LayoutAndShow(form_rows) value1 = values[0] value2 = values[1] ... - + ## All Widgets / Elements This code utilizes as many of the elements in one form as possible. - with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: - layout = [[Text('Here they all are!', Size=(30,1), Font=("Helvetica", 25), TextColor='red')], - [Text('Here is some text with font sizing', Font=("Helvetica", 15))], - [InputText()], - [Checkbox('My first checkbox!'), Checkbox('My second checkbox!', Default=True)], - [Radio('My first Radio!', "RADIO1", Default=True), Radio('My second checkbox!', "RADIO1")], - [Multiline(DefaultText='This is the DEFAULT text should you decide not to type anything', Scale=(2, 10))], - [InputCombo(['choice 1', 'choice 2'], Size=(20, 3))], - [Text('_' * 90, Size=(60, 1))], - [Text('Choose Source and Destination Folders', Size=(35,1))], - [Text('Source Folder', Size=(15, 1), AutoSizeText=False), InputText('Source'), FolderBrowse()], - [Text('Destination Folder', Size=(15, 1), AutoSizeText=False), InputText('Dest'), FolderBrowse()], - [SimpleButton('Your Button with any text you want')], - [SimpleButton('Big Text', Size=(12,1), Font=("Helvetica", 20))], - [Submit(), Cancel()]] - + with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: + layout = [[Text('Here they all are!', Size=(30,1), Font=("Helvetica", 25), TextColor='red')], + [Text('Here is some text with font sizing', Font=("Helvetica", 15))], + [InputText()], + [Checkbox('My first checkbox!'), Checkbox('My second checkbox!', Default=True)], + [Radio('My first Radio!', "RADIO1", Default=True), Radio('My second checkbox!', "RADIO1")], + [Multiline(DefaultText='This is the DEFAULT text should you decide not to type anything', Scale=(2, 10))], + [InputCombo(['choice 1', 'choice 2'], Size=(20, 3))], + [Text('_' * 90, Size=(60, 1))], + [Text('Choose Source and Destination Folders', Size=(35,1))], + [Text('Source Folder', Size=(15, 1), AutoSizeText=False), InputText('Source'), FolderBrowse()], + [Text('Destination Folder', Size=(15, 1), AutoSizeText=False), InputText('Dest'), FolderBrowse()], + [SimpleButton('Your Button with any text you want')], + [SimpleButton('Big Text', Size=(12,1), Font=("Helvetica", 20))], + [Submit(), Cancel()]] + (button, (values)) = form.LayoutAndShow(layout) @@ -285,7 +347,7 @@ One important aspect of this example is the return codes: (button, (values)) = form.LayoutAndShow(layout) The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. -You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes. These return `bool`. +You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. @@ -293,7 +355,7 @@ You can see in the MsgBox that the values returned are a list. Each input field You will find it much easier to write code using PySimpleGUI is you use features that show you documentation about the API call you are making. In PyCharm 2 commands are helpful. > Control-Q (when cursor is on function name) brings up a box with the -> function definition +> function definition > Control-P (when cursor inside function call "()") > shows a list of parameters and their default values @@ -308,10 +370,10 @@ NON-BLOCKING form call: ### Beginning a Form The first step is to create the form object using the desired form customization. - with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: + with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: Let's go through the options available when creating a form. - def __init__(self, title, + def __init__(self, title, DefaultElementSize=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), AutoSizeText=DEFAULT_AUTOSIZE_TEXT, Scale=(None, None), @@ -324,7 +386,7 @@ Let's go through the options available when creating a form. AutoClose=False, AutoCloseDuration=DEFAULT_AUTOCLOSE_TIME, Icon=DEFAULT_WINDOW_ICON): - + #### Sizes Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. @@ -355,18 +417,18 @@ A summary of the variables that can be changed when a FlexForm is created ## Elements "Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. -> Text -> Single Line Input -> Buttons including these types: File Browse Folder Browse Non-closing return Close form -> Checkboxes -> Radio Buttons -> Multi-line Text Input -> Scroll-able Output -> Progress Bar -> Async/Non-Blocking Windows +> Text +> Single Line Input +> Buttons including these types: File Browse Folder Browse Non-closing return Close form +> Checkboxes +> Radio Buttons +> Multi-line Text Input +> Scroll-able Output +> Progress Bar +> Async/Non-Blocking Windows > Tabbed forms -> Persistent Windows -> Redirect Python Output/Errors to scrolling Window +> Persistent Windows +> Redirect Python Output/Errors to scrolling Window > 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) @@ -378,15 +440,15 @@ Building a form is simply making lists of Elements. Each list is a row in the o The code is a crude representation of the GUI, laid out in text. #### Text Element - layout = [[SG.Text('This is what a Text Element looks like')]] + layout = [[SG.Text('This is what a Text Element looks like')]] + - ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. - Text(Text, + Text(Text, Scale=(None, None), Size=(None, None), AutoSizeText=None, @@ -430,7 +492,8 @@ This Element doubles as both an input and output Element. The `DefaultText` opt >AutoSizeText - Bool. Change width to match size of text ### Input Elements - These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `Size` is specified in the Element). + These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `Size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. + #### Text Input Element layout = [[SG.InputText('Default text')]] @@ -440,26 +503,50 @@ This Element doubles as both an input and output Element. The `DefaultText` opt Scale=(None, None), Size=(None, None), AutoSizeText=None) +Shorthand functions that are equivalent to `InputText` are `Input` and `In` + +#### Combo Element +Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. + + layout = [[SG.InputCombo(['choice 1', 'choice 2'])]] + +![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) + + InputCombo(Values, + Scale=(None, None), + Size=(None, None), + AutoSizeText=None) + + +## Contributing + +A MikeTheWatchGuy production... entirely responsible for this code + +## Versioning + + +1.0.9 - July 10, 2018 - Initial Release +1.0.20 - July 13, 2018 - Readme file updates + + ## Code Condition +> Make it run +> Make it right +> Make it fast + +It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor on hiding implementation details, naming conventions, PEP 8. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. + +## Authors + + +## License + +This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details + +## Acknowledgments -## Contributing - -A MikeTheWatchGuy production... entirely responsible for this code - -## Versioning - -1.0.9 - July 10, 2018 - Initial Release - - -## Authors - - -## License - -This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details - -## Acknowledgments - * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence + + From a430c86ad2f1d2a4915d155c60ef259fac982b21 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 13 Jul 2018 10:53:50 -0400 Subject: [PATCH 016/209] Readme updates. Button color Still working on completing the Readme. Changed the global button colors to white on black, the new signature for PySimpleGUI. --- Demo High Level APIs.py | 10 ++++++ PySimpleGUI.py | 74 ++++++++++++++++++++++++++++++++++++----- readme.md | 55 ++++++++++++++++++------------ 3 files changed, 110 insertions(+), 29 deletions(-) create mode 100644 Demo High Level APIs.py diff --git a/Demo High Level APIs.py b/Demo High Level APIs.py new file mode 100644 index 000000000..2f9c3bec7 --- /dev/null +++ b/Demo High Level APIs.py @@ -0,0 +1,10 @@ +import PySimpleGUI as sg + +rc, number = sg.GetTextBox('Title goes here', 'Enter a number') +if not rc: + sg.MsgBoxError('You have cancelled') + exit(0) + +msg = '\n'.join([f'{i}' for i in range(0,int(number))]) + +sg.ScrolledTextBox(msg, Height=10) \ No newline at end of file diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 333ab230a..89464f28f 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -31,7 +31,8 @@ (YELLOWS[0], GREENS[3]), (YELLOWS[0], BLUES[2])) # DEFAULT_BUTTON_COLOR = (YELLOWS[0], PURPLES[0]) # (Text, Background) or (Color "on", Color) as a way to remember # DEFAULT_BUTTON_COLOR = (GREENS[3], TANS[0]) # Foreground, Background (None, None) == System Default -DEFAULT_BUTTON_COLOR = (YELLOWS[0], GREENS[4]) # Foreground, Background (None, None) == System Default +# DEFAULT_BUTTON_COLOR = (YELLOWS[0], GREENS[4]) # Foreground, Background (None, None) == System Default +DEFAULT_BUTTON_COLOR = ('white', 'black') # Foreground, Background (None, None) == System Default # DEFAULT_BUTTON_COLOR = (YELLOWS[0], PURPLES[2]) # Foreground, Background (None, None) == System Default DEFAULT_ERROR_BUTTON_COLOR =("#FFFFFF", "#FF0000") DEFAULT_CANCEL_BUTTON_COLOR = (GREENS[3], TANS[0]) @@ -1221,7 +1222,7 @@ def _GetNumLinesNeeded(text, max_line_width): # ===================================================# def MsgBox(*args, ButtonColor=None, ButtonType=MSG_BOX_OK, AutoClose=False, AutoCloseDuration=None, Icon=DEFAULT_WINDOW_ICON, LineWidth=MESSAGE_BOX_LINE_WIDTH, Font=None): ''' - + Show message box. Displays one line per user supplied argument. Takes any Type of variable to display. :param args: :param ButtonColor: :param ButtonType: @@ -1232,10 +1233,13 @@ def MsgBox(*args, ButtonColor=None, ButtonType=MSG_BOX_OK, AutoClose=False, Aut :param Font: :return: ''' - if not args: return - with FlexForm(args[0], AutoSizeText=True, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Icon=Icon, Font=Font) as form: + if not args: + args_to_print = [''] + else: + args_to_print = args + with FlexForm(args_to_print[0], AutoSizeText=True, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Icon=Icon, Font=Font) as form: max_line_total, total_lines = 0,0 - for message in args: + for message in args_to_print: # fancy code to check if string and convert if not is not need. Just always convert to string :-) # if not isinstance(message, str): message = str(message) message = str(message) @@ -1273,6 +1277,15 @@ def MsgBox(*args, ButtonColor=None, ButtonType=MSG_BOX_OK, AutoClose=False, Aut # Lazy function. Same as calling MsgBox with parms # # ===================================================# def MsgBoxAutoClose(*args, ButtonColor=None,AutoClose=True, AutoCloseDuration=DEFAULT_AUTOCLOSE_TIME, Font=None): + ''' + Display a standard MsgBox that will automatically close after a specified amount of time + :param args: + :param ButtonColor: + :param AutoClose: + :param AutoCloseDuration: + :param Font: + :return: + ''' MsgBox(*args, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Font=Font) return @@ -1281,13 +1294,31 @@ def MsgBoxAutoClose(*args, ButtonColor=None,AutoClose=True, AutoCloseDuration=DE # Like MsgBox but presents RED BUTTONS # # ===================================================# def MsgBoxError(*args, ButtonColor=DEFAULT_ERROR_BUTTON_COLOR,AutoClose=False, AutoCloseDuration=None, Font=None): + ''' + Display a MsgBox with a red button + :param args: + :param ButtonColor: + :param AutoClose: + :param AutoCloseDuration: + :param Font: + :return: + ''' MsgBox(*args, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Font=Font) return # ============================== MsgBoxCancel =====# -# Like MsgBox but presents RED BUTTONS # +# # # ===================================================# def MsgBoxCancel(*args,ButtonColor=DEFAULT_CANCEL_BUTTON_COLOR,AutoClose=False, AutoCloseDuration=None, Font=None): + ''' + Display a MsgBox with a single "Cancel" button. + :param args: + :param ButtonColor: + :param AutoClose: + :param AutoCloseDuration: + :param Font: + :return: + ''' MsgBox(*args, ButtonType=MSG_BOX_CANCELLED, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Font=Font) return @@ -1295,13 +1326,31 @@ def MsgBoxCancel(*args,ButtonColor=DEFAULT_CANCEL_BUTTON_COLOR,AutoClose=False, # Like MsgBox but only 1 button # # ===================================================# def MsgBoxOK(*args,ButtonColor=('white', 'black'),AutoClose=False, AutoCloseDuration=None, Font=None): + ''' + Display a MsgBox with a single buttoned labelled "OK" + :param args: + :param ButtonColor: + :param AutoClose: + :param AutoCloseDuration: + :param Font: + :return: + ''' MsgBox(*args, ButtonType=MSG_BOX_OK, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Font=Font) return -# ============================== MsgBoxCancel =====# -# Like MsgBox but presents RED BUTTONS # +# ============================== MsgBoxOKCancel ====# +# Like MsgBox but presents OK and Cancel buttons # # ===================================================# def MsgBoxOKCancel(*args,ButtonColor=None,AutoClose=False, AutoCloseDuration=None, Font=None): + ''' + Display MsgBox with 2 buttons, "OK" and "Cancel" + :param args: + :param ButtonColor: + :param AutoClose: + :param AutoCloseDuration: + :param Font: + :return: + ''' result = MsgBox(*args, ButtonType=MSG_BOX_OK_CANCEL, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Font=Font) return result @@ -1310,6 +1359,15 @@ def MsgBoxOKCancel(*args,ButtonColor=None,AutoClose=False, AutoCloseDuration=Non # Returns True if Yes was pressed else False # # ===================================================# def MsgBoxYesNo(*args,ButtonColor=None,AutoClose=False, AutoCloseDuration=None, Font=None): + ''' + Display MsgBox with 2 buttons, "Yes" and "No" + :param args: + :param ButtonColor: + :param AutoClose: + :param AutoCloseDuration: + :param Font: + :return: + ''' result = MsgBox(*args,ButtonType=MSG_BOX_YES_NO, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Font=Font) return result diff --git a/readme.md b/readme.md index cfb44a7b3..f41477af9 100644 --- a/readme.md +++ b/readme.md @@ -21,21 +21,25 @@ You can add a GUI to your command line with a single line of code. With 3 or 4 The customization is via the form/dialog box builder that enables users to experience all of the normal GUI widgets without having to write a lot of code. -> Features of PySimpleGUI include: -> Text -> Single Line Input -> Buttons including these types: File Browse Folder Browse Non-closing return Close form -> Checkboxes -> Radio Buttons -> Icons -> Multi-line Text Input -> Scroll-able Output -> Progress Bar -> Async/Non-Blocking Windows -> Tabbed forms -> Persistent Windows -> Redirect Python Output/Errors to scrolling Window -> 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + Features of PySimpleGUI include: + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Checkboxes + Radio Buttons + Icons + Multi-line Text Input + Scroll-able Output + Progress Bar + Async/Non-Blocking Windows + Tabbed forms + Persistent Windows + Redirect Python Output/Errors to scrolling Window + 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) An example of many widgets used on a single form. A little further down you'll find the FIFTEEN lines of code required to create this complex form. @@ -199,6 +203,19 @@ We all have loops in our code. 'Isn't it joyful waiting, watching a counter scr Scale=(None, None), BorderWidth=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): +Here's the one-line Progress Meter in action! + + for i in range(1,10000): + SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') + +That line of code resulted in this window popping up and updating. +![progress meter 5](https://user-images.githubusercontent.com/13696193/42696912-a5c958b8-8687-11e8-9a7d-a390a465407a.jpg) + +A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. +With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. + + if not SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message'): break + # Custom Form API Calls This is the FUN part of the programming of this GUI. In order to really get the most out of the API, you should be using an IDE that supports auto complete or will show you the definition of the function. This will make customizing go smoother. @@ -478,7 +495,8 @@ A MikeTheWatchGuy production... entirely responsible for this code ## Versioning -1.0.9 - July 10, 2018 - Initial Release +1.0.9 - July 10, 2018 - Initial Release +1.0.21 - July 13, 2018 - Readme updates ## Code Condition > Make it run @@ -497,8 +515,3 @@ This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md ## Acknowledgments * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence - - - - - From cb3f2a500712a3b03f856fe5d29b401128a20bce Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 13 Jul 2018 11:02:21 -0400 Subject: [PATCH 017/209] Initial checkin Demonstrates using custom forms to generate a 3 forms. Two are synchronous forms and one is async. Excellent design templates. --- Demo Recipes.py | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Demo Recipes.py diff --git a/Demo Recipes.py b/Demo Recipes.py new file mode 100644 index 000000000..a19bdeeba --- /dev/null +++ b/Demo Recipes.py @@ -0,0 +1,63 @@ +import PySimpleGUI as g + +def SourceDestFolders(): + with g.FlexForm('Demo Source / Destination Folders', AutoSizeText=True) as form: + form_rows = [[g.Text('Enter the Source and Destination folders')], + [g.Text('Choose Source and Destination Folders')], + [g.Text('Source Folder', Size=(15, 1), AutoSizeText=False), g.InputText('Source'), + g.FolderBrowse()], + [g.Text('Destination Folder', Size=(15, 1), AutoSizeText=False), g.InputText('Dest'), + g.FolderBrowse()], + [g.Submit(), g.Cancel()]] + + (button, (source, dest)) = form.LayoutAndShow(form_rows) + if button == 'Submit': + # do something useful with the inputs + g.MsgBox('Submitted', 'The user entered source folder', source, 'And destination folder', dest) + else: + g.MsgBoxError('Cancelled', 'User Cancelled') + +def Everything(): + with g.FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(40,1)) as form: + layout = [[g.Text('All graphic widgets in one form!', Size=(30,1), Font=("Helvetica", 25))], + [g.Text('Here is some text.... and a place to enter text')], + [g.InputText()], + [g.Checkbox('My first checkbox!'), g.Checkbox('My second checkbox!', Default=True)], + [g.Radio('My first Radio!', "RADIO1", Default=True), g.Radio('My second Radio!', "RADIO1")], + [g.Multiline(DefaultText='This is the DEFAULT Text should you decide not to type anything', Scale=(2, 10))], + [g.InputCombo(['choice 1', 'choice 2'], Size=(20, 3))], + [g.Text('_' * 100, Size=(90, 1))], + [g.Text('Choose Source and Destination Folders', Size=(35,1))], + [g.Text('Source Folder', Size=(15, 1), AutoSizeText=False), g.InputText('Source'), g.FolderBrowse()], + [g.Text('Destination Folder', Size=(15, 1), AutoSizeText=False), g.InputText('Dest'), g.FolderBrowse()], + [g.SimpleButton('Your very own button')], + [g.Submit(), g.Cancel()]] + + (button, (values)) = form.LayoutAndShow(layout) + + g.MsgBox('Title', 'Typical message box', 'The results of the form are a lot of data! Get ready... ', 'The button clicked was "{}"'.format(button), 'The values are', values) + +# example of an Asynchronous form +def ChatBot(): + with g.FlexForm('Chat Window', AutoSizeText=True, DefaultElementSize=(30, 2)) as form: + form.AddRow(g.Text('This is where standard out is being routed', Size=[40,1])) + form.AddRow(g.Output(Size=(80, 20))) + form.AddRow(g.Multiline(Size=(70, 5), EnterSubmits=True), g.ReadFormButton('SEND', ButtonColor=(g.YELLOWS[0], g.BLUES[0])), g.SimpleButton('EXIT', ButtonColor=(g.YELLOWS[0], g.GREENS[0]))) + + # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # + while True: + (button, value) = form.Read() + if button == 'SEND': + print(value) + else: + print('Exiting the form now') + break + print('Exiting the chatbot....') + +def main(): + SourceDestFolders() + Everything() + ChatBot() + +if __name__ == '__main__': + main() From 61b9ccb2283a9cc36f92657c5153245e3bea3489 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 13 Jul 2018 11:03:20 -0400 Subject: [PATCH 018/209] Update readme.md --- readme.md | 603 ++++++++++++++---------------------------------------- 1 file changed, 155 insertions(+), 448 deletions(-) diff --git a/readme.md b/readme.md index 13ec0a13d..8f2765bc1 100644 --- a/readme.md +++ b/readme.md @@ -8,107 +8,67 @@ This really is a simple GUI, but also powerfully customizable. I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. - + Python itself doesn't have a simple GUI solution... nor did the *many* GUI packages I tried. Most tried to do TOO MUCH, making it impossible for users to get started quickly. Others were just plain broken, requiring multiple files or other packages that were missing. - -The PySimpleGUI solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. - + +The PySimpleGUI solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. + You can add a GUI to your command line with a single line of code. With 3 or 4 lines of code you can add a fully customized GUI. And for you Machine Learning folks out there, a **single line** progress meter call that you can drop into any loop. ![progress meter 2](https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg) - The customization is via the form/dialog box builder that enables users to experience all of the normal GUI widgets without having to write a lot of code. - + The customization is via the form/dialog box builder that enables users to experience all of the normal GUI widgets without having to write a lot of code. + -<<<<<<< HEAD - Features of PySimpleGUI include: - Text - Single Line Input - Buttons including these types: + Features of PySimpleGUI include: + Text + Single Line Input + Buttons including these types: File Browse Folder Browse Non-closing return - Close form - Checkboxes - Radio Buttons - Icons - Multi-line Text Input - Scroll-able Output - Progress Bar - Async/Non-Blocking Windows + Close form + Checkboxes + Radio Buttons + Icons + Multi-line Text Input + Scroll-able Output + Progress Bar + Async/Non-Blocking Windows Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling Window + Persistent Windows + Redirect Python Output/Errors to scrolling Window 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) -======= - -> Features of PySimpleGUI include: -> Text -> Single Line Input -> Buttons including these types: -> File Browse -> Folder Browse -> Non-closing return -> Close form -> Checkboxes -> Radio Buttons -> Icons -> Multi-line Text Input -> Scroll-able Output -> Progress Bar -> Async/Non-Blocking Windows -> Tabbed forms -> Persistent Windows -> Redirect Python Output/Errors to scrolling Window -> 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) -> Features of PySimpleGUI include: -> Text -> Single Line Input -> Buttons including these types: File Browse Folder Browse Non-closing return Close form -> Checkboxes -> Radio Buttons -> Icons -> Multi-line Text Input -> Scroll-able Output -> Progress Bar -> Async/Non-Blocking Windows -> Tabbed forms -> Persistent Windows -> Redirect Python Output/Errors to scrolling Window -> 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) ->>>>>>> 46e56434a39bcd98d4683aa3da3a3126999e6f13 - - An example of many widgets used on a single form. A little further down you'll find the FIFTEEN lines of code required to create this complex form. ![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) - -## Getting Started with PySimpleGUI - -### Installing - - pip install PySimpleGUI - or -Simply download the file - PySimpleGUI.py and import it into your code - - -### Prerequisites - -Python 3 -tkinter - -Should run on all Python platforms that have tkinter running on them. Has been thoroughly tested on Windows. While not tested elsewhere, should work on Linux, Mac, Pi, etc. - + +## Getting Started with PySimpleGUI + +### Installing + + pip install PySimpleGUI + or +Simply download the file - PySimpleGUI.py and import it into your code + + +### Prerequisites + +Python 3 +tkinter + +Should run on all Python platforms that have tkinter running on them. Has been thoroughly tested on Windows. While not tested elsewhere, should work on Linux, Mac, Pi, etc. + ### Using To us in your code, simply import.... - `import PySimpleGUI as SG` + `import PySimpleGUI as SG` -Then use either "high level" API calls or build your own forms. +Then use either "high level" API calls or build your own forms. SG.MsgBox('This is my first message box') ![simple msgbox](https://user-images.githubusercontent.com/13696193/42597824-1749b160-8528-11e8-9114-374bf9731b30.jpg) @@ -116,90 +76,65 @@ Then use either "high level" API calls or build your own forms. Yes, it's just that easy to have a window appear on the screen using Python. ## APIs - -PySimpleGUI can be broken down into 2 types of API's: - * High Level single call functions - * Custom form functions - + +PySimpleGUI can be broken down into 2 types of API's: + * High Level single call functions + * Custom form functions + ### Python Language Features There are a couple of Python language features that PySimpleGUI utilizes heavily that should be understood first... - * Variable number of arguments to a function call + * Variable number of arguments to a function call * Optional parameters to a function call - + #### Variable Number of Arguments The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. - + SG.MsgBox('Variable number of parameters example', my_variable, second_variable, "etc") Each new item begins on a new line in the Message Box ![variablearguments](https://user-images.githubusercontent.com/13696193/42598375-022bc51e-852a-11e8-8f77-4d664ae1a560.jpg) - + #### Optional Parameters to a Function Call - + This feature of the Python language is utilized ***heavily*** as a method of customizing forms and part of forms. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. -Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't have to be specified on each and every call. +Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't have to be specified on each and every call. -<<<<<<< HEAD - def MsgBox(*args, - ButtonColor=None, - ButtonType=MSG_BOX_OK, - AutoClose=False, - AutoCloseDuration=None, - Icon=DEFAULT_WINDOW_ICON, + def MsgBox(*args, + ButtonColor=None, + ButtonType=MSG_BOX_OK, + AutoClose=False, + AutoCloseDuration=None, + Icon=DEFAULT_WINDOW_ICON, LineWidth=MESSAGE_BOX_LINE_WIDTH, Font=None): -======= - - Features of PySimpleGUI include: - Text - Single Line Input - Buttons including these types: - File Browse - Folder Browse - Non-closing return - Close form - Checkboxes - Radio Buttons - Icons - Multi-line Text Input - Scroll-able Output - Progress Bar - Async/Non-Blocking Windows - Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling Window - 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) - - ->>>>>>> 46e56434a39bcd98d4683aa3da3a3126999e6f13 If the caller wanted to change the button color to be black on yellow, the call would look something like this: - SG.MsgBox('This box has a custom button color', + SG.MsgBox('This box has a custom button color', ButtonColor=('black', 'yellow')) ![custombuttoncolor](https://user-images.githubusercontent.com/13696193/42599212-84f3fe2e-852c-11e8-8a60-4aad669a1fd6.jpg) -### High Level API Calls - -The classic "input a value, print result" example. -Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. -This code prompts user to input a line of text and then displays that text in a messages box: - - import PySimpleGUI_local as SG - - rc = SG.GetTextBox('Title', 'Please input something') - SG.MsgBox('Results', 'The value returned from GetTextBox', rc) - -![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) - -![MsgBox](https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg) +### High Level API Calls +The classic "input a value, print result" example. +Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. +This code prompts user to input a line of text and then displays that text in a messages box: + + import PySimpleGUI_local as SG + + rc = SG.GetTextBox('Title', 'Please input something') + SG.MsgBox('Results', 'The value returned from GetTextBox', rc) + +![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) + +![MsgBox](https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg) + #### Message Boxes In addition to MsgBox, you'll find a several API calls that are shortcuts to common messages boxes. You can achieve similar results by calling MsgBox with the correct parameters. @@ -208,7 +143,7 @@ The differences tend to be the number and types of buttons. Here are the calls import PySimpleGUI as SG `SG.MsgBoxOK('This is an OK MsgBox')` - + ![msgboxok](https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg) SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') @@ -232,13 +167,13 @@ The differences tend to be the number and types of buttons. Here are the calls ![scrolledtextbox](https://user-images.githubusercontent.com/13696193/42600800-a44f4562-8531-11e8-8c21-51dd70316879.jpg) -Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. +Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. #### High Level User Input There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. If you need only 1 value, then perhaps one of these high level functions will work. - GetTextBox - - GetFileBox + - GetFileBox - GetFolderBox `submit_clicked, value = SG.GetTextBox('Title', 'Please enter anything')` @@ -256,7 +191,6 @@ There are 3 very basic user input high-level function calls. It's expected that #### Progress Meter! We all have loops in our code. 'Isn't it joyful waiting, watching a counter scrolling past in a text window? How about one line of code to get a progress meter, that contains statistics about your code? ![progress meter 3](https://user-images.githubusercontent.com/13696193/42696332-dca3ca6e-8685-11e8-846b-6bee8362ee5f.jpg) -<<<<<<< HEAD EasyProgressMeter(Title, CurrentValue, @@ -269,35 +203,18 @@ We all have loops in our code. 'Isn't it joyful waiting, watching a counter scr Scale=(None, None), BorderWidth=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): -======= - - EasyProgressMeter(Title, - CurrentValue, - MaxValue, - *args, - Orientation=None, - BarColor=DEFAULT_PROGRESS_BAR_COLOR, - ButtonColor=None, - Size=DEFAULT_PROGRESS_BAR_SIZE, - Scale=(None, None), - BorderWidth=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): - ->>>>>>> 46e56434a39bcd98d4683aa3da3a3126999e6f13 Here's the one-line Progress Meter in action! - for i in range(1,10000): + for i in range(1,10000): SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') That line of code resulted in this window popping up and updating. ![progress meter 5](https://user-images.githubusercontent.com/13696193/42696912-a5c958b8-8687-11e8-9a7d-a390a465407a.jpg) A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. -<<<<<<< HEAD -With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. +With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. if not SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message'): break -======= ->>>>>>> 46e56434a39bcd98d4683aa3da3a3126999e6f13 # Custom Form API Calls @@ -307,10 +224,10 @@ It's both not enjoyable nor helpful to immediately jump into tweaking each and e ## COPY THIS DESIGN PATTERN! - with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], - [SG.InputText(), SG.FileBrowse()], - [SG.Submit(), SG.Cancel()]] + with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + [SG.InputText(), SG.FileBrowse()], + [SG.Submit(), SG.Cancel()]] (button, (source_filename, )) = form.LayoutAndShow(form_rows) This context manager contains all of the code needed to specify, show and retrieve results for this form: @@ -318,23 +235,23 @@ This context manager contains all of the code needed to specify, show and retrie It's important to use the "with" context manager. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. -You will use this design pattern or code template for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. +You will use this design pattern or code template for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. > Copy, Paste, Run. -PySimpleGUI's goal with the API is to be easy on the programmer. An attempt was made to make the program's code visually match the window on the screen. The way this is done is that a GUI is broken up into "Rows". Then each row is broke up into "Elements" or "Widgets". Each element is specified by names such as Text, Button, Checkbox, etc. +PySimpleGUI's goal with the API is to be easy on the programmer. An attempt was made to make the program's code visually match the window on the screen. The way this is done is that a GUI is broken up into "Rows". Then each row is broke up into "Elements" or "Widgets". Each element is specified by names such as Text, Button, Checkbox, etc. Some elements are shortcuts, again meant to make it easy on the programmer. Rather than writing a `Button`, with name = "Submit", etc, the caller simply writes `Submit`. Going through each line of code - with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: -This creates a new form, storing it in the variable `form`. + with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: +This creates a new form, storing it in the variable `form`. - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. - [SG.InputText(), SG.FileBrowse()], + [SG.InputText(), SG.FileBrowse()], Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. [SG.Submit(), SG.Cancel()]] @@ -346,42 +263,42 @@ This is the code that **displays** the form, collects the information and return ## Return values - Return information from FlexForm, SG's primary form builder interface, is in this format: - - (button, (value1, value2, ...)) - -Don't forget all those ()'s of your values won't be coreectly assigned. - -If you have a SINGLE value being returned, it is written this way: - + Return information from FlexForm, SG's primary form builder interface, is in this format: + + (button, (value1, value2, ...)) + +Don't forget all those ()'s of your values won't be coreectly assigned. + +If you have a SINGLE value being returned, it is written this way: + (button, (value1,)) = form.LayoutAndShow(form_rows) Another way of parsing the return values is to store the list of values into a variable that is then referenced. - (button, (value)) = form.LayoutAndShow(form_rows) + (button, (value)) = form.LayoutAndShow(form_rows) value1 = values[0] value2 = values[1] ... - + ## All Widgets / Elements This code utilizes as many of the elements in one form as possible. - with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: - layout = [[Text('Here they all are!', Size=(30,1), Font=("Helvetica", 25), TextColor='red')], - [Text('Here is some text with font sizing', Font=("Helvetica", 15))], - [InputText()], - [Checkbox('My first checkbox!'), Checkbox('My second checkbox!', Default=True)], - [Radio('My first Radio!', "RADIO1", Default=True), Radio('My second checkbox!', "RADIO1")], - [Multiline(DefaultText='This is the DEFAULT text should you decide not to type anything', Scale=(2, 10))], - [InputCombo(['choice 1', 'choice 2'], Size=(20, 3))], - [Text('_' * 90, Size=(60, 1))], - [Text('Choose Source and Destination Folders', Size=(35,1))], - [Text('Source Folder', Size=(15, 1), AutoSizeText=False), InputText('Source'), FolderBrowse()], - [Text('Destination Folder', Size=(15, 1), AutoSizeText=False), InputText('Dest'), FolderBrowse()], - [SimpleButton('Your Button with any text you want')], - [SimpleButton('Big Text', Size=(12,1), Font=("Helvetica", 20))], - [Submit(), Cancel()]] - + with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: + layout = [[Text('Here they all are!', Size=(30,1), Font=("Helvetica", 25), TextColor='red')], + [Text('Here is some text with font sizing', Font=("Helvetica", 15))], + [InputText()], + [Checkbox('My first checkbox!'), Checkbox('My second checkbox!', Default=True)], + [Radio('My first Radio!', "RADIO1", Default=True), Radio('My second checkbox!', "RADIO1")], + [Multiline(DefaultText='This is the DEFAULT text should you decide not to type anything', Scale=(2, 10))], + [InputCombo(['choice 1', 'choice 2'], Size=(20, 3))], + [Text('_' * 90, Size=(60, 1))], + [Text('Choose Source and Destination Folders', Size=(35,1))], + [Text('Source Folder', Size=(15, 1), AutoSizeText=False), InputText('Source'), FolderBrowse()], + [Text('Destination Folder', Size=(15, 1), AutoSizeText=False), InputText('Dest'), FolderBrowse()], + [SimpleButton('Your Button with any text you want')], + [SimpleButton('Big Text', Size=(12,1), Font=("Helvetica", 20))], + [Submit(), Cancel()]] + (button, (values)) = form.LayoutAndShow(layout) @@ -397,214 +314,11 @@ Clicking the Submit button caused the form call to return. The call to MsgBox r ![results](https://user-images.githubusercontent.com/13696193/42604952-502f64e6-8543-11e8-8045-bc10d38c5fd4.jpg) One important aspect of this example is the return codes: -<<<<<<< HEAD - - (button, (values)) = form.LayoutAndShow(layout) -The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. - -You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. - - - -# Building Custom Forms -You will find it much easier to write code using PySimpleGUI is you use features that show you documentation about the API call you are making. In PyCharm 2 commands are helpful. - -> Control-Q (when cursor is on function name) brings up a box with the -> function definition -> Control-P (when cursor inside function call "()") -> shows a list of parameters and their default values - -## Synchronous Forms -The most common use of PySimpleGUI is to display and collect information from the user. The most straightforward way to do this is using a "blocking" GUI call. Execution is "blocked" while waiting for the user to close the GUI form/dialog box. -You've already seen a number of examples above that use blocking forms. Anytime you see a context manager used (see the `with` statement) it's most likely a blocking form. You can examine the show calls to be sure. If the form is a non-blocking form, it must indicate that in the call to `form.show`. - -NON-BLOCKING form call: - - form.Show(NonBlocking=True) - -### Beginning a Form -The first step is to create the form object using the desired form customization. - - with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: -Let's go through the options available when creating a form. - - def __init__(self, title, - DefaultElementSize=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), - AutoSizeText=DEFAULT_AUTOSIZE_TEXT, - Scale=(None, None), - Size=(None, None), - Location=(None, None), - ButtonColor=None,Font=None, - ProgressBarColor=(None,None), - IsTabbedForm=False, - BorderDepth=None, - AutoClose=False, - AutoCloseDuration=DEFAULT_AUTOCLOSE_TIME, - Icon=DEFAULT_WINDOW_ICON): - - -#### Sizes -Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. - -The default Element size for PySimpleGUI is `(45,1)`. - -Sizes can be set at the element level, or in this case, the size variables apply to all elements in the form. Setting `Size=(20,1)` in the form creation call will set all elements in the form to that size. - -In addition to `size` there is a `scale` option. Scale will take the Element's size and scale it up or down depending on the scale value. `scale=(1,1)` doesn't change the Element's size. `scale=(2,1)` will set the Element's size to be twice as wide as the size setting. - - -#### FlexForm - form-level variables overview -A summary of the variables that can be changed when a FlexForm is created - -> DefaultElementSize - set default size for all elements in the form -> AutoSizeText - true/false autosizing turned on / off -> Scale - set scale value for all elements -> ButtonColor - default button color (foreground, background) -> Font - font name and size for all text items -> ProgressBarColor - progress bar colors -> IsTabbedForm - true/false indicates form is a tabbed or normal form -> BorderDepth - style setting for buttons, input fields -> AutoClose - true/false indicates if form will automatically close -> AutoCloseDuration - how long in seconds before closing form -> Icon - filename for icon that's displayed on the window on taskbar - - -## Elements -"Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. - -> Text -> Single Line Input -> Buttons including these types: File Browse Folder Browse Non-closing return Close form -> Checkboxes -> Radio Buttons -> Multi-line Text Input -> Scroll-able Output -> Progress Bar -> Async/Non-Blocking Windows -> Tabbed forms -> Persistent Windows -> Redirect Python Output/Errors to scrolling Window -> 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) - - -### Output Elements -Building a form is simply making lists of Elements. Each list is a row in the overall GUI dialog box. The definition looks something like this: - - layout = [ [row 1 element, row 1 element], - [row 2 element, row 2 element, row 2 element] ] -The code is a crude representation of the GUI, laid out in text. -#### Text Element - - layout = [[SG.Text('This is what a Text Element looks like')]] - - - ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) - - -The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. - - Text(Text, - Scale=(None, None), - Size=(None, None), - AutoSizeText=None, - Font=None, - TextColor=None) - -Some commonly used elements have 'shorthand' versions of the functions to make the code more compact. The functions `T` and `Txt` are the same as calling `Text`. - -**Fonts** in PySimpleGUI are always in this format: - - (font_name, point_size) - -The default font setting is - - ("Helvetica", 10) - -**Colos** in PySimpleGUI are always in this format: - - (foreground, background) - -The values foreground and background can be the color names or the hex value formatted as a string: - - "#RRGGBB" - -#### Multiline Text Element - - layout = [[SG.Multiline('This is what a Multi-line Text Element looks like', Size=(45,5))]] -![multiline text](https://user-images.githubusercontent.com/13696193/42670464-0824c754-8629-11e8-9741-6ed08f924618.jpg) -This Element doubles as both an input and output Element. The `DefaultText` optional parameter is used to indicate what to output to the window. - - Multiline(DefaultText='', - EnterSubmits = False, - Scale=(None, None), - Size=(None, None), - AutoSizeText=None) - -> DefaultText - Text to display in the text box ->EnterSubmits - Bool. If True, pressing Enter key submits form ->Scale - Element's scale ->Size - Element's size ->AutoSizeText - Bool. Change width to match size of text - -### Input Elements - These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `Size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. - -#### Text Input Element - - layout = [[SG.InputText('Default text')]] -![inputtext](https://user-images.githubusercontent.com/13696193/42693515-610a716c-867d-11e8-9a00-7e7fcf771230.jpg) - - def InputText(DefaultText = '', - Scale=(None, None), - Size=(None, None), - AutoSizeText=None) -Shorthand functions that are equivalent to `InputText` are `Input` and `In` - -#### Combo Element -Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. - - layout = [[SG.InputCombo(['choice 1', 'choice 2'])]] - -![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) - - InputCombo(Values, - Scale=(None, None), - Size=(None, None), - AutoSizeText=None) - - -## Contributing - -A MikeTheWatchGuy production... entirely responsible for this code - -## Versioning - -1.0.9 - July 10, 2018 - Initial Release -1.0.21 - July 13, 2018 - Readme updates - - ## Code Condition -> Make it run -> Make it right -> Make it fast - -It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor on hiding implementation details, naming conventions, PEP 8. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. - -## Authors - - -## License - -This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details - -## Acknowledgments - -* Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence -======= (button, (values)) = form.LayoutAndShow(layout) The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. -You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. +You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. @@ -612,7 +326,7 @@ You can see in the MsgBox that the values returned are a list. Each input field You will find it much easier to write code using PySimpleGUI is you use features that show you documentation about the API call you are making. In PyCharm 2 commands are helpful. > Control-Q (when cursor is on function name) brings up a box with the -> function definition +> function definition > Control-P (when cursor inside function call "()") > shows a list of parameters and their default values @@ -627,10 +341,10 @@ NON-BLOCKING form call: ### Beginning a Form The first step is to create the form object using the desired form customization. - with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: + with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: Let's go through the options available when creating a form. - def __init__(self, title, + def __init__(self, title, DefaultElementSize=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), AutoSizeText=DEFAULT_AUTOSIZE_TEXT, Scale=(None, None), @@ -643,7 +357,7 @@ Let's go through the options available when creating a form. AutoClose=False, AutoCloseDuration=DEFAULT_AUTOCLOSE_TIME, Icon=DEFAULT_WINDOW_ICON): - + #### Sizes Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. @@ -674,18 +388,18 @@ A summary of the variables that can be changed when a FlexForm is created ## Elements "Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. -> Text -> Single Line Input -> Buttons including these types: File Browse Folder Browse Non-closing return Close form -> Checkboxes -> Radio Buttons -> Multi-line Text Input -> Scroll-able Output -> Progress Bar -> Async/Non-Blocking Windows +> Text +> Single Line Input +> Buttons including these types: File Browse Folder Browse Non-closing return Close form +> Checkboxes +> Radio Buttons +> Multi-line Text Input +> Scroll-able Output +> Progress Bar +> Async/Non-Blocking Windows > Tabbed forms -> Persistent Windows -> Redirect Python Output/Errors to scrolling Window +> Persistent Windows +> Redirect Python Output/Errors to scrolling Window > 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) @@ -697,15 +411,15 @@ Building a form is simply making lists of Elements. Each list is a row in the o The code is a crude representation of the GUI, laid out in text. #### Text Element - layout = [[SG.Text('This is what a Text Element looks like')]] - + layout = [[SG.Text('This is what a Text Element looks like')]] + ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. - Text(Text, + Text(Text, Scale=(None, None), Size=(None, None), AutoSizeText=None, @@ -750,7 +464,7 @@ This Element doubles as both an input and output Element. The `DefaultText` opt ### Input Elements These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `Size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. - + #### Text Input Element layout = [[SG.InputText('Default text')]] @@ -766,45 +480,38 @@ Shorthand functions that are equivalent to `InputText` are `Input` and `In` Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. layout = [[SG.InputCombo(['choice 1', 'choice 2'])]] - + ![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) - InputCombo(Values, + InputCombo(Values, Scale=(None, None), Size=(None, None), AutoSizeText=None) -## Contributing - -A MikeTheWatchGuy production... entirely responsible for this code - -## Versioning - - -1.0.9 - July 10, 2018 - Initial Release -1.0.20 - July 13, 2018 - Readme file updates - - ## Code Condition -> Make it run +## Contributing + +A MikeTheWatchGuy production... entirely responsible for this code + +## Versioning + +1.0.9 - July 10, 2018 - Initial Release +1.0.21 - July 13, 2018 - Readme updates + + ## Code Condition +> Make it run > Make it right > Make it fast It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor on hiding implementation details, naming conventions, PEP 8. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. - -## Authors - - -## License - -This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details - -## Acknowledgments - + +## Authors + + +## License + +This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details + +## Acknowledgments + * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence - - - - - ->>>>>>> 46e56434a39bcd98d4683aa3da3a3126999e6f13 From d15b199d4e50125368319ce467bedb60ba4c47b4 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 13 Jul 2018 13:24:22 -0400 Subject: [PATCH 019/209] Update readme.md --- readme.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 8f2765bc1..ef139cdb2 100644 --- a/readme.md +++ b/readme.md @@ -15,6 +15,7 @@ The PySimpleGUI solution is focused on the ***developer***. How can the desired You can add a GUI to your command line with a single line of code. With 3 or 4 lines of code you can add a fully customized GUI. And for you Machine Learning folks out there, a **single line** progress meter call that you can drop into any loop. + ![progress meter 2](https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg) @@ -209,6 +210,7 @@ Here's the one-line Progress Meter in action! SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') That line of code resulted in this window popping up and updating. + ![progress meter 5](https://user-images.githubusercontent.com/13696193/42696912-a5c958b8-8687-11e8-9a7d-a390a465407a.jpg) A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. @@ -436,7 +438,7 @@ The default font setting is ("Helvetica", 10) -**Colos** in PySimpleGUI are always in this format: +**Color** in PySimpleGUI are always in this format: (foreground, background) @@ -444,6 +446,10 @@ The values foreground and background can be the color names or the hex value for "#RRGGBB" +**AutoSizeText** +A `True` value for `AutoSizeText`, when placed on any Element, indicates that the width of the Element should be shrunk do the width of the text. This is particularly useful with `Buttons` as fixed-width buttons are somewhat crude looking. The default value is `False`. You will often see this setting on FlexForm definitions. + + #### Multiline Text Element layout = [[SG.Multiline('This is what a Multi-line Text Element looks like', Size=(45,5))]] @@ -462,6 +468,16 @@ This Element doubles as both an input and output Element. The `DefaultText` opt >Size - Element's size >AutoSizeText - Bool. Change width to match size of text +#### Output Element +Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. More on this later. + + form.AddRow(gg.Output(Size=(100,20))) + +![output element](https://user-images.githubusercontent.com/13696193/42704820-5446959c-869f-11e8-849e-047ea280387a.jpg) + + Output(Scale=(None, None), + Size=(None, None)) + ### Input Elements These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `Size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. @@ -488,6 +504,17 @@ Also known as a drop-down list. Only required parameter is the list of choices. Size=(None, None), AutoSizeText=None) +#### Radio Button Element +Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. + + + +#### Checkbox Element +#### Spin Element +#### Button Element +#### ProgressBar +#### Output +#### UberForm ## Contributing @@ -515,3 +542,4 @@ This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md ## Acknowledgments * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence + From 4438bac4399a2dce333b518b3e81427cbe3c3545 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 13 Jul 2018 13:42:43 -0400 Subject: [PATCH 020/209] Button color --- Demo Recipes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Demo Recipes.py b/Demo Recipes.py index a19bdeeba..0d57c15de 100644 --- a/Demo Recipes.py +++ b/Demo Recipes.py @@ -19,7 +19,7 @@ def SourceDestFolders(): def Everything(): with g.FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(40,1)) as form: - layout = [[g.Text('All graphic widgets in one form!', Size=(30,1), Font=("Helvetica", 25))], + layout = [[g.Text('All graphic widgets in one form!', Size=(30,1), Font=("Helvetica", 25), TextColor='blue')], [g.Text('Here is some text.... and a place to enter text')], [g.InputText()], [g.Checkbox('My first checkbox!'), g.Checkbox('My second checkbox!', Default=True)], @@ -30,7 +30,7 @@ def Everything(): [g.Text('Choose Source and Destination Folders', Size=(35,1))], [g.Text('Source Folder', Size=(15, 1), AutoSizeText=False), g.InputText('Source'), g.FolderBrowse()], [g.Text('Destination Folder', Size=(15, 1), AutoSizeText=False), g.InputText('Dest'), g.FolderBrowse()], - [g.SimpleButton('Your very own button')], + [g.SimpleButton('Your very own button', ButtonColor=('white', 'green'))], [g.Submit(), g.Cancel()]] (button, (values)) = form.LayoutAndShow(layout) From caad84a674b8248c518e707c8f8cc87a7b30664e Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 13 Jul 2018 13:52:49 -0400 Subject: [PATCH 021/209] Update readme.md --- readme.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/readme.md b/readme.md index ef139cdb2..f146bbab1 100644 --- a/readme.md +++ b/readme.md @@ -478,6 +478,9 @@ Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. Output(Scale=(None, None), Size=(None, None)) +> Scale - How much to scale size of element +> Size - Size of element (width, height) in characters + ### Input Elements These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `Size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. @@ -490,8 +493,15 @@ Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. Scale=(None, None), Size=(None, None), AutoSizeText=None) + +> DefaultText - Text initially shown in the input box +> Scale - Amount size is scaled by +> Size - (width, height) of element in characters +> AutoSizeText - Bool. True is element should be sized to fit text + Shorthand functions that are equivalent to `InputText` are `Input` and `In` + #### Combo Element Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. @@ -504,10 +514,34 @@ Also known as a drop-down list. Only required parameter is the list of choices. Size=(None, None), AutoSizeText=None) +> Values Choices to be displayed. List of strings +> Scale - Amount to scale size by +> Size - (width, height) of element in characters +> AutoSizeText - Bool. True if size should fit the text length + #### Radio Button Element Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. + layout = [[SG.Radio('My first Radio!', "RADIO1", Default=True), SG.Radio('My second radio!', "RADIO1")]] + +![radio element](https://user-images.githubusercontent.com/13696193/42705705-327b4b6c-86a2-11e8-81a7-740e57646ba8.jpg) + + Radio(Text, + GroupID, + Default=False, + Scale=(None, None), + Size=(None, None), + AutoSizeText=None, + Font=None) + +> Text - Text to display next to button +> GroupID - Variable to groups together multiple Radio Buttons. Can be any value +> Default - Bool. Initial state +> Scale - Amount to scale size of element +> Size - (width, height) size of element in characters +> AutoSizeText - Bool. True if should size width to fit text +> Font - Font type and size for text display #### Checkbox Element #### Spin Element From 3c8ea90692243ab6991e8415a379e33dcc2dd330 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 13 Jul 2018 16:53:03 -0400 Subject: [PATCH 022/209] More readme updates --- Demo Recipes.py | 8 +-- readme.md | 178 ++++++++++++++++++++++++++++++------------------ 2 files changed, 117 insertions(+), 69 deletions(-) diff --git a/Demo Recipes.py b/Demo Recipes.py index 0d57c15de..890454c9a 100644 --- a/Demo Recipes.py +++ b/Demo Recipes.py @@ -1,4 +1,4 @@ -import PySimpleGUI as g +import PySimpleGUI_local as g def SourceDestFolders(): with g.FlexForm('Demo Source / Destination Folders', AutoSizeText=True) as form: @@ -35,7 +35,7 @@ def Everything(): (button, (values)) = form.LayoutAndShow(layout) - g.MsgBox('Title', 'Typical message box', 'The results of the form are a lot of data! Get ready... ', 'The button clicked was "{}"'.format(button), 'The values are', values) + g.MsgBox('Title', 'Typical message box', 'The results of the form are a lot of data! Get ready... ', 'The button clicked was "{}"'.format(button), 'The values are', values, AutoClose=True) # example of an Asynchronous form def ChatBot(): @@ -55,9 +55,9 @@ def ChatBot(): print('Exiting the chatbot....') def main(): - SourceDestFolders() + # SourceDestFolders() Everything() - ChatBot() + # ChatBot() if __name__ == '__main__': main() diff --git a/readme.md b/readme.md index ef139cdb2..00ea65fa1 100644 --- a/readme.md +++ b/readme.md @@ -327,10 +327,8 @@ You can see in the MsgBox that the values returned are a list. Each input field # Building Custom Forms You will find it much easier to write code using PySimpleGUI is you use features that show you documentation about the API call you are making. In PyCharm 2 commands are helpful. -> Control-Q (when cursor is on function name) brings up a box with the -> function definition -> Control-P (when cursor inside function call "()") -> shows a list of parameters and their default values + Control-Q (when cursor is on function name) brings up a box with the function definition + Control-P (when cursor inside function call "()") shows a list of parameters and their default values ## Synchronous Forms The most common use of PySimpleGUI is to display and collect information from the user. The most straightforward way to do this is using a "blocking" GUI call. Execution is "blocked" while waiting for the user to close the GUI form/dialog box. @@ -343,10 +341,10 @@ NON-BLOCKING form call: ### Beginning a Form The first step is to create the form object using the desired form customization. - with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: + with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: Let's go through the options available when creating a form. - def __init__(self, title, + def __init__(self, title, DefaultElementSize=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), AutoSizeText=DEFAULT_AUTOSIZE_TEXT, Scale=(None, None), @@ -359,7 +357,7 @@ Let's go through the options available when creating a form. AutoClose=False, AutoCloseDuration=DEFAULT_AUTOCLOSE_TIME, Icon=DEFAULT_WINDOW_ICON): - + #### Sizes Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. @@ -374,35 +372,39 @@ In addition to `size` there is a `scale` option. Scale will take the Element's #### FlexForm - form-level variables overview A summary of the variables that can be changed when a FlexForm is created -> DefaultElementSize - set default size for all elements in the form -> AutoSizeText - true/false autosizing turned on / off -> Scale - set scale value for all elements -> ButtonColor - default button color (foreground, background) -> Font - font name and size for all text items -> ProgressBarColor - progress bar colors -> IsTabbedForm - true/false indicates form is a tabbed or normal form -> BorderDepth - style setting for buttons, input fields -> AutoClose - true/false indicates if form will automatically close -> AutoCloseDuration - how long in seconds before closing form -> Icon - filename for icon that's displayed on the window on taskbar + DefaultElementSize - set default size for all elements in the form + AutoSizeText - true/false autosizing turned on / off + Scale - set scale value for all elements + ButtonColor - default button color (foreground, background) + Font - font name and size for all text items + ProgressBarColor - progress bar colors + IsTabbedForm - true/false indicates form is a tabbed or normal form + BorderDepth - style setting for buttons, input fields + AutoClose - true/false indicates if form will automatically close + AutoCloseDuration - how long in seconds before closing form + Icon - filename for icon that's displayed on the window on taskbar ## Elements "Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. -> Text -> Single Line Input -> Buttons including these types: File Browse Folder Browse Non-closing return Close form -> Checkboxes -> Radio Buttons -> Multi-line Text Input -> Scroll-able Output -> Progress Bar -> Async/Non-Blocking Windows -> Tabbed forms -> Persistent Windows -> Redirect Python Output/Errors to scrolling Window -> 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Checkboxes + Radio Buttons + Multi-line Text Input + Scroll-able Output + Progress Bar + Async/Non-Blocking Windows + Tabbed forms + Persistent Windows + Redirect Python Output/Errors to scrolling Window + "Higher level" APIs (e.g. MessageBox, YesNobox, ...) ### Output Elements @@ -413,15 +415,15 @@ Building a form is simply making lists of Elements. Each list is a row in the o The code is a crude representation of the GUI, laid out in text. #### Text Element - layout = [[SG.Text('This is what a Text Element looks like')]] + layout = [[SG.Text('This is what a Text Element looks like')]] + - ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. - Text(Text, + Text(Text, Scale=(None, None), Size=(None, None), AutoSizeText=None, @@ -462,11 +464,13 @@ This Element doubles as both an input and output Element. The `DefaultText` opt Size=(None, None), AutoSizeText=None) -> DefaultText - Text to display in the text box ->EnterSubmits - Bool. If True, pressing Enter key submits form ->Scale - Element's scale ->Size - Element's size ->AutoSizeText - Bool. Change width to match size of text +. + + DefaultText - Text to display in the text box + EnterSubmits - Bool. If True, pressing Enter key submits form + Scale - Element's scale + Size - Element's size + AutoSizeText - Bool. Change width to match size of text #### Output Element Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. More on this later. @@ -477,10 +481,14 @@ Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. Output(Scale=(None, None), Size=(None, None)) +. + + Scale - How much to scale size of element + Size - Size of element (width, height) in characters ### Input Elements These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `Size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. - + #### Text Input Element layout = [[SG.InputText('Default text')]] @@ -490,23 +498,60 @@ Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. Scale=(None, None), Size=(None, None), AutoSizeText=None) +. + + DefaultText - Text initially shown in the input box + Scale - Amount size is scaled by + Size - (width, height) of element in characters + AutoSizeText - Bool. True is element should be sized to fit text + Shorthand functions that are equivalent to `InputText` are `Input` and `In` + #### Combo Element Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. layout = [[SG.InputCombo(['choice 1', 'choice 2'])]] - + ![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) - InputCombo(Values, + InputCombo(Values, Scale=(None, None), Size=(None, None), AutoSizeText=None) +. + + Values Choices to be displayed. List of strings + Scale - Amount to scale size by + Size - (width, height) of element in characters + AutoSizeText - Bool. True if size should fit the text length #### Radio Button Element Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. + layout = [[SG.Radio('My first Radio!', "RADIO1", Default=True), SG.Radio('My second radio!', "RADIO1")]] + +![radio element](https://user-images.githubusercontent.com/13696193/42705705-327b4b6c-86a2-11e8-81a7-740e57646ba8.jpg) + + Radio(Text, + GroupID, + Default=False, + Scale=(None, None), + Size=(None, None), + AutoSizeText=None, + Font=None) + +. + + Text - Text to display next to button + GroupID - Groups together multiple Radio Buttons. Can be any value + Default - Bool. Initial state + Scale - Amount to scale size of element + Size - (width, height) size of element in characters + AutoSizeText - Bool. True if should size width to fit text + Font - Font type and size for text display + + #### Checkbox Element @@ -516,30 +561,33 @@ Creates one radio button that is assigned to a group of radio buttons. Only 1 o #### Output #### UberForm -## Contributing - -A MikeTheWatchGuy production... entirely responsible for this code - -## Versioning - -1.0.9 - July 10, 2018 - Initial Release -1.0.21 - July 13, 2018 - Readme updates - - ## Code Condition -> Make it run -> Make it right -> Make it fast +## Contributing + +A MikeTheWatchGuy production... entirely responsible for this code + +## Versioning + +1.0.9 - July 10, 2018 - Initial Release +1.0.21 - July 13, 2018 - Readme updates + + ## Code Condition + + Make it run + Make it right + Make it fast It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor on hiding implementation details, naming conventions, PEP 8. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. - -## Authors - - -## License - -This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details - -## Acknowledgments - + +## Authors + + +## License + +This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details + +## Acknowledgments + * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence + + From 099f20c62847bf913116e5d3b6112c12a3d8303e Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 13 Jul 2018 16:56:04 -0400 Subject: [PATCH 023/209] More readme --- readme.md | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/readme.md b/readme.md index 74ac898ed..00ea65fa1 100644 --- a/readme.md +++ b/readme.md @@ -486,9 +486,6 @@ Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. Scale - How much to scale size of element Size - Size of element (width, height) in characters -> Scale - How much to scale size of element -> Size - Size of element (width, height) in characters - ### Input Elements These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `Size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. @@ -501,20 +498,12 @@ Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. Scale=(None, None), Size=(None, None), AutoSizeText=None) -<<<<<<< HEAD . DefaultText - Text initially shown in the input box Scale - Amount size is scaled by Size - (width, height) of element in characters AutoSizeText - Bool. True is element should be sized to fit text -======= - -> DefaultText - Text initially shown in the input box -> Scale - Amount size is scaled by -> Size - (width, height) of element in characters -> AutoSizeText - Bool. True is element should be sized to fit text ->>>>>>> caad84a674b8248c518e707c8f8cc87a7b30664e Shorthand functions that are equivalent to `InputText` are `Input` and `In` @@ -537,11 +526,6 @@ Also known as a drop-down list. Only required parameter is the list of choices. Size - (width, height) of element in characters AutoSizeText - Bool. True if size should fit the text length -> Values Choices to be displayed. List of strings -> Scale - Amount to scale size by -> Size - (width, height) of element in characters -> AutoSizeText - Bool. True if size should fit the text length - #### Radio Button Element Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. @@ -557,7 +541,6 @@ Creates one radio button that is assigned to a group of radio buttons. Only 1 o AutoSizeText=None, Font=None) -<<<<<<< HEAD . Text - Text to display next to button @@ -569,16 +552,7 @@ Creates one radio button that is assigned to a group of radio buttons. Only 1 o Font - Font type and size for text display -======= ->>>>>>> caad84a674b8248c518e707c8f8cc87a7b30664e -> Text - Text to display next to button -> GroupID - Variable to groups together multiple Radio Buttons. Can be any value -> Default - Bool. Initial state -> Scale - Amount to scale size of element -> Size - (width, height) size of element in characters -> AutoSizeText - Bool. True if should size width to fit text -> Font - Font type and size for text display #### Checkbox Element #### Spin Element From b2d144bde8923627b972dc60383bd3daf9d7ba9a Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 13 Jul 2018 20:11:50 -0400 Subject: [PATCH 024/209] More Readme --- readme.md | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 128 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index 00ea65fa1..a84428c1f 100644 --- a/readme.md +++ b/readme.md @@ -451,6 +451,9 @@ The values foreground and background can be the color names or the hex value for **AutoSizeText** A `True` value for `AutoSizeText`, when placed on any Element, indicates that the width of the Element should be shrunk do the width of the text. This is particularly useful with `Buttons` as fixed-width buttons are somewhat crude looking. The default value is `False`. You will often see this setting on FlexForm definitions. +**Shorthand functions** +The shorthand functions for `Text` are `Txt` and `T` + #### Multiline Text Element @@ -463,7 +466,6 @@ This Element doubles as both an input and output Element. The `DefaultText` opt Scale=(None, None), Size=(None, None), AutoSizeText=None) - . DefaultText - Text to display in the text box @@ -552,11 +554,135 @@ Creates one radio button that is assigned to a group of radio buttons. Only 1 o Font - Font type and size for text display +#### Checkbox Element +Checkbox elements are like Radio Button elements. They return a bool indicating whether or not they are checked. + + layout = [[SG.Checkbox('My first Checkbox!', Default=True), SG.Checkbox('My second Checkbox!')]] + +![checkbox element](https://user-images.githubusercontent.com/13696193/42717015-655d73d2-86cc-11e8-9c69-3c810f48e578.jpg) + + + Checkbox(Text, + Default=False, + Scale=(None, None), + Size=(None, None), + AutoSizeText=None, + Font=None): +. + + Text - Text to display next to checkbox + Default - Bool. Initial state + Scale - Amount to scale size of element + Size - (width, height) size of element in characters + AutoSizeText - Bool. True if should size width to fit text + Font - Font type and size for text display -#### Checkbox Element #### Spin Element +An up/down spinner control. The valid values are passed in as a list. + + layout = [[SG.Spin([i for i in range(1,11)], InitialValue=1), SG.Text('Volume level')]] + +![spin element](https://user-images.githubusercontent.com/13696193/42717231-8ddb51d4-86cd-11e8-827a-75f2237477fa.jpg) + + Spin(Values, + InitialValue=None, + Scale=(None, None), + Size=(None, None), + AutoSizeText=None, + Font=None) +. + + Values - List of valid values + InitialValue - String with initial value + Scale - Amount to scale size of element + Size - (width, height) size of element in characters + AutoSizeText - Bool. True if should size width to fit text + Font - Font type and size for text display + #### Button Element +Buttons are the most important element of all! They cause the majority of the action to happen. After all, it's a button press that will get you out of a form, whether it but Submit or Cancel, one way or another a button is involved in all forms. The only exception is to this is when the user closes the window using the "X" in the upper corner which means no button was involved. + +The Types of buttons include: +* Folder Browse +* File Browse +* Close Form +* Read Form + + + Close Form - Normal buttons like Submit, Cancel, Yes, No, etc, are "Close Form" buttons. They cause the input values to be read and then the form is closed, returning the values to the caller. + +Folder Browse - When clicked a folder browse dialog box is opened. The results of the Folder Browse dialog box are written into one of the input fields of the form. + +File Browse - Same as the Folder Browse except rather than choosing a folder, a single file is chosen. + +Read Form - This is an async form button that will read a snapshot of all of the input fields, but does not close the form after it's clicked. + +While it's possible to build forms using the Button Element directly, you should never need to do that. There are pre-made buttons and shortcuts that will make life much easier. The most basic Button element call to use is `SimpleButton` + + SimpleButton(Text, + Scale=(None, None), + Size=(None, None), + AutoSizeText=None, + ButtonColor=None, + Font=None) + +Pre-made buttons include: + + OK + Ok + Submit + Cancel + Yes + No + FileBrowse + FolderBrowse +' + layout = [[SG.OK(), SG.Cancel()]] + +![ok cancel](https://user-images.githubusercontent.com/13696193/42717733-1803f584-86d1-11e8-9223-36b782971b9f.jpg) + +The FileBrowse and FolderBrowse buttons both fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. + +The default value for `Target` is `(ThisRow, -1)`. ThisRow is a special value that tells the GUI to use the same row as the button. The Y-value of -1 means the field one value to the left of the button. For a File or Folder Browse button, the field that it fills are generally to the left of the button is most cases. + +Let's examine this form as an example: + +![button target example](https://user-images.githubusercontent.com/13696193/42718075-b4dcb61e-86d3-11e8-904c-d709dd364108.jpg) + +The `InputText` element is located at (1,0)... row 1, column 0. The `Browse` button is located at position (2,0). The Target for the button could be any of these values: + + Target = (1,0) + Target = (-1,0) +The code for the entire form could be: + + layout = [[SG.T('Source Folder')], + [SG.In()], + [SG.FolderBrowse(Target=(-1,0)), SG.OK()]] + +**Custom Buttons** +If you want to define your own button, you will generally do this with the Button Element `SimpleButton`. + +layout = [[SG.SimpleButton('My Button')]] + +![singlebutton](https://user-images.githubusercontent.com/13696193/42718281-9453deca-86d5-11e8-83c7-4b6d33720858.jpg) + +All buttons can have their text changed by changing the `ButtonText` variable. + +**File Types** +The `FileBrowse` button has an additional setting named `FileTypes`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is + + FileTypes=(("ALL Files", "*.*"),) + +This code produces a form where the Browse button only shows files of type .TXT + + layout = [[SG.In() ,SG.FileBrowse(FileTypes=(("Text Files", "*.txt"),))]] + + ***The ENTER key*** + The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. Keep this in mind when designing forms. + + + #### ProgressBar #### Output #### UberForm @@ -588,6 +714,3 @@ This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md ## Acknowledgments * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence - - - From e9cbc4856f9bf06cf640ff836388f34b78c8e546 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 13 Jul 2018 21:39:28 -0400 Subject: [PATCH 025/209] More readme --- readme.md | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 72 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index a84428c1f..1d43c4825 100644 --- a/readme.md +++ b/readme.md @@ -637,7 +637,7 @@ Pre-made buttons include: No FileBrowse FolderBrowse -' +. layout = [[SG.OK(), SG.Cancel()]] ![ok cancel](https://user-images.githubusercontent.com/13696193/42717733-1803f584-86d1-11e8-9223-36b782971b9f.jpg) @@ -681,11 +681,78 @@ This code produces a form where the Browse button only shows files of type .TXT ***The ENTER key*** The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. Keep this in mind when designing forms. +#### ProgressBar +The `ProgressBar` element is used to build custom Progress Bar forms. It is HIGHLY recommended that you use the functions that provide a complete progress meter solution for you. Progress Meters are not easy to work with because the forms have to be non-blocking and they are tricky to debug. + +The "easiest" way to get progress meters into your code is to use the `EasyProgessMeter` API. This consists of a pair of functions, `EasyProgessMeter` and `EasyProgressMeterCancel`. You can easily cancel any progress meter by calling it with the current value = max value. This will mark the meter as expired and close the window. +You've already seen EasyProgressMeter calls presented earlier in this readme. + + SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') + +If you want a bit more customization of your meter, then you can go up 1 level and use the calls to `ProgressMeter` and `ProgressMeterUpdate` + +You setup the progress meter by calling + + my_meter = ProgressMeter(Title, + MaxValue, + *args, + Orientation=None, + BarColor=DEFAULT_PROGRESS_BAR_COLOR, + ButtonColor=None, + Size=DEFAULT_PROGRESS_BAR_SIZE, + Scale=(None, None), + BorderWidth=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) +Then to update the bar within your loop + + return_code = ProgressMeterUpdate(my_meter, + Value, + *args): +Putting it all together you get this design pattern + + my_meter = SG.ProgressMeter('Meter Title', 100000, Orientation='Vert') + + for i in range(0, 100000): + SG.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') + +The final way of using a Progress Meter with PySimpleGUI is to build a custom form with a `ProgressBar` Element in the form. You will need to run your form as a non-blocking form. When you are ready to update your progress bar, you call the `UpdateBar` method for the `ProgressBar` element itself. -#### ProgressBar #### Output -#### UberForm +The Output Element is a re-direction of Stdout. Anything "printed" will be displayed in this element. + + Output(Scale=(None, None), + Size=(None, None)) + +Here's a complete solution for a chat-window using an Async form with an Output Element + + import PySimpleGUI as g + + with g.FlexForm('Chat Window', AutoSizeText=True, DefaultElementSize=(30, 2)) as form: + form.AddRow(g.Text('This is where standard out is being routed', Size=[40,1])) + form.AddRow(g.Output(Size=(80, 20))) + form.AddRow(g.Multiline(Size=(70, 5), EnterSubmits=True), g.ReadFormButton('SEND', ButtonColor=(g.YELLOWS[0], g.BLUES[0])), g.SimpleButton('EXIT', ButtonColor=(g.YELLOWS[0], g.GREENS[0]))) + + # ---===--- Loop taking in user input and printing it --- # + while True: + (button, value) = form.Read() + if button == 'SEND': + print(value) + else: + print('Exiting the form now') + break + + +#### Tabbed Forms +Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format + + results = ShowTabbedForm('Title for the form', + (form,layout,'Tab 1 label'), + (form2,layout2, 'Tab 2 label')) + +Each of the tabs of the form is in fact a form. The same steps are taken to create the form as before. A `FlexForm` is created, then rows are filled with Elements, and finally the form is shown. When calling `ShowTabbedForm`, each form is passed in as a tuple. The tuple has the format: `(the form, the rows, a label shown on the tab)` + +## Asynchronous (Non-Blocking) Forms + ## Contributing @@ -714,3 +781,5 @@ This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md ## Acknowledgments * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence + + From 338bf78b5474d62d6e279a803cff1b0c0b34cb58 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 13 Jul 2018 21:43:01 -0400 Subject: [PATCH 026/209] Renamed Text to ButtonText Fixed up the API naming a little to be more clear when it came to button text. --- PySimpleGUI.py | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 89464f28f..28469b3c2 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -243,7 +243,7 @@ def __del__(self): class Spin(Element): # Values = None # TKSpinBox = None - def __init__(self, Values, Scale=(None, None), Size=(None, None), AutoSizeText=None, Font=None, InitialValue=None): + def __init__(self, Values, InitialValue=None, Scale=(None, None), Size=(None, None), AutoSizeText=None, Font=None): self.Values = Values self.DefaultValue = InitialValue self.TKSpinBox = None @@ -288,6 +288,7 @@ def __init__(self, Text, Scale=(None, None), Size=(None, None), AutoSizeText=Non self.DisplayText = Text self.TextColor = TextColor if TextColor else 'black' # self.Font = Font if Font else DEFAULT_FONT + # i=1/0 super().__init__(TEXT, Scale, Size, AutoSizeText, Font=Font if Font else DEFAULT_FONT) return @@ -409,12 +410,12 @@ def __del__(self): # Button Class # # ---------------------------------------------------------------------- # class Button(Element): - def __init__(self, ButtonType=CLOSES_WIN, Target=(None, None), Text ='', FileTypes=(("ALL Files", "*.*"),), Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None, Font=None): + def __init__(self, ButtonType=CLOSES_WIN, Target=(None, None), ButtonText='', FileTypes=(("ALL Files", "*.*"),), Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None, Font=None): self.BType = ButtonType self.FileTypes = FileTypes self.TKButton = None self.Target = Target - self.Text = Text + self.ButtonText = ButtonText self.ButtonColor = ButtonColor if ButtonColor else DEFAULT_BUTTON_COLOR self.UserData = None super().__init__(BUTTON, Scale, Size, AutoSizeText, Font=Font) @@ -432,6 +433,8 @@ def ButtonCallBack(self): target[1] = self.Position[1] + target[1] strvar = None if target[0] != None: + if target[0] < 0: + target = [self.Position[0] + target[0], target[1]] target_element = self.ParentForm.GetElementAtLocation(target) try: strvar = target_element.TKStringVar @@ -751,46 +754,46 @@ def T(DisplayText, Scale=(None, None), Size=(None, None), AutoSizeText=None, Fon return Text(DisplayText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, Font=Font, TextColor=TextColor) # ------------------------- FOLDER BROWSE Element lazy function ------------------------- # -def FolderBrowse(Target=(ThisRow, -1), DisplayText='Browse', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None): - return Button(BROWSE_FOLDER, Target=Target, Text=DisplayText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) +def FolderBrowse(Target=(ThisRow, -1), ButtonText='Browse', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None): + return Button(BROWSE_FOLDER, Target=Target, ButtonText=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) # ------------------------- FILE BROWSE Element lazy function ------------------------- # def FileBrowse(Target=(ThisRow, -1), FileTypes=(("ALL Files", "*.*"),),ButtonText='Browse',Scale=(None, None),Size=(None, None), AutoSizeText=None, ButtonColor=None): - return Button(BROWSE_FILE, Target, Text=ButtonText, FileTypes=FileTypes, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) + return Button(BROWSE_FILE, Target, ButtonText=ButtonText, FileTypes=FileTypes, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) # ------------------------- SUBMIT BUTTON Element lazy function ------------------------- # def Submit(ButtonText='Submit', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None): - return Button(CLOSES_WIN, Text=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) + return Button(CLOSES_WIN, ButtonText=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) # ------------------------- OK BUTTON Element lazy function ------------------------- # def OK(ButtonText='OK', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None): - return Button(CLOSES_WIN, Text=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) + return Button(CLOSES_WIN, ButtonText=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) # ------------------------- YES BUTTON Element lazy function ------------------------- # def Ok(ButtonText='Ok', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None): - return Button(CLOSES_WIN, Text=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) + return Button(CLOSES_WIN, ButtonText=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) # ------------------------- CANCEL BUTTON Element lazy function ------------------------- # def Cancel(ButtonText='Cancel', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None, Font=None): - return Button(CLOSES_WIN, Text=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor, Font=Font) + return Button(CLOSES_WIN, ButtonText=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor, Font=Font) # ------------------------- YES BUTTON Element lazy function ------------------------- # def Yes(ButtonText='Yes', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None): - return Button(CLOSES_WIN, Text=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) + return Button(CLOSES_WIN, ButtonText=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) # ------------------------- NO BUTTON Element lazy function ------------------------- # def No(ButtonText='No', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None): - return Button(CLOSES_WIN, Text=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) + return Button(CLOSES_WIN, ButtonText=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) # ------------------------- GENERIC BUTTON Element lazy function ------------------------- # # this is the only button that REQUIRES button text field -def SimpleButton(Text, Scale=(None, None),Size=(None, None), AutoSizeText=None, ButtonColor=None, Font=None): - return Button(CLOSES_WIN, Text=Text, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor, Font=Font) +def SimpleButton(ButtonText, Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None, Font=None): + return Button(CLOSES_WIN, ButtonText=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor, Font=Font) # ------------------------- GENERIC BUTTON Element lazy function ------------------------- # # this is the only button that REQUIRES button text field def ReadFormButton(ButtonText, Scale=(None, None),Size=(None, None), AutoSizeText=None, ButtonColor=None, Font=None): - return Button(READ_FORM, Text=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor, Font=Font) + return Button(READ_FORM, ButtonText=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor, Font=Font) #------------------------------------------------------------------------------------------------------# # ------- FUNCTION InitializeResults. Sets up form results matrix ------- # @@ -875,7 +878,7 @@ def BuildResults(form): input_values.append(value) elif element.Type == BUTTON: if results[row_num][col_num] is True: - button_pressed_text = element.Text + button_pressed_text = element.ButtonText results[row_num][col_num] = False elif element.Type == INPUT_COMBO: value=element.TKStringVar.get() @@ -979,7 +982,7 @@ def ConvertFlexToTK(MyFlexForm): # ------------------------- BUTTON element ------------------------- # elif element_type == BUTTON: element.Location = (row_num, col_num) - btext = element.Text + btext = element.ButtonText btype = element.BType if auto_size_text is False: width=element_size[0] else: width = 0 From d2f538cd82e5ecef067f20d2118f0ffc371096fd Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 14 Jul 2018 13:19:51 -0400 Subject: [PATCH 027/209] HowDoI demo checkin An EXCELLENT program... I use it daily to find answers of all types --- Demo HowDoI.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Demo HowDoI.py diff --git a/Demo HowDoI.py b/Demo HowDoI.py new file mode 100644 index 000000000..2fb20c989 --- /dev/null +++ b/Demo HowDoI.py @@ -0,0 +1,55 @@ +import PySimpleGUI as SG +import subprocess + +# CHANGE THIS LINE OF CODE! Point it to the howdoi.py file that is in the howdoi code you download from github +HOW_DO_I_COMMAND = 'python C:\\Python\\PycharmProjects\\GitHub\\howdoi\\howdoi\\howdoi.py' +# 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 FlexForm ------- # + form = SG.FlexForm('How Do I ??', AutoSizeText=True, DefaultElementSize=(30, 2), Icon=DEFAULT_ICON) + form.AddRow(SG.Text('Ask and your answer will appear here....', Size=(40, 1))) + form.AddRow(SG.Output(Size=(90, 20))) + form.AddRow(SG.Multiline(Size=(90, 5), EnterSubmits=True), + SG.ReadFormButton('SEND', ButtonColor=(SG.YELLOWS[0], SG.BLUES[0])), + SG.SimpleButton('EXIT', ButtonColor=(SG.YELLOWS[0], SG.GREENS[0]))) + + # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # + while True: + (button, value) = form.Read() + if button == 'SEND': + command = value[0][:-1] + QueryHowDoI(command) + else: + print(button, 'pressed') + break + + print('Exiting the app now') + exit(69) + +def QueryHowDoI(Query): + ''' + 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 + t = subprocess.Popen(howdoi_command + ' '+ Query, stdout=subprocess.PIPE) + (output, err) = t.communicate() + print('You asked: '+ Query) + print('_______________________________________') + print(output.decode("utf-8") ) + exit_code = t.wait() + +if __name__ == '__main__': + HowDoI() + From a77dc1c724c7980b94050c6549f402336c750de7 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sun, 15 Jul 2018 19:21:06 -0400 Subject: [PATCH 028/209] Fixed message box text width, renamed Display Hash, added Duplicate file finder FINALLY got the message box text width sizing correct. Required change to Text Elements so watch out for possible side effects. Added a new Duplicate File Finder demo program that uses an input form an a progress meter --- ...sh1and256.py => Demo DisplayHash1and256.py | 26 ++++++++- Demo DuplicateFileFinder.py | 58 +++++++++++++++++++ PySimpleGUI.py | 15 +++-- 3 files changed, 91 insertions(+), 8 deletions(-) rename DemoDisplayHash1and256.py => Demo DisplayHash1and256.py (80%) create mode 100644 Demo DuplicateFileFinder.py diff --git a/DemoDisplayHash1and256.py b/Demo DisplayHash1and256.py similarity index 80% rename from DemoDisplayHash1and256.py rename to Demo DisplayHash1and256.py index 1aa0f902f..fa4545cc5 100644 --- a/DemoDisplayHash1and256.py +++ b/Demo DisplayHash1and256.py @@ -66,6 +66,25 @@ def HashManuallyBuiltGUI(): else: SG.MsgBoxError('Display A Hash in PySimpleGUI', '* Cancelled *') +def HashManuallyBuiltGUINonContext(): + # ------- Form design ------- # + form = SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + [SG.InputText(), SG.FileBrowse()], + [SG.Submit(), SG.Cancel()]] + (button, (source_filename, )) = form.LayoutAndShow(form_rows) + + if button == 'Submit': + if source_filename != '': + hash_sha1 = compute_sha1_hash_for_file(source_filename).upper() + hash_sha256 = compute_sha256_hash_for_file(source_filename).upper() + SG.MsgBox( 'Display A Hash in PySimpleGUI', 'The SHA-1 Hash for the file\n', source_filename, hash_sha1, 'SHA-256 is', hash_sha256, LineWidth=75) + else: SG.MsgBoxError('Display A Hash in PySimpleGUI', 'Illegal filename') + else: + SG.MsgBoxError('Display A Hash in PySimpleGUI', '* Cancelled *') + + + # ---------------------------------------------------------------------- # # Compute and display SHA1 hash # @@ -80,7 +99,7 @@ def HashMostCompactGUI(): # ------- OUTPUT GUI results portion ------- # if rc == True: - hash = compute_sha1_hash_for_file(source_filename).upper() + hash = compute_sha1_hash_for_file(source_filename) SG.MsgBox('Display Hash - Compact GUI', 'The SHA-1 Hash for the file\n', source_filename, hash) else: SG.MsgBox('Display Hash - Compact GUI', '* Cancelled *') @@ -90,8 +109,9 @@ def HashMostCompactGUI(): # Our main calls two GUIs that act identically but use different calls # # ---------------------------------------------------------------------- # def main(): - # HashMostCompactGUI() - HashManuallyBuiltGUI() + HashManuallyBuiltGUINonContext() + HashMostCompactGUI() + # ====____====____==== Pseudo-MAIN program ====____====____==== # # This is our main-alike piece of code # diff --git a/Demo DuplicateFileFinder.py b/Demo DuplicateFileFinder.py new file mode 100644 index 000000000..b32f8cf12 --- /dev/null +++ b/Demo DuplicateFileFinder.py @@ -0,0 +1,58 @@ +import hashlib +import os +import win32clipboard +import PySimpleGUI as gg + + +# ====____====____==== FUNCTION DeDuplicate_folder(path) ====____====____==== # +# Function to de-duplicate the folder passed in # +# --------------------------------------------------------------------------- # +def FindDuplicatesFilesInFolder(path): + shatab = [] + total = 0 + small = (1024) + small_count, dup_count, error_count = 0,0,0 + pngdir = path + if not os.path.exists(path): + gg.MsgBox('De-Dupe', '** Folder doesn\'t exist***', path) + return + pngfiles = os.listdir(pngdir) + total_files = len(pngfiles) + not_cancelled = True + for idx, f in enumerate(pngfiles): + if not gg.EasyProgressMeter('Counting Duplicates', idx+1, total_files, 'Counting Duplicate Files'): + break + total += 1 + fname = os.path.join(pngdir, f) + if os.path.isdir(fname): + continue + x = open(fname, "rb").read() + + m = hashlib.sha256() + m.update(x) + f_sha = m.digest() + if f_sha in shatab: + # os.remove(fname) + dup_count += 1 + continue + shatab.append(f_sha) + + msg = f'{total} Files processed\n'\ + f'{dup_count} Duplicates found\n' + gg.MsgBox('Duplicate Finder Ended', msg) + +# ====____====____==== Pseudo-MAIN program ====____====____==== # +# This is our main-alike piece of code # +# + Starts up the GUI # +# + Gets values from GUI # +# + Runs DeDupe_folder based on GUI inputs # +# ------------------------------------------------------------- # +if __name__ == '__main__': + + source_folder = None + rc, source_folder = gg.GetPathBox('DeDuplicate a Folder\'s image files', 'Enter path to folder you wish to find duplicates in') + if rc is True and source_folder is not None: + FindDuplicatesFilesInFolder(source_folder) + else: + gg.MsgBox('Cancelling', '*** Cancelling ***') + exit(0) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 28469b3c2..1e45abc48 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -18,7 +18,7 @@ DEFAULT_AUTOSIZE_TEXT = False DEFAULT_FONT = ("Helvetica", 10) -DEFAULT_BORDER_WIDTH = 7 +DEFAULT_BORDER_WIDTH = 6 DEFAULT_AUTOCLOSE_TIME = 3 # time in seconds to show an autoclose form MAX_SCROLLED_TEXT_BOX_HEIGHT = 50 #################### COLOR STUFF #################### @@ -973,11 +973,13 @@ def ConvertFlexToTK(MyFlexForm): stringvar = tk.StringVar() element.TKStringVar = stringvar stringvar.set(display_text) + if auto_size_text: + width = 0 tktext_label = tk.Label(tk_row_frame,anchor=tk.NW, textvariable=stringvar, width=width, height=height, justify=tk.LEFT, bd=border_depth, fg=element.TextColor) # tktext_label = tk.Label(tk_row_frame,anchor=tk.NW, text=display_text, width=width, height=height, justify=tk.LEFT, bd=border_depth) # Set wrap-length for text (in PIXELS) == PAIN IN THE ASS wraplen = tktext_label.winfo_reqwidth() # width of widget in Pixels - tktext_label.configure( anchor=tk.NW, font=font, wraplen=wraplen*2 ) # set wrap to width of widget + tktext_label.configure(anchor=tk.NW, font=font, wraplen=wraplen*2 ) # set wrap to width of widget tktext_label.pack(side=tk.LEFT) # ------------------------- BUTTON element ------------------------- # elif element_type == BUTTON: @@ -1240,20 +1242,23 @@ def MsgBox(*args, ButtonColor=None, ButtonType=MSG_BOX_OK, AutoClose=False, Aut args_to_print = [''] else: args_to_print = args - with FlexForm(args_to_print[0], AutoSizeText=True, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Icon=Icon, Font=Font) as form: + with FlexForm(args_to_print[0], AutoSizeText=True, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Icon=Icon, Font=Font) as form: max_line_total, total_lines = 0,0 for message in args_to_print: # fancy code to check if string and convert if not is not need. Just always convert to string :-) # if not isinstance(message, str): message = str(message) message = str(message) - message_wrapped = textwrap.fill(message, LineWidth) + if message.count('\n'): + message_wrapped = message + else: + message_wrapped = textwrap.fill(message, LineWidth) message_wrapped_lines = message_wrapped.count('\n')+1 longest_line_len = max([len(l) for l in message.split('\n')]) width_used = min(longest_line_len, LineWidth) max_line_total = max(max_line_total, width_used) # height = _GetNumLinesNeeded(message, width_used) height = message_wrapped_lines - form.AddRow(Text(message_wrapped, Size=(width_used, height), AutoSizeText=True),) + form.AddRow(Text(message_wrapped, AutoSizeText=True)) total_lines += height pad = max_line_total-15 if max_line_total > 15 else 1 From c3ee62f29f31d9883a6cec969ba4641dd696008a Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sun, 15 Jul 2018 20:13:41 -0400 Subject: [PATCH 029/209] Readme update --- readme.md | 170 +++++++++++++++++++++++++++++------------------------- 1 file changed, 92 insertions(+), 78 deletions(-) diff --git a/readme.md b/readme.md index 1d43c4825..9f139bf7b 100644 --- a/readme.md +++ b/readme.md @@ -66,10 +66,10 @@ Should run on all Python platforms that have tkinter running on them. Has been ### Using -To us in your code, simply import.... - `import PySimpleGUI as SG` +To use in your code, simply import.... + `import PySimpleGUI as SG` -Then use either "high level" API calls or build your own forms. +Then use either "high level" API calls or build your own forms. SG.MsgBox('This is my first message box') ![simple msgbox](https://user-images.githubusercontent.com/13696193/42597824-1749b160-8528-11e8-9114-374bf9731b30.jpg) @@ -77,65 +77,65 @@ Then use either "high level" API calls or build your own forms. Yes, it's just that easy to have a window appear on the screen using Python. ## APIs - -PySimpleGUI can be broken down into 2 types of API's: - * High Level single call functions - * Custom form functions - + +PySimpleGUI can be broken down into 2 types of API's: + * High Level single call functions + * Custom form functions + ### Python Language Features There are a couple of Python language features that PySimpleGUI utilizes heavily that should be understood first... - * Variable number of arguments to a function call + * Variable number of arguments to a function call * Optional parameters to a function call - + #### Variable Number of Arguments The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. - + SG.MsgBox('Variable number of parameters example', my_variable, second_variable, "etc") Each new item begins on a new line in the Message Box ![variablearguments](https://user-images.githubusercontent.com/13696193/42598375-022bc51e-852a-11e8-8f77-4d664ae1a560.jpg) - + #### Optional Parameters to a Function Call - + This feature of the Python language is utilized ***heavily*** as a method of customizing forms and part of forms. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. -Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't have to be specified on each and every call. +Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't have to be specified on each and every call. - def MsgBox(*args, - ButtonColor=None, - ButtonType=MSG_BOX_OK, - AutoClose=False, - AutoCloseDuration=None, - Icon=DEFAULT_WINDOW_ICON, + def MsgBox(*args, + ButtonColor=None, + ButtonType=MSG_BOX_OK, + AutoClose=False, + AutoCloseDuration=None, + Icon=DEFAULT_WINDOW_ICON, LineWidth=MESSAGE_BOX_LINE_WIDTH, Font=None): If the caller wanted to change the button color to be black on yellow, the call would look something like this: - SG.MsgBox('This box has a custom button color', + SG.MsgBox('This box has a custom button color', ButtonColor=('black', 'yellow')) ![custombuttoncolor](https://user-images.githubusercontent.com/13696193/42599212-84f3fe2e-852c-11e8-8a60-4aad669a1fd6.jpg) -### High Level API Calls +### High Level API Calls + +The classic "input a value, print result" example. +Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. +This code prompts user to input a line of text and then displays that text in a messages box: + + import PySimpleGUI_local as SG + + rc = SG.GetTextBox('Title', 'Please input something') + SG.MsgBox('Results', 'The value returned from GetTextBox', rc) + +![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) + +![MsgBox](https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg) -The classic "input a value, print result" example. -Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. -This code prompts user to input a line of text and then displays that text in a messages box: - - import PySimpleGUI_local as SG - - rc = SG.GetTextBox('Title', 'Please input something') - SG.MsgBox('Results', 'The value returned from GetTextBox', rc) - -![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) - -![MsgBox](https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg) - #### Message Boxes In addition to MsgBox, you'll find a several API calls that are shortcuts to common messages boxes. You can achieve similar results by calling MsgBox with the correct parameters. @@ -144,7 +144,7 @@ The differences tend to be the number and types of buttons. Here are the calls import PySimpleGUI as SG `SG.MsgBoxOK('This is an OK MsgBox')` - + ![msgboxok](https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg) SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') @@ -168,13 +168,13 @@ The differences tend to be the number and types of buttons. Here are the calls ![scrolledtextbox](https://user-images.githubusercontent.com/13696193/42600800-a44f4562-8531-11e8-8c21-51dd70316879.jpg) -Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. +Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. #### High Level User Input There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. If you need only 1 value, then perhaps one of these high level functions will work. - GetTextBox - - GetFileBox + - GetFileBox - GetFolderBox `submit_clicked, value = SG.GetTextBox('Title', 'Please enter anything')` @@ -206,7 +206,7 @@ We all have loops in our code. 'Isn't it joyful waiting, watching a counter scr Here's the one-line Progress Meter in action! - for i in range(1,10000): + for i in range(1,10000): SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') That line of code resulted in this window popping up and updating. @@ -214,7 +214,7 @@ That line of code resulted in this window popping up and updating. ![progress meter 5](https://user-images.githubusercontent.com/13696193/42696912-a5c958b8-8687-11e8-9a7d-a390a465407a.jpg) A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. -With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. +With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. if not SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message'): break @@ -226,10 +226,10 @@ It's both not enjoyable nor helpful to immediately jump into tweaking each and e ## COPY THIS DESIGN PATTERN! - with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], - [SG.InputText(), SG.FileBrowse()], - [SG.Submit(), SG.Cancel()]] + with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + [SG.InputText(), SG.FileBrowse()], + [SG.Submit(), SG.Cancel()]] (button, (source_filename, )) = form.LayoutAndShow(form_rows) This context manager contains all of the code needed to specify, show and retrieve results for this form: @@ -237,23 +237,23 @@ This context manager contains all of the code needed to specify, show and retrie It's important to use the "with" context manager. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. -You will use this design pattern or code template for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. +You will use this design pattern or code template for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. > Copy, Paste, Run. -PySimpleGUI's goal with the API is to be easy on the programmer. An attempt was made to make the program's code visually match the window on the screen. The way this is done is that a GUI is broken up into "Rows". Then each row is broke up into "Elements" or "Widgets". Each element is specified by names such as Text, Button, Checkbox, etc. +PySimpleGUI's goal with the API is to be easy on the programmer. An attempt was made to make the program's code visually match the window on the screen. The way this is done is that a GUI is broken up into "Rows". Then each row is broke up into "Elements" or "Widgets". Each element is specified by names such as Text, Button, Checkbox, etc. Some elements are shortcuts, again meant to make it easy on the programmer. Rather than writing a `Button`, with name = "Submit", etc, the caller simply writes `Submit`. Going through each line of code - with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: -This creates a new form, storing it in the variable `form`. + with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: +This creates a new form, storing it in the variable `form`. - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. - [SG.InputText(), SG.FileBrowse()], + [SG.InputText(), SG.FileBrowse()], Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. [SG.Submit(), SG.Cancel()]] @@ -265,42 +265,42 @@ This is the code that **displays** the form, collects the information and return ## Return values - Return information from FlexForm, SG's primary form builder interface, is in this format: - - (button, (value1, value2, ...)) - -Don't forget all those ()'s of your values won't be coreectly assigned. - -If you have a SINGLE value being returned, it is written this way: - + Return information from FlexForm, SG's primary form builder interface, is in this format: + + (button, (value1, value2, ...)) + +Don't forget all those ()'s of your values won't be coreectly assigned. + +If you have a SINGLE value being returned, it is written this way: + (button, (value1,)) = form.LayoutAndShow(form_rows) Another way of parsing the return values is to store the list of values into a variable that is then referenced. - (button, (value)) = form.LayoutAndShow(form_rows) + (button, (value)) = form.LayoutAndShow(form_rows) value1 = values[0] value2 = values[1] ... - + ## All Widgets / Elements This code utilizes as many of the elements in one form as possible. - with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: - layout = [[Text('Here they all are!', Size=(30,1), Font=("Helvetica", 25), TextColor='red')], - [Text('Here is some text with font sizing', Font=("Helvetica", 15))], - [InputText()], - [Checkbox('My first checkbox!'), Checkbox('My second checkbox!', Default=True)], - [Radio('My first Radio!', "RADIO1", Default=True), Radio('My second checkbox!', "RADIO1")], - [Multiline(DefaultText='This is the DEFAULT text should you decide not to type anything', Scale=(2, 10))], - [InputCombo(['choice 1', 'choice 2'], Size=(20, 3))], - [Text('_' * 90, Size=(60, 1))], - [Text('Choose Source and Destination Folders', Size=(35,1))], - [Text('Source Folder', Size=(15, 1), AutoSizeText=False), InputText('Source'), FolderBrowse()], - [Text('Destination Folder', Size=(15, 1), AutoSizeText=False), InputText('Dest'), FolderBrowse()], - [SimpleButton('Your Button with any text you want')], - [SimpleButton('Big Text', Size=(12,1), Font=("Helvetica", 20))], - [Submit(), Cancel()]] - + with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: + layout = [[Text('Here they all are!', Size=(30,1), Font=("Helvetica", 25), TextColor='red')], + [Text('Here is some text with font sizing', Font=("Helvetica", 15))], + [InputText()], + [Checkbox('My first checkbox!'), Checkbox('My second checkbox!', Default=True)], + [Radio('My first Radio!', "RADIO1", Default=True), Radio('My second checkbox!', "RADIO1")], + [Multiline(DefaultText='This is the DEFAULT text should you decide not to type anything', Scale=(2, 10))], + [InputCombo(['choice 1', 'choice 2'], Size=(20, 3))], + [Text('_' * 90, Size=(60, 1))], + [Text('Choose Source and Destination Folders', Size=(35,1))], + [Text('Source Folder', Size=(15, 1), AutoSizeText=False), InputText('Source'), FolderBrowse()], + [Text('Destination Folder', Size=(15, 1), AutoSizeText=False), InputText('Dest'), FolderBrowse()], + [SimpleButton('Your Button with any text you want')], + [SimpleButton('Big Text', Size=(12,1), Font=("Helvetica", 20))], + [Submit(), Cancel()]] + (button, (values)) = form.LayoutAndShow(layout) @@ -320,7 +320,7 @@ One important aspect of this example is the return codes: (button, (values)) = form.LayoutAndShow(layout) The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. -You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. +You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. @@ -753,10 +753,24 @@ Each of the tabs of the form is in fact a form. The same steps are taken to cre ## Asynchronous (Non-Blocking) Forms +## Sample Applications +Use the example programs as a starting basis for your GUI. Copy, paste, modify and run! The demo files are: +`Demo DisplayHash1and256.py` - Demonstrates using High Level API calls to get a filename +`Demo DupliucateFileFinder.py` - Demonstrates High Level API to get a folder & Easy Progress Meter to show progress of the file scanning +`Demo Recipes.py` - Three sample forms including an asynchronous form +`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. + +## Fun Stuff + +## Known Issues +While not an "issue" this is a *stern warning* +**Do not attempt** to call `PySimpleGUI` from multiple threads! It's `tkinter` based and `tkinter` has issues with multiple threads + +**Progress Meters** - the visual graphic portion of the meter may be off. May return to the native tkinter progress meter solution in the future. Right now a "custom" progress meter is used. On the bright side, the statistics shown are extremely accurate and can tell you something about the performance of your code. ## Contributing -A MikeTheWatchGuy production... entirely responsible for this code +A MikeTheWatchGuy production... entirely responsible for this code.... unless it causes you trouble in which case I'm not at all responsible. ## Versioning From 0ec43ac11264815f4240e1d221994e921e205cd2 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 16 Jul 2018 14:52:16 -0400 Subject: [PATCH 030/209] Renamed ALL oprtional parameters Switched from CamelCase to all_lower_case --- Demo DisplayHash1and256.py | 8 +- Demo DuplicateFileFinder.py | 10 +- Demo High Level APIs.py | 3 +- Demo HowDoI.py | 21 +- Demo Recipes.py | 48 ++-- PySimpleGUI.py | 557 ++++++++++++++++++------------------ readme.md | 420 +++++++++++++-------------- 7 files changed, 532 insertions(+), 535 deletions(-) diff --git a/Demo DisplayHash1and256.py b/Demo DisplayHash1and256.py index fa4545cc5..dbc47afcc 100644 --- a/Demo DisplayHash1and256.py +++ b/Demo DisplayHash1and256.py @@ -51,7 +51,7 @@ def compute_sha256_hash_for_file(filename): # ---------------------------------------------------------------------- # def HashManuallyBuiltGUI(): # ------- Form design ------- # - with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: + with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], [SG.InputText(), SG.FileBrowse()], [SG.Submit(), SG.Cancel()]] @@ -61,14 +61,14 @@ def HashManuallyBuiltGUI(): if source_filename != '': hash_sha1 = compute_sha1_hash_for_file(source_filename).upper() hash_sha256 = compute_sha256_hash_for_file(source_filename).upper() - SG.MsgBox( 'Display A Hash in PySimpleGUI', 'The SHA-1 Hash for the file\n', source_filename, hash_sha1, 'SHA-256 is', hash_sha256, LineWidth=75) + SG.MsgBox( 'Display A Hash in PySimpleGUI', 'The SHA-1 Hash for the file\n', source_filename, hash_sha1, 'SHA-256 is', hash_sha256, line_width=75) else: SG.MsgBoxError('Display A Hash in PySimpleGUI', 'Illegal filename') else: SG.MsgBoxError('Display A Hash in PySimpleGUI', '* Cancelled *') def HashManuallyBuiltGUINonContext(): # ------- Form design ------- # - form = SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) + form = SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], [SG.InputText(), SG.FileBrowse()], [SG.Submit(), SG.Cancel()]] @@ -78,7 +78,7 @@ def HashManuallyBuiltGUINonContext(): if source_filename != '': hash_sha1 = compute_sha1_hash_for_file(source_filename).upper() hash_sha256 = compute_sha256_hash_for_file(source_filename).upper() - SG.MsgBox( 'Display A Hash in PySimpleGUI', 'The SHA-1 Hash for the file\n', source_filename, hash_sha1, 'SHA-256 is', hash_sha256, LineWidth=75) + SG.MsgBox( 'Display A Hash in PySimpleGUI', 'The SHA-1 Hash for the file\n', source_filename, hash_sha1, 'SHA-256 is', hash_sha256, line_width=75) else: SG.MsgBoxError('Display A Hash in PySimpleGUI', 'Illegal filename') else: SG.MsgBoxError('Display A Hash in PySimpleGUI', '* Cancelled *') diff --git a/Demo DuplicateFileFinder.py b/Demo DuplicateFileFinder.py index b32f8cf12..49b061bbc 100644 --- a/Demo DuplicateFileFinder.py +++ b/Demo DuplicateFileFinder.py @@ -1,6 +1,5 @@ import hashlib import os -import win32clipboard import PySimpleGUI as gg @@ -10,15 +9,13 @@ def FindDuplicatesFilesInFolder(path): shatab = [] total = 0 - small = (1024) small_count, dup_count, error_count = 0,0,0 pngdir = path if not os.path.exists(path): - gg.MsgBox('De-Dupe', '** Folder doesn\'t exist***', path) + gg.MsgBox('Duplicate Finder', '** Folder doesn\'t exist***', path) return pngfiles = os.listdir(pngdir) total_files = len(pngfiles) - not_cancelled = True for idx, f in enumerate(pngfiles): if not gg.EasyProgressMeter('Counting Duplicates', idx+1, total_files, 'Counting Duplicate Files'): break @@ -32,6 +29,7 @@ def FindDuplicatesFilesInFolder(path): m.update(x) f_sha = m.digest() if f_sha in shatab: + # uncomment next line to remove duplicate files # os.remove(fname) dup_count += 1 continue @@ -50,9 +48,9 @@ def FindDuplicatesFilesInFolder(path): if __name__ == '__main__': source_folder = None - rc, source_folder = gg.GetPathBox('DeDuplicate a Folder\'s image files', 'Enter path to folder you wish to find duplicates in') + rc, source_folder = gg.GetPathBox('Duplicate Finder - Count number of duplicate files', 'Enter path to folder you wish to find duplicates in') if rc is True and source_folder is not None: FindDuplicatesFilesInFolder(source_folder) else: - gg.MsgBox('Cancelling', '*** Cancelling ***') + gg.MsgBoxCancel('Cancelling', '*** Cancelling ***') exit(0) diff --git a/Demo High Level APIs.py b/Demo High Level APIs.py index 2f9c3bec7..92bd53edc 100644 --- a/Demo High Level APIs.py +++ b/Demo High Level APIs.py @@ -1,5 +1,6 @@ import PySimpleGUI as sg +sg.MsgBox('Title', 'My first message... Is the length the same?') rc, number = sg.GetTextBox('Title goes here', 'Enter a number') if not rc: sg.MsgBoxError('You have cancelled') @@ -7,4 +8,4 @@ msg = '\n'.join([f'{i}' for i in range(0,int(number))]) -sg.ScrolledTextBox(msg, Height=10) \ No newline at end of file +sg.ScrolledTextBox(msg, height=10) \ No newline at end of file diff --git a/Demo HowDoI.py b/Demo HowDoI.py index 2fb20c989..3565b1a67 100644 --- a/Demo HowDoI.py +++ b/Demo HowDoI.py @@ -15,24 +15,21 @@ def HowDoI(): :return: never returns ''' # ------- Make a new FlexForm ------- # - form = SG.FlexForm('How Do I ??', AutoSizeText=True, DefaultElementSize=(30, 2), Icon=DEFAULT_ICON) - form.AddRow(SG.Text('Ask and your answer will appear here....', Size=(40, 1))) - form.AddRow(SG.Output(Size=(90, 20))) - form.AddRow(SG.Multiline(Size=(90, 5), EnterSubmits=True), - SG.ReadFormButton('SEND', ButtonColor=(SG.YELLOWS[0], SG.BLUES[0])), - SG.SimpleButton('EXIT', ButtonColor=(SG.YELLOWS[0], SG.GREENS[0]))) + form = SG.FlexForm('How Do I ??', auto_size_text=True, default_element_size=(30, 2), icon=DEFAULT_ICON) + form.AddRow(SG.Text('Ask and your answer will appear here....', size=(40, 1))) + form.AddRow(SG.Output(size=(90, 20))) + form.AddRow(SG.Multiline(size=(90, 5), enter_submits=True), + SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), + SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))) - # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # + # ---===--- Loop taking in user input and using it to query HowDoI --- # while True: (button, value) = form.Read() if button == 'SEND': - command = value[0][:-1] - QueryHowDoI(command) + QueryHowDoI(value[0][:-1]) # send string without carriage return on end else: - print(button, 'pressed') - break + break # exit button clicked - print('Exiting the app now') exit(69) def QueryHowDoI(Query): diff --git a/Demo Recipes.py b/Demo Recipes.py index 890454c9a..170eea731 100644 --- a/Demo Recipes.py +++ b/Demo Recipes.py @@ -1,12 +1,12 @@ -import PySimpleGUI_local as g +import PySimpleGUI as g def SourceDestFolders(): - with g.FlexForm('Demo Source / Destination Folders', AutoSizeText=True) as form: + with g.FlexForm('Demo Source / Destination Folders', auto_size_text=True) as form: form_rows = [[g.Text('Enter the Source and Destination folders')], [g.Text('Choose Source and Destination Folders')], - [g.Text('Source Folder', Size=(15, 1), AutoSizeText=False), g.InputText('Source'), + [g.Text('Source Folder', size=(15, 1), auto_size_text=False), g.InputText('Source'), g.FolderBrowse()], - [g.Text('Destination Folder', Size=(15, 1), AutoSizeText=False), g.InputText('Dest'), + [g.Text('Destination Folder', size=(15, 1), auto_size_text=False), g.InputText('Dest'), g.FolderBrowse()], [g.Submit(), g.Cancel()]] @@ -18,46 +18,44 @@ def SourceDestFolders(): g.MsgBoxError('Cancelled', 'User Cancelled') def Everything(): - with g.FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(40,1)) as form: - layout = [[g.Text('All graphic widgets in one form!', Size=(30,1), Font=("Helvetica", 25), TextColor='blue')], + with g.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40,1)) as form: + layout = [[g.Text('All graphic widgets in one form!', size=(30,1), font=("Helvetica", 25), text_color='blue')], [g.Text('Here is some text.... and a place to enter text')], [g.InputText()], - [g.Checkbox('My first checkbox!'), g.Checkbox('My second checkbox!', Default=True)], - [g.Radio('My first Radio!', "RADIO1", Default=True), g.Radio('My second Radio!', "RADIO1")], - [g.Multiline(DefaultText='This is the DEFAULT Text should you decide not to type anything', Scale=(2, 10))], - [g.InputCombo(['choice 1', 'choice 2'], Size=(20, 3))], - [g.Text('_' * 100, Size=(90, 1))], - [g.Text('Choose Source and Destination Folders', Size=(35,1))], - [g.Text('Source Folder', Size=(15, 1), AutoSizeText=False), g.InputText('Source'), g.FolderBrowse()], - [g.Text('Destination Folder', Size=(15, 1), AutoSizeText=False), g.InputText('Dest'), g.FolderBrowse()], - [g.SimpleButton('Your very own button', ButtonColor=('white', 'green'))], + [g.Checkbox('My first checkbox!'), g.Checkbox('My second checkbox!', default=True)], + [g.Radio('My first Radio!', "RADIO1", default=True), g.Radio('My second Radio!', "RADIO1")], + [g.Multiline(default_text='This is the default Text should you decide not to type anything', scale=(2,10))], + [g.InputCombo(['choice 1', 'choice 2'], size=(20,3))], + [g.Text('_' * 100, size=(70,1))], + [g.Text('Choose Source and Destination Folders', size=(35,1))], + [g.Text('Source Folder', size=(15,1), auto_size_text=False), g.InputText('Source'), g.FolderBrowse()], + [g.Text('Destination Folder', size=(15,1), auto_size_text=False), g.InputText('Dest'), g.FolderBrowse()], + [g.SimpleButton('Your very own button', button_color=('white', 'green'))], [g.Submit(), g.Cancel()]] (button, (values)) = form.LayoutAndShow(layout) - g.MsgBox('Title', 'Typical message box', 'The results of the form are a lot of data! Get ready... ', 'The button clicked was "{}"'.format(button), 'The values are', values, AutoClose=True) + g.MsgBox('Title', 'Typical message box', 'The results of the form are a lot of data! Get ready... ', 'The button clicked was "{}"'.format(button), 'The values are', values, auto_close=True) # example of an Asynchronous form def ChatBot(): - with g.FlexForm('Chat Window', AutoSizeText=True, DefaultElementSize=(30, 2)) as form: - form.AddRow(g.Text('This is where standard out is being routed', Size=[40,1])) - form.AddRow(g.Output(Size=(80, 20))) - form.AddRow(g.Multiline(Size=(70, 5), EnterSubmits=True), g.ReadFormButton('SEND', ButtonColor=(g.YELLOWS[0], g.BLUES[0])), g.SimpleButton('EXIT', ButtonColor=(g.YELLOWS[0], g.GREENS[0]))) + with g.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + form.AddRow(g.Text('This is where standard out is being routed', size=[40,1])) + form.AddRow(g.Output(size=(80, 20))) + form.AddRow(g.Multiline(size=(70, 5), enter_submits=True), g.ReadFormButton('SEND', button_color=(g.YELLOWS[0], g.BLUES[0])), g.SimpleButton('EXIT', button_color=(g.YELLOWS[0], g.GREENS[0]))) # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # while True: (button, value) = form.Read() if button == 'SEND': - print(value) + print(value, end="") else: - print('Exiting the form now') break - print('Exiting the chatbot....') def main(): - # SourceDestFolders() + SourceDestFolders() Everything() - # ChatBot() + ChatBot() if __name__ == '__main__': main() diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 1e45abc48..aaf030a01 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -120,13 +120,13 @@ def RGB(red,green,blue): return '#%02x%02x%02x' % (red,green,blue) # Element CLASS # # ------------------------------------------------------------------------- # class Element(): - def __init__(self, Type, Scale=(None, None), Size=(None, None), AutoSizeText=None, Font=None): - self.Size = Size - self.Type = Type - self.AutoSizeText = AutoSizeText - self.Scale = Scale + def __init__(self, type, scale=(None, None), size=(None, None), auto_size_text=None, font=None): + self.Size = size + self.Type = type + self.AutoSizeText = auto_size_text + self.Scale = scale self.Pad = DEFAULT_ELEMENT_PADDING - self.Font = Font + self.Font = font self.TKStringVar = None self.TKIntVar = None @@ -161,9 +161,9 @@ def __del__(self): # ---------------------------------------------------------------------- # class InputText(Element): - def __init__(self, DefaultText = '', Scale=(None, None), Size=(None, None), AutoSizeText=None): - self.DefaultText = DefaultText - super().__init__(INPUT_TEXT, Scale, Size, AutoSizeText) + def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto_size_text=None): + self.DefaultText = default_text + super().__init__(INPUT_TEXT, scale, size, auto_size_text) return def ReturnKeyHandler(self, event): @@ -183,10 +183,10 @@ def __del__(self): # ---------------------------------------------------------------------- # class InputCombo(Element): - def __init__(self, Values, Scale=(None, None), Size=(None, None), AutoSizeText=None): - self.Values = Values + def __init__(self, values, scale=(None, None), size=(None, None), auto_size_text=None): + self.Values = values self.TKComboBox = None - super().__init__(INPUT_COMBO, Scale, Size, AutoSizeText) + super().__init__(INPUT_COMBO, scale, size, auto_size_text) return def __del__(self): @@ -200,13 +200,13 @@ def __del__(self): # Radio # # ---------------------------------------------------------------------- # class Radio(Element): - def __init__(self, Text, GroupID, Default=False, Scale=(None, None), Size=(None, None), AutoSizeText=None,Font=None): - self.InitialState = Default - self.Text = Text + def __init__(self, text, group_id, default=False, scale=(None, None), size=(None, None), auto_size_text=None, font=None): + self.InitialState = default + self.Text = text self.TKRadio = None - self.GroupID = GroupID + self.GroupID = group_id self.Value = None - super().__init__(INPUT_RADIO, Scale, Size, AutoSizeText, Font) + super().__init__(INPUT_RADIO, scale, size, auto_size_text, font) return def __del__(self): @@ -220,13 +220,13 @@ def __del__(self): # Checkbox # # ---------------------------------------------------------------------- # class Checkbox(Element): - def __init__(self, Text, Default=False, Scale=(None, None), Size=(None, None), AutoSizeText=None, Font=None): - self.Text = Text - self.InitialState = Default + def __init__(self, text, default=False, scale=(None, None), size=(None, None), auto_size_text=None, font=None): + self.Text = text + self.InitialState = default self.Value = None self.TKCheckbox = None - super().__init__(INPUT_CHECKBOX, Scale, Size, AutoSizeText, Font) + super().__init__(INPUT_CHECKBOX, scale, size, auto_size_text, font) return def __del__(self): @@ -243,11 +243,11 @@ def __del__(self): class Spin(Element): # Values = None # TKSpinBox = None - def __init__(self, Values, InitialValue=None, Scale=(None, None), Size=(None, None), AutoSizeText=None, Font=None): - self.Values = Values - self.DefaultValue = InitialValue + def __init__(self, values, initial_value=None, scale=(None, None), size=(None, None), auto_size_text=None, font=None): + self.Values = values + self.DefaultValue = initial_value self.TKSpinBox = None - super().__init__(INPUT_SPIN, Scale, Size, AutoSizeText, Font=Font) + super().__init__(INPUT_SPIN, scale, size, auto_size_text, font=font) return def __del__(self): @@ -261,10 +261,10 @@ def __del__(self): # Multiline # # ---------------------------------------------------------------------- # class Multiline(Element): - def __init__(self, DefaultText='', EnterSubmits = False, Scale=(None, None), Size=(None, None), AutoSizeText=None): - self.DefaultText = DefaultText - self.EnterSubmits = EnterSubmits - super().__init__(INPUT_MULTILINE, Scale, Size, AutoSizeText) + def __init__(self, default_text='', enter_submits = False, scale=(None, None), size=(None, None), auto_size_text=None): + self.DefaultText = default_text + self.EnterSubmits = enter_submits + super().__init__(INPUT_MULTILINE, scale, size, auto_size_text) return def ReturnKeyHandler(self, event): @@ -284,12 +284,12 @@ def __del__(self): # Text # # ---------------------------------------------------------------------- # class Text(Element): - def __init__(self, Text, Scale=(None, None), Size=(None, None), AutoSizeText=None, Font=None, TextColor=None): - self.DisplayText = Text - self.TextColor = TextColor if TextColor else 'black' + def __init__(self, text, scale=(None, None), size=(None, None), auto_size_text=None, font=None, text_color=None): + self.DisplayText = text + self.TextColor = text_color if text_color else 'black' # self.Font = Font if Font else DEFAULT_FONT # i=1/0 - super().__init__(TEXT, Scale, Size, AutoSizeText, Font=Font if Font else DEFAULT_FONT) + super().__init__(TEXT, scale, size, auto_size_text, font=font if font else DEFAULT_FONT) return def Update(self, NewValue): @@ -307,41 +307,41 @@ def __del__(self): # ---------------------------------------------------------------------- # class TKProgressBar(): - def __init__(self, root, Max, Length=400, Width=20, Highlightt=0, Relief='sunken', Borderwidth=4, Orientation='horizontal', BarColor=DEFAULT_PROGRESS_BAR_COLOR): - self.Length = Length - self.Width = Width - self.Max = Max - self.Orientation = Orientation + def __init__(self, root, max, length=400, width=20, highlightt=0, relief='sunken', border_width=4, orientation='horizontal', BarColor=DEFAULT_PROGRESS_BAR_COLOR): + self.Length = length + self.Width = width + self.Max = max + self.Orientation = orientation self.Count = None self.PriorCount = 0 - if Orientation[0].lower() == 'h': - self.TKCanvas = tk.Canvas(root, width=Length, height=Width, highlightt=Highlightt, relief=Relief, borderwidth=Borderwidth) - self.TKRect = self.TKCanvas.create_rectangle(0, 0, -(Length * 1.5), Width * 1.5, fill=BarColor[0], tags='bar') + if orientation[0].lower() == 'h': + self.TKCanvas = tk.Canvas(root, width=length, height=width, highlightt=highlightt, relief=relief, borderwidth=border_width) + self.TKRect = self.TKCanvas.create_rectangle(0, 0, -(length * 1.5), width * 1.5, fill=BarColor[0], tags='bar') # self.canvas.pack(padx='10') else: - self.TKCanvas = tk.Canvas(root, width=Width, height=Length, highlightt=Highlightt, relief=Relief, borderwidth=Borderwidth) - self.TKRect = self.TKCanvas.create_rectangle(Width * 1.5, 2 * Length + 40, 0, Length * .5, fill=BarColor[0], tags='bar') + self.TKCanvas = tk.Canvas(root, width=width, height=length, highlightt=highlightt, relief=relief, borderwidth=border_width) + self.TKRect = self.TKCanvas.create_rectangle(width * 1.5, 2 * length + 40, 0, length * .5, fill=BarColor[0], tags='bar') # self.canvas.pack() - def Update(self,Count): - if Count > self.Max: return + def Update(self, count): + if count > self.Max: return if self.Orientation[0].lower() == 'h': try: - if Count != self.PriorCount: - delta = Count - self.PriorCount + if count != self.PriorCount: + delta = count - self.PriorCount self.TKCanvas.move(self.TKRect, delta*(self.Length / self.Max), 0) if 0: self.TKCanvas.update() except: return False # the window was closed by the user on us else: try: - if Count != self.PriorCount: - delta = Count - self.PriorCount + if count != self.PriorCount: + delta = count - self.PriorCount self.TKCanvas.move(self.TKRect, 0, delta*(-self.Length / self.Max)) if 0: self.TKCanvas.update() except: return False # the window was closed by the user on us - self.PriorCount = Count + self.PriorCount = count return True def __del__(self): @@ -395,9 +395,9 @@ def __del__(self): sys.stdout = self.previous_stdout class Output(Element): - def __init__(self, Scale=(None, None), Size=(None, None)): + def __init__(self, scale=(None, None), size=(None, None)): self.TKOut = None - super().__init__(OUTPUT, Scale, Size) + super().__init__(OUTPUT, scale, size) def __del__(self): try: @@ -410,15 +410,15 @@ def __del__(self): # Button Class # # ---------------------------------------------------------------------- # class Button(Element): - def __init__(self, ButtonType=CLOSES_WIN, Target=(None, None), ButtonText='', FileTypes=(("ALL Files", "*.*"),), Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None, Font=None): - self.BType = ButtonType - self.FileTypes = FileTypes + def __init__(self, button_type=CLOSES_WIN, target=(None, None), button_text='', file_types=(("ALL Files", "*.*"),), scale=(None, None), size=(None, None), auto_size_text=None, button_color=None, font=None): + self.BType = button_type + self.FileTypes = file_types self.TKButton = None - self.Target = Target - self.ButtonText = ButtonText - self.ButtonColor = ButtonColor if ButtonColor else DEFAULT_BUTTON_COLOR + self.Target = target + self.ButtonText = button_text + self.ButtonColor = button_color if button_color else DEFAULT_BUTTON_COLOR self.UserData = None - super().__init__(BUTTON, Scale, Size, AutoSizeText, Font=Font) + super().__init__(BUTTON, scale, size, auto_size_text, font=font) return # ------- Button Callback ------- # @@ -493,22 +493,22 @@ def __del__(self): # ProgreessBar # # ---------------------------------------------------------------------- # class ProgressBar(Element): - def __init__(self, MaxValue, Orientation=None, Target=(None,None), Scale=(None, None), Size=(None, None), AutoSizeText=None, BarColor=(None,None), Style=None, BorderWidth=None, Relief=None): - self.MaxValue = MaxValue + def __init__(self, max_value, orientation=None, target=(None, None), scale=(None, None), size=(None, None), auto_size_text=None, bar_color=(None, None), style=None, broder_width=None, relief=None): + self.MaxValue = max_value self.TKProgressBar = None self.Cancelled = False self.NotRunning = True - self.Orientation = Orientation if Orientation else DEFAULT_METER_ORIENTATION - self.BarColor = BarColor - self.BarStyle = Style if Style else DEFAULT_PROGRESS_BAR_STYLE - self.Target = Target - self.BorderWidth = BorderWidth if BorderWidth else DEFAULT_PROGRESS_BAR_BORDER_WIDTH - self.Relief = Relief if Relief else DEFAULT_PROGRESS_BAR_RELIEF + self.Orientation = orientation if orientation else DEFAULT_METER_ORIENTATION + self.BarColor = bar_color + self.BarStyle = style if style else DEFAULT_PROGRESS_BAR_STYLE + self.Target = target + self.BorderWidth = broder_width if broder_width else DEFAULT_PROGRESS_BAR_BORDER_WIDTH + self.Relief = relief if relief else DEFAULT_PROGRESS_BAR_RELIEF self.BarExpired = False - super().__init__(PROGRESS_BAR, Scale, Size, AutoSizeText) + super().__init__(PROGRESS_BAR, scale, size, auto_size_text) return - def UpdateBar(self, CurrentCount): + def UpdateBar(self, current_count): if self.ParentForm.TKrootDestroyed: return False target = self.Target @@ -519,7 +519,7 @@ def UpdateBar(self, CurrentCount): # update the progress bar counter # self.TKProgressBar['value'] = self.CurrentValue - self.TKProgressBar.Update(CurrentCount) + self.TKProgressBar.Update(current_count) try: self.ParentForm.TKroot.update() except: @@ -538,8 +538,8 @@ def __del__(self): # Row CLASS # # ------------------------------------------------------------------------- # class Row(): - def __init__(self, AutoSizeText = None): - self.AutoSizeText = AutoSizeText # Setting to override the form's policy on autosizing. + def __init__(self, auto_size_text = None): + self.AutoSizeText = auto_size_text # Setting to override the form's policy on autosizing. self.Elements = [] # List of Elements in this Rrow return @@ -563,44 +563,44 @@ class FlexForm: ''' Display a user defined for and return the filled in data ''' - def __init__(self, title, DefaultElementSize=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), AutoSizeText=DEFAULT_AUTOSIZE_TEXT, Scale=(None, None),Size=(None, None), Location=(None, None), ButtonColor=None, Font=None, ProgressBarColor=(None,None), IsTabbedForm=False,BorderDepth=None, AutoClose=False, AutoCloseDuration=DEFAULT_AUTOCLOSE_TIME, Icon=DEFAULT_WINDOW_ICON): - self.AutoSizeText = AutoSizeText + def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=DEFAULT_AUTOSIZE_TEXT, scale=(None, None), size=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON): + self.AutoSizeText = auto_size_text self.Title = title self.Rows = [] # a list of ELEMENTS for this row - self.DefaultElementSize = DefaultElementSize - self.Size = Size - self.Scale = Scale - self.Location = Location - self.ButtonColor = ButtonColor if ButtonColor else DEFAULT_BUTTON_COLOR - self.IsTabbedForm = IsTabbedForm + self.DefaultElementSize = default_element_size + self.Size = size + self.Scale = scale + self.Location = location + self.ButtonColor = button_color if button_color else DEFAULT_BUTTON_COLOR + self.IsTabbedForm = is_tabbed_form self.ParentWindow = None - self.Font = Font if Font else DEFAULT_FONT + self.Font = font if font else DEFAULT_FONT self.RadioDict = {} - self.BorderDepth = BorderDepth - self.WindowIcon = Icon if not _my_windows.user_defined_icon else _my_windows.user_defined_icon - self.AutoClose = AutoClose + self.BorderDepth = border_depth + self.WindowIcon = icon if not _my_windows.user_defined_icon else _my_windows.user_defined_icon + self.AutoClose = auto_close self.NonBlocking = False self.TKroot = None self.TKrootDestroyed = False self.TKAfterID = None - self.ProgressBarColor = ProgressBarColor - self.AutoCloseDuration = AutoCloseDuration + self.ProgressBarColor = progress_bar_color + self.AutoCloseDuration = auto_close_duration self.UberParent = None self.RootNeedsDestroying = False self.Shown = False self.ReturnValues = None # ------------------------- Add ONE Row to Form ------------------------- # - def AddRow(self, *args,AutoSizeText=None): + def AddRow(self, *args, auto_size_text=None): ''' Parms are a variable number of Elements ''' NumRows = len(self.Rows) # number of existing rows is our row number CurrentRowNumber = NumRows # this row's number - CurrentRow = Row(AutoSizeText) # start with a blank row and build up + CurrentRow = Row(auto_size_text) # start with a blank row and build up # ------------------------- Add the elements to a row ------------------------- # for i, element in enumerate(args): # Loop through list of elements and add them to the row element.Position = (CurrentRowNumber, i) CurrentRow.Elements.append(element) - CurrentRow.AutoSizeText = AutoSizeText + CurrentRow.AutoSizeText = auto_size_text # ------------------------- Append the row to list of Rows ------------------------- # self.Rows.append(CurrentRow) @@ -615,26 +615,26 @@ def LayoutAndShow(self,rows): return self.ReturnValues # ------------------------- ShowForm THIS IS IT! ------------------------- # - def Show(self, NonBlocking=False): + def Show(self, non_blocking=False): self.Shown = True # Compute num rows & num cols (it'll come in handy debugging) self.NumRows = len(self.Rows) self.NumCols = max(len(row.Elements) for row in self.Rows) - self.NonBlocking=NonBlocking + self.NonBlocking=non_blocking # -=-=-=-=-=-=-=-=- RUN the GUI -=-=-=-=-=-=-=-=- ## StartupTK(self) return self.ReturnValues # ------------------------- SetIcon - set the window's fav icon ------------------------- # - def SetIcon(self, Icon): - self.WindowIcon = Icon + def SetIcon(self, icon): + self.WindowIcon = icon try: - self.TKroot.iconbitmap(Icon) + self.TKroot.iconbitmap(icon) except: pass - def GetElementAtLocation(self,Location): - (row_num,col_num) = Location + def GetElementAtLocation(self, location): + (row_num,col_num) = location row = self.Rows[row_num] element = row.Elements[col_num] return element @@ -720,8 +720,8 @@ def __init__(self): self.TKroot = None self.TKrootDestroyed = False - def AddForm(self, Form): - self.FormList.append(Form) + def AddForm(self, form): + self.FormList.append(form) def Close(self): self.FormReturnValues = [] @@ -740,60 +740,60 @@ def __del__(self): # ====================================================================== # # ------------------------- INPUT TEXT Element lazy functions ------------------------- # -def In(DefaultText = '', Scale=(None, None), Size=(None, None), AutoSizeText=None): - return InputText(DefaultText=DefaultText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText) +def In(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None): + return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text) -def Input(DefaultText = '', Scale=(None, None), Size=(None, None), AutoSizeText=None): - return InputText(DefaultText=DefaultText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText) +def Input(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None): + return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text) # ------------------------- TEXT Element lazy functions ------------------------- # -def Txt(DisplayText, Scale=(None, None), Size=(None, None), AutoSizeText=None, Font=None, TextColor=None): - return Text(DisplayText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, Font=Font, TextColor=TextColor) +def Txt(display_text, scale=(None, None), size=(None, None), auto_size_text=None, font=None, text_color=None): + return Text(display_text, scale=scale, size=size, auto_size_text=auto_size_text, font=font, text_color=text_color) -def T(DisplayText, Scale=(None, None), Size=(None, None), AutoSizeText=None, Font=None, TextColor=None): - return Text(DisplayText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, Font=Font, TextColor=TextColor) +def T(display_text, scale=(None, None), size=(None, None), auto_size_text=None, font=None, text_color=None): + return Text(display_text, scale=scale, size=size, auto_size_text=auto_size_text, font=font, text_color=text_color) # ------------------------- FOLDER BROWSE Element lazy function ------------------------- # -def FolderBrowse(Target=(ThisRow, -1), ButtonText='Browse', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None): - return Button(BROWSE_FOLDER, Target=Target, ButtonText=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) +def FolderBrowse(target=(ThisRow, -1), button_text='Browse', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None): + return Button(BROWSE_FOLDER, target=target, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color) # ------------------------- FILE BROWSE Element lazy function ------------------------- # -def FileBrowse(Target=(ThisRow, -1), FileTypes=(("ALL Files", "*.*"),),ButtonText='Browse',Scale=(None, None),Size=(None, None), AutoSizeText=None, ButtonColor=None): - return Button(BROWSE_FILE, Target, ButtonText=ButtonText, FileTypes=FileTypes, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) +def FileBrowse(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Browse', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None): + return Button(BROWSE_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color) # ------------------------- SUBMIT BUTTON Element lazy function ------------------------- # -def Submit(ButtonText='Submit', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None): - return Button(CLOSES_WIN, ButtonText=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) +def Submit(button_text='Submit', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None): + return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color) # ------------------------- OK BUTTON Element lazy function ------------------------- # -def OK(ButtonText='OK', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None): - return Button(CLOSES_WIN, ButtonText=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) +def OK(button_text='OK', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None): + return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color) # ------------------------- YES BUTTON Element lazy function ------------------------- # -def Ok(ButtonText='Ok', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None): - return Button(CLOSES_WIN, ButtonText=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) +def Ok(button_text='Ok', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None): + return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color) # ------------------------- CANCEL BUTTON Element lazy function ------------------------- # -def Cancel(ButtonText='Cancel', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None, Font=None): - return Button(CLOSES_WIN, ButtonText=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor, Font=Font) +def Cancel(button_text='Cancel', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None, font=None): + return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color, font=font) # ------------------------- YES BUTTON Element lazy function ------------------------- # -def Yes(ButtonText='Yes', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None): - return Button(CLOSES_WIN, ButtonText=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) +def Yes(button_text='Yes', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None): + return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color) # ------------------------- NO BUTTON Element lazy function ------------------------- # -def No(ButtonText='No', Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None): - return Button(CLOSES_WIN, ButtonText=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor) +def No(button_text='No', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None): + return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color) # ------------------------- GENERIC BUTTON Element lazy function ------------------------- # # this is the only button that REQUIRES button text field -def SimpleButton(ButtonText, Scale=(None, None), Size=(None, None), AutoSizeText=None, ButtonColor=None, Font=None): - return Button(CLOSES_WIN, ButtonText=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor, Font=Font) +def SimpleButton(button_text, scale=(None, None), size=(None, None), auto_size_text=None, button_color=None, font=None): + return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color, font=font) # ------------------------- GENERIC BUTTON Element lazy function ------------------------- # # this is the only button that REQUIRES button text field -def ReadFormButton(ButtonText, Scale=(None, None),Size=(None, None), AutoSizeText=None, ButtonColor=None, Font=None): - return Button(READ_FORM, ButtonText=ButtonText, Scale=Scale, Size=Size, AutoSizeText=AutoSizeText, ButtonColor=ButtonColor, Font=Font) +def ReadFormButton(button_text, scale=(None, None), size=(None, None), auto_size_text=None, button_color=None, Font=None): + return Button(READ_FORM, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color, font=Font) #------------------------------------------------------------------------------------------------------# # ------- FUNCTION InitializeResults. Sets up form results matrix ------- # @@ -843,8 +843,8 @@ def DecodeRadioRowCol(RadValue): col = RadValue%1000 return row,col -def EncodeRadioRowCol(Row, Col): - RadValue = Row*1000 + Col +def EncodeRadioRowCol(row, col): + RadValue = row * 1000 + col return RadValue # ------- FUNCTION BuildResults. Form exiting so build the results to pass back ------- # @@ -1066,7 +1066,7 @@ def ConvertFlexToTK(MyFlexForm): bar_color = element.BarColor else: bar_color = DEFAULT_PROGRESS_BAR_COLOR - element.TKProgressBar = TKProgressBar(tk_row_frame, element.MaxValue, progress_length, progress_width, Orientation=direction, BarColor=bar_color, Borderwidth=element.BorderWidth, Relief=element.Relief) + element.TKProgressBar = TKProgressBar(tk_row_frame, element.MaxValue, progress_length, progress_width, orientation=direction, BarColor=bar_color, border_width=element.BorderWidth, relief=element.Relief) s = ttk.Style() element.TKProgressBar.TKCanvas.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) # ------------------------- INPUT RADIO BUTTON element ------------------------- # @@ -1131,14 +1131,14 @@ def ConvertFlexToTK(MyFlexForm): return # ----====----====----====----====----==== STARTUP TK ====----====----====----====----====----# -def ShowTabbedForm(Title, *args,AutoClose=False, AutoCloseDuration=DEFAULT_AUTOCLOSE_TIME,FavIcon=DEFAULT_WINDOW_ICON): +def ShowTabbedForm(title, *args, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, fav_icon=DEFAULT_WINDOW_ICON): global _my_windows uber = UberForm() root = tk.Tk() uber.TKroot = root - if Title is not None: - root.title(Title) + if title is not None: + root.title(title) if not len(args): ('******************* SHOW TABBED FORMS ERROR .... no arguments') return @@ -1160,8 +1160,8 @@ def ShowTabbedForm(Title, *args,AutoClose=False, AutoCloseDuration=DEFAULT_AUTOC uber.FormReturnValues.append(form.ReturnValues) # dangerous?? or clever? use the final form as a callback for autoclose - id = root.after(AutoCloseDuration*1000, form.AutoCloseAlarmCallback) if AutoClose else 0 - icon = FavIcon if not _my_windows.user_defined_icon else _my_windows.user_defined_icon + id = root.after(auto_close_duration * 1000, form.AutoCloseAlarmCallback) if auto_close else 0 + icon = fav_icon if not _my_windows.user_defined_icon else _my_windows.user_defined_icon try: uber.TKroot.iconbitmap(icon) except: pass @@ -1172,31 +1172,31 @@ def ShowTabbedForm(Title, *args,AutoClose=False, AutoCloseDuration=DEFAULT_AUTOC return uber.FormReturnValues # ----====----====----====----====----==== STARTUP TK ====----====----====----====----====----# -def StartupTK(MyFlexForm): +def StartupTK(my_flex_form): global _my_windows ow = _my_windows.NumOpenWindows root = tk.Tk() if not ow else tk.Toplevel() _my_windows.NumOpenWindows += 1 - MyFlexForm.TKroot = root + my_flex_form.TKroot = root # root.protocol("WM_DELETE_WINDOW", MyFlexForm.DestroyedCallback()) # root.bind('', MyFlexForm.DestroyedCallback()) - ConvertFlexToTK(MyFlexForm) - MyFlexForm.SetIcon(MyFlexForm.WindowIcon) - - if MyFlexForm.AutoClose: - duration = DEFAULT_AUTOCLOSE_TIME if MyFlexForm.AutoCloseDuration is None else MyFlexForm.AutoCloseDuration - MyFlexForm.TKAfterID = root.after(duration*1000, MyFlexForm.AutoCloseAlarmCallback) - if MyFlexForm.NonBlocking: - MyFlexForm.TKroot.protocol("WM_WINDOW_DESTROYED", MyFlexForm.OnClosingCallback()) + ConvertFlexToTK(my_flex_form) + my_flex_form.SetIcon(my_flex_form.WindowIcon) + + if my_flex_form.AutoClose: + duration = DEFAULT_AUTOCLOSE_TIME if my_flex_form.AutoCloseDuration is None else my_flex_form.AutoCloseDuration + my_flex_form.TKAfterID = root.after(duration * 1000, my_flex_form.AutoCloseAlarmCallback) + if my_flex_form.NonBlocking: + my_flex_form.TKroot.protocol("WM_WINDOW_DESTROYED", my_flex_form.OnClosingCallback()) pass else: # it's a blocking form - MyFlexForm.TKroot.mainloop() + my_flex_form.TKroot.mainloop() _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 - if MyFlexForm.RootNeedsDestroying: - MyFlexForm.TKroot.destroy() - MyFlexForm.RootNeedsDestroying = False + if my_flex_form.RootNeedsDestroying: + my_flex_form.TKroot.destroy() + my_flex_form.RootNeedsDestroying = False return @@ -1225,24 +1225,24 @@ def _GetNumLinesNeeded(text, max_line_width): # Exits via an OK button2 press # # Returns nothing # # ===================================================# -def MsgBox(*args, ButtonColor=None, ButtonType=MSG_BOX_OK, AutoClose=False, AutoCloseDuration=None, Icon=DEFAULT_WINDOW_ICON, LineWidth=MESSAGE_BOX_LINE_WIDTH, Font=None): +def MsgBox(*args, button_color=None, button_type=MSG_BOX_OK, auto_close=False, auto_close_duration=None, icon=DEFAULT_WINDOW_ICON, line_width=MESSAGE_BOX_LINE_WIDTH, font=None): ''' Show message box. Displays one line per user supplied argument. Takes any Type of variable to display. :param args: - :param ButtonColor: - :param ButtonType: - :param AutoClose: - :param AutoCloseDuration: - :param Icon: - :param LineWidth: - :param Font: + :param button_color: + :param button_type: + :param auto_close: + :param auto_close_duration: + :param icon: + :param line_width: + :param font: :return: ''' if not args: args_to_print = [''] else: args_to_print = args - with FlexForm(args_to_print[0], AutoSizeText=True, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Icon=Icon, Font=Font) as form: + with FlexForm(args_to_print[0], auto_size_text=True, button_color=button_color, auto_close=auto_close, auto_close_duration=auto_close_duration, icon=icon, font=font) as form: max_line_total, total_lines = 0,0 for message in args_to_print: # fancy code to check if string and convert if not is not need. Just always convert to string :-) @@ -1251,32 +1251,33 @@ def MsgBox(*args, ButtonColor=None, ButtonType=MSG_BOX_OK, AutoClose=False, Aut if message.count('\n'): message_wrapped = message else: - message_wrapped = textwrap.fill(message, LineWidth) + message_wrapped = textwrap.fill(message, line_width) message_wrapped_lines = message_wrapped.count('\n')+1 longest_line_len = max([len(l) for l in message.split('\n')]) - width_used = min(longest_line_len, LineWidth) + width_used = min(longest_line_len, line_width) max_line_total = max(max_line_total, width_used) # height = _GetNumLinesNeeded(message, width_used) height = message_wrapped_lines - form.AddRow(Text(message_wrapped, AutoSizeText=True)) + form.AddRow(Text(message_wrapped, auto_size_text=True)) total_lines += height pad = max_line_total-15 if max_line_total > 15 else 1 pad =1 # show either an OK or Yes/No depending on paramater - if ButtonType is MSG_BOX_YES_NO: - form.AddRow(Text('', Size=(pad,1), AutoSizeText=False), Yes(ButtonColor=ButtonColor), No(ButtonColor=ButtonColor)) + if button_type is MSG_BOX_YES_NO: + form.AddRow(Text('', size=(pad, 1), auto_size_text=False), Yes(button_color=button_color), No( + button_color=button_color)) (button_text, values) = form.Show() return button_text == 'Yes' - elif ButtonType is MSG_BOX_CANCELLED: - form.AddRow(Text('', Size=(pad,1), AutoSizeText=False), SimpleButton('Cancelled', ButtonColor=ButtonColor)) - elif ButtonType is MSG_BOX_ERROR: - form.AddRow(Text('', Size=(pad,1), AutoSizeText=False), SimpleButton('ERROR', Size=(5,1), ButtonColor=ButtonColor)) - elif ButtonType is MSG_BOX_OK_CANCEL: - form.AddRow(Text('', Size=(pad,1), AutoSizeText=False), SimpleButton('OK', Size=(5,1), ButtonColor=ButtonColor), - SimpleButton('Cancel', Size=(5, 1), ButtonColor=ButtonColor)) + elif button_type is MSG_BOX_CANCELLED: + form.AddRow(Text('', size=(pad, 1), auto_size_text=False), SimpleButton('Cancelled', button_color=button_color)) + elif button_type is MSG_BOX_ERROR: + form.AddRow(Text('', size=(pad, 1), auto_size_text=False), SimpleButton('ERROR', size=(5, 1), button_color=button_color)) + elif button_type is MSG_BOX_OK_CANCEL: + form.AddRow(Text('', size=(pad, 1), auto_size_text=False), SimpleButton('OK', size=(5, 1), button_color=button_color), + SimpleButton('Cancel', size=(5, 1), button_color=button_color)) else: - form.AddRow(Text('', Size=(pad,1), AutoSizeText=False), SimpleButton('OK', Size=(5,1), ButtonColor=ButtonColor)) + form.AddRow(Text('', size=(pad, 1), auto_size_text=False), SimpleButton('OK', size=(5, 1), button_color=button_color)) button, values = form.Show() return button @@ -1284,99 +1285,99 @@ def MsgBox(*args, ButtonColor=None, ButtonType=MSG_BOX_OK, AutoClose=False, Aut # ============================== MsgBoxAutoClose====# # Lazy function. Same as calling MsgBox with parms # # ===================================================# -def MsgBoxAutoClose(*args, ButtonColor=None,AutoClose=True, AutoCloseDuration=DEFAULT_AUTOCLOSE_TIME, Font=None): +def MsgBoxAutoClose(*args, button_color=None, auto_close=True, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, font=None): ''' Display a standard MsgBox that will automatically close after a specified amount of time :param args: - :param ButtonColor: - :param AutoClose: - :param AutoCloseDuration: - :param Font: + :param button_color: + :param auto_close: + :param auto_close_duration: + :param font: :return: ''' - MsgBox(*args, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Font=Font) + MsgBox(*args, button_color=button_color, auto_close=auto_close, auto_close_duration=auto_close_duration, font=font) return # ============================== MsgBoxError =====# # Like MsgBox but presents RED BUTTONS # # ===================================================# -def MsgBoxError(*args, ButtonColor=DEFAULT_ERROR_BUTTON_COLOR,AutoClose=False, AutoCloseDuration=None, Font=None): +def MsgBoxError(*args, button_color=DEFAULT_ERROR_BUTTON_COLOR, auto_close=False, auto_close_duration=None, Font=None): ''' Display a MsgBox with a red button :param args: - :param ButtonColor: - :param AutoClose: - :param AutoCloseDuration: + :param button_color: + :param auto_close: + :param auto_close_duration: :param Font: :return: ''' - MsgBox(*args, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Font=Font) + MsgBox(*args, button_color=button_color, auto_close=auto_close, auto_close_duration=auto_close_duration, font=Font) return # ============================== MsgBoxCancel =====# # # # ===================================================# -def MsgBoxCancel(*args,ButtonColor=DEFAULT_CANCEL_BUTTON_COLOR,AutoClose=False, AutoCloseDuration=None, Font=None): +def MsgBoxCancel(*args, button_color=DEFAULT_CANCEL_BUTTON_COLOR, auto_close=False, auto_close_duration=None, font=None): ''' Display a MsgBox with a single "Cancel" button. :param args: - :param ButtonColor: - :param AutoClose: - :param AutoCloseDuration: - :param Font: + :param button_color: + :param auto_close: + :param auto_close_duration: + :param font: :return: ''' - MsgBox(*args, ButtonType=MSG_BOX_CANCELLED, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Font=Font) + MsgBox(*args, button_type=MSG_BOX_CANCELLED, button_color=button_color, auto_close=auto_close, auto_close_duration=auto_close_duration, font=font) return # ============================== MsgBoxOK =====# # Like MsgBox but only 1 button # # ===================================================# -def MsgBoxOK(*args,ButtonColor=('white', 'black'),AutoClose=False, AutoCloseDuration=None, Font=None): +def MsgBoxOK(*args, button_color=('white', 'black'), auto_close=False, auto_close_duration=None, font=None): ''' Display a MsgBox with a single buttoned labelled "OK" :param args: - :param ButtonColor: - :param AutoClose: - :param AutoCloseDuration: - :param Font: + :param button_color: + :param auto_close: + :param auto_close_duration: + :param font: :return: ''' - MsgBox(*args, ButtonType=MSG_BOX_OK, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Font=Font) + MsgBox(*args, button_type=MSG_BOX_OK, button_color=button_color, auto_close=auto_close, auto_close_duration=auto_close_duration, font=font) return # ============================== MsgBoxOKCancel ====# # Like MsgBox but presents OK and Cancel buttons # # ===================================================# -def MsgBoxOKCancel(*args,ButtonColor=None,AutoClose=False, AutoCloseDuration=None, Font=None): +def MsgBoxOKCancel(*args, button_color=None, auto_close=False, auto_close_duration=None, font=None): ''' Display MsgBox with 2 buttons, "OK" and "Cancel" :param args: - :param ButtonColor: - :param AutoClose: - :param AutoCloseDuration: - :param Font: + :param button_color: + :param auto_close: + :param auto_close_duration: + :param font: :return: ''' - result = MsgBox(*args, ButtonType=MSG_BOX_OK_CANCEL, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Font=Font) + result = MsgBox(*args, button_type=MSG_BOX_OK_CANCEL, button_color=button_color, auto_close=auto_close, auto_close_duration=auto_close_duration, font=font) return result # ==================================== YesNoBox=====# # Like MsgBox but presents Yes and No buttons # # Returns True if Yes was pressed else False # # ===================================================# -def MsgBoxYesNo(*args,ButtonColor=None,AutoClose=False, AutoCloseDuration=None, Font=None): +def MsgBoxYesNo(*args, button_color=None, auto_close=False, auto_close_duration=None, font=None): ''' Display MsgBox with 2 buttons, "Yes" and "No" :param args: - :param ButtonColor: - :param AutoClose: - :param AutoCloseDuration: - :param Font: + :param button_color: + :param auto_close: + :param auto_close_duration: + :param font: :return: ''' - result = MsgBox(*args,ButtonType=MSG_BOX_YES_NO, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration, Font=Font) + result = MsgBox(*args, button_type=MSG_BOX_YES_NO, button_color=button_color, auto_close=auto_close, auto_close_duration=auto_close_duration, font=font) return result # ============================== PROGRESS METER ========================================== # @@ -1400,52 +1401,52 @@ def ConvertArgsToSingleString(*args): # ============================== ProgressMeter =====# # ===================================================# -def ProgressMeter(Title, MaxValue, *args, Orientation=None, BarColor=DEFAULT_PROGRESS_BAR_COLOR, ButtonColor=None,Size=DEFAULT_PROGRESS_BAR_SIZE, Scale=(None, None), BorderWidth=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): +def ProgressMeter(title, max_value, *args, Orientation=None, bar_color=DEFAULT_PROGRESS_BAR_COLOR, button_color=None, size=DEFAULT_PROGRESS_BAR_SIZE, scale=(None, None), border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): ''' Create and show a form on tbe caller's behalf. - :param Title: - :param MaxValue: + :param title: + :param max_value: :param args: ANY number of arguments the caller wants to display :param Orientation: - :param BarColor: - :param Size: - :param Scale: + :param bar_color: + :param size: + :param scale: :param Style: :param StyleOffset: :return: ProgressBar object that is in the form ''' orientation = DEFAULT_METER_ORIENTATION if Orientation is None else Orientation target = (0,0) if orientation[0].lower() == 'h' else (0,1) - bar2 = ProgressBar(MaxValue, Orientation=orientation, Size=Size, BarColor=BarColor, Scale=Scale, Target=target, BorderWidth=BorderWidth) - form = FlexForm(Title, AutoSizeText=True) + bar2 = ProgressBar(max_value, orientation=orientation, size=size, bar_color=bar_color, scale=scale, target=target, broder_width=border_width) + form = FlexForm(title, auto_size_text=True) # Form using a horizontal bar if orientation[0].lower() == 'h': single_line_message, width, height = ConvertArgsToSingleString(*args) bar2.TextToDisplay = single_line_message - bar2.MaxValue = MaxValue + bar2.MaxValue = max_value bar2.CurrentValue = 0 - form.AddRow(Text(single_line_message,Size=(width+20, height+3), AutoSizeText=True)) + form.AddRow(Text(single_line_message, size=(width + 20, height + 3), auto_size_text=True)) form.AddRow((bar2)) - form.AddRow((Cancel(ButtonColor=ButtonColor))) + form.AddRow((Cancel(button_color=button_color))) else: single_line_message, width, height = ConvertArgsToSingleString(*args) bar2.TextToDisplay = single_line_message - bar2.MaxValue = MaxValue + bar2.MaxValue = max_value bar2.CurrentValue = 0 - form.AddRow(bar2, Text(single_line_message,Size=(width+20, height+3), AutoSizeText=True)) - form.AddRow((Cancel(ButtonColor=ButtonColor))) + form.AddRow(bar2, Text(single_line_message, size=(width + 20, height + 3), auto_size_text=True)) + form.AddRow((Cancel(button_color=button_color))) form.NonBlocking = True - form.Show(NonBlocking = True) + form.Show(non_blocking= True) return bar2 # ============================== ProgressMeterUpdate =====# -def ProgressMeterUpdate(bar, Value, *args): +def ProgressMeterUpdate(bar, value, *args): ''' Update the progress meter for a form :param form: class ProgressBar - :param Value: int + :param value: int :return: True if not cancelled, OK....False if Error ''' global _my_windows @@ -1455,9 +1456,9 @@ def ProgressMeterUpdate(bar, Value, *args): bar.TextToDisplay = message - bar.CurrentValue = Value - rc = bar.UpdateBar(Value) - if Value >= bar.MaxValue or not rc: + bar.CurrentValue = value + rc = bar.UpdateBar(value) + if value >= bar.MaxValue or not rc: bar.BarExpired = True bar.ParentForm.Close() if bar.ParentForm.RootNeedsDestroying: @@ -1474,12 +1475,12 @@ def ProgressMeterUpdate(bar, Value, *args): # ============================== EASY PROGRESS METER ========================================== # # class to hold the easy meter info (a global variable essentialy) class EasyProgressMeterDataClass(): - def __init__(self, Title='', CurrentValue=1, MaxValue=10, StartTime=None, StatMessages=()): - self.Title = Title - self.CurrentValue = CurrentValue - self.MaxValue = MaxValue - self.StartTime = StartTime - self.StatMessages = StatMessages + def __init__(self, title='', current_value=1, max_value=10, start_time=None, stat_messages=()): + self.Title = title + self.CurrentValue = current_value + self.MaxValue = max_value + self.StartTime = start_time + self.StatMessages = stat_messages self.ParentForm = None self.MeterID = None @@ -1514,18 +1515,18 @@ def ComputeProgressStats(self): # ============================== EasyProgressMeter =====# -def EasyProgressMeter(Title, CurrentValue, MaxValue,*args, Orientation=None, BarColor=DEFAULT_PROGRESS_BAR_COLOR, ButtonColor=None, Size=DEFAULT_PROGRESS_BAR_SIZE, Scale=(None, None),BorderWidth=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): +def EasyProgressMeter(title, current_value, max_value, *args, orientation=None, bar_color=DEFAULT_PROGRESS_BAR_COLOR, button_color=None, size=DEFAULT_PROGRESS_BAR_SIZE, scale=(None, None), border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): ''' A ONE-LINE progress meter. Add to your code where ever you need a meter. No need for a second function call before your loop. You've got enough code to write! - :param Title: Title will be shown on the window - :param CurrentValue: Current count of your items - :param MaxValue: Max value your count will ever reach. This indicates it should be closed + :param title: Title will be shown on the window + :param current_value: Current count of your items + :param max_value: Max value your count will ever reach. This indicates it should be closed :param args: VARIABLE number of arguements... you request it, we'll print it no matter what the item! - :param Orientation: - :param BarColor: - :param Size: - :param Scale: + :param orientation: + :param bar_color: + :param size: + :param scale: :param Style: :param StyleOffset: :return: False if should stop the meter @@ -1536,34 +1537,34 @@ def EasyProgressMeter(Title, CurrentValue, MaxValue,*args, Orientation=None, Bar EasyProgressMeter.EasyProgressMeterData = getattr(EasyProgressMeter, 'EasyProgressMeterData', EasyProgressMeterDataClass()) # if no meter currently running if EasyProgressMeter.EasyProgressMeterData.MeterID is None: # Starting a new meter - if int(CurrentValue) >= int(MaxValue): + if int(current_value) >= int(max_value): return False del(EasyProgressMeter.EasyProgressMeterData) - EasyProgressMeter.EasyProgressMeterData = EasyProgressMeterDataClass(Title, 1, int(MaxValue), datetime.datetime.utcnow(), []) + EasyProgressMeter.EasyProgressMeterData = EasyProgressMeterDataClass(title, 1, int(max_value), datetime.datetime.utcnow(), []) EasyProgressMeter.EasyProgressMeterData.ComputeProgressStats() message = "\n".join([line for line in EasyProgressMeter.EasyProgressMeterData.StatMessages]) - EasyProgressMeter.EasyProgressMeterData.MeterID = ProgressMeter(Title, int(MaxValue), message, *args, Orientation=Orientation, BarColor=BarColor, Size=Size, Scale=Scale, ButtonColor=ButtonColor,BorderWidth=BorderWidth) + EasyProgressMeter.EasyProgressMeterData.MeterID = ProgressMeter(title, int(max_value), message, *args, Orientation=orientation, bar_color=bar_color, size=size, scale=scale, button_color=button_color, border_width=border_width) EasyProgressMeter.EasyProgressMeterData.ParentForm = EasyProgressMeter.EasyProgressMeterData.MeterID.ParentForm return True # if exactly the same values as before, then ignore. - if EasyProgressMeter.EasyProgressMeterData.MaxValue == MaxValue and EasyProgressMeter.EasyProgressMeterData.CurrentValue == CurrentValue: + if EasyProgressMeter.EasyProgressMeterData.MaxValue == max_value and EasyProgressMeter.EasyProgressMeterData.CurrentValue == current_value: return True - if EasyProgressMeter.EasyProgressMeterData.MaxValue != int(MaxValue): + if EasyProgressMeter.EasyProgressMeterData.MaxValue != int(max_value): EasyProgressMeter.EasyProgressMeterData.MeterID = None EasyProgressMeter.EasyProgressMeterData.ParentForm = None del(EasyProgressMeter.EasyProgressMeterData) EasyProgressMeter.EasyProgressMeterData = EasyProgressMeterDataClass() # setup a new progress meter return True # HAVE to return TRUE or else the new meter will thing IT is failing when it hasn't - EasyProgressMeter.EasyProgressMeterData.CurrentValue = int(CurrentValue) - EasyProgressMeter.EasyProgressMeterData.MaxValue = int(MaxValue) + EasyProgressMeter.EasyProgressMeterData.CurrentValue = int(current_value) + EasyProgressMeter.EasyProgressMeterData.MaxValue = int(max_value) EasyProgressMeter.EasyProgressMeterData.ComputeProgressStats() message = '' for line in EasyProgressMeter.EasyProgressMeterData.StatMessages: message = message + str(line) + '\n' message = "\n".join(EasyProgressMeter.EasyProgressMeterData.StatMessages) - rc = ProgressMeterUpdate(EasyProgressMeter.EasyProgressMeterData.MeterID, CurrentValue,*args, message ) + rc = ProgressMeterUpdate(EasyProgressMeter.EasyProgressMeterData.MeterID, current_value, *args, message) # if counter >= max then the progress meter is all done. Indicate none running - if CurrentValue >= EasyProgressMeter.EasyProgressMeterData.MaxValue or not rc: + if current_value >= EasyProgressMeter.EasyProgressMeterData.MaxValue or not rc: EasyProgressMeter.EasyProgressMeterData.MeterID = None del(EasyProgressMeter.EasyProgressMeterData) EasyProgressMeter.EasyProgressMeterData = EasyProgressMeterDataClass() # setup a new progress meter @@ -1571,11 +1572,11 @@ def EasyProgressMeter(Title, CurrentValue, MaxValue,*args, Orientation=None, Bar return rc # return whatever the update told us -def EasyProgressMeterCancel(Title, *args): +def EasyProgressMeterCancel(title, *args): EasyProgressMeter.EasyProgressMeterData = getattr(EasyProgressMeter, 'EasyProgressMeterData', EasyProgressMeterDataClass()) if EasyProgressMeter.EasyProgressMeterData.MeterID is not None: # tell the normal meter update that we're at max value which will close the meter - rc = EasyProgressMeter(Title, EasyProgressMeter.EasyProgressMeterData.MaxValue, EasyProgressMeter.EasyProgressMeterData.MaxValue, ' *** CANCELLING ***', 'Caller requested a cancel', *args) + rc = EasyProgressMeter(title, EasyProgressMeter.EasyProgressMeterData.MaxValue, EasyProgressMeter.EasyProgressMeterData.MaxValue, ' *** CANCELLING ***', 'Caller requested a cancel', *args) return rc return True @@ -1609,10 +1610,10 @@ def GetComplimentaryHex(color): # ======================== Scrolled Text Box =====# # ===================================================# -def ScrolledTextBox(*args, ButtonColor=None, YesNo=False, AutoClose=False, AutoCloseDuration=None, Height=None): +def ScrolledTextBox(*args, button_color=None, yes_no=False, auto_close=False, auto_close_duration=None, height=None): if not args: return - with FlexForm(args[0], AutoSizeText=True, ButtonColor=ButtonColor, AutoClose=AutoClose, AutoCloseDuration=AutoCloseDuration) as form: - max_line_total, max_line_width, total_lines, height = 0,0,0,0 + with FlexForm(args[0], auto_size_text=True, button_color=button_color, auto_close=auto_close, auto_close_duration=auto_close_duration) as form: + max_line_total, max_line_width, total_lines, height_computed = 0,0,0,0 complete_output = '' for message in args: # fancy code to check if string and convert if not is not need. Just always convert to string :-) @@ -1623,21 +1624,21 @@ def ScrolledTextBox(*args, ButtonColor=None, YesNo=False, AutoClose=False, AutoC max_line_total = max(max_line_total, width_used) max_line_width = MESSAGE_BOX_LINE_WIDTH lines_needed = _GetNumLinesNeeded(message, width_used) - height += lines_needed + height_computed += lines_needed complete_output += message + '\n' total_lines += lines_needed - height = MAX_SCROLLED_TEXT_BOX_HEIGHT if height > MAX_SCROLLED_TEXT_BOX_HEIGHT else height - if Height: - height = Height - form.AddRow(Multiline(complete_output, Size=(max_line_width, height)), AutoSizeText=True) + height_computed = MAX_SCROLLED_TEXT_BOX_HEIGHT if height_computed > MAX_SCROLLED_TEXT_BOX_HEIGHT else height_computed + if height: + height_computed = height + form.AddRow(Multiline(complete_output, size=(max_line_width, height_computed)), auto_size_text=True) pad = max_line_total-15 if max_line_total > 15 else 1 # show either an OK or Yes/No depending on paramater - if YesNo: - form.AddRow(Text('', Size=(pad,1), AutoSizeText=False), Yes(), No()) + if yes_no: + form.AddRow(Text('', size=(pad, 1), auto_size_text=False), Yes(), No()) (button_text, values) = form.Show() return button_text == 'Yes' else: - form.AddRow(Text('', Size=(pad,1), AutoSizeText=False), SimpleButton('OK', Size=(5,1), ButtonColor=ButtonColor)) + form.AddRow(Text('', size=(pad, 1), auto_size_text=False), SimpleButton('OK', size=(5, 1), button_color=button_color)) form.Show() @@ -1652,10 +1653,10 @@ def ScrolledTextBox(*args, ButtonColor=None, YesNo=False, AutoClose=False, AutoC # True/False, path # # (True if Submit was pressed, false otherwise) # # ---------------------------------------------------------------------- # -def GetPathBox(Title, Message, DefaultPath='', ButtonColor=None, Size=(None,None)): - with FlexForm(Title, AutoSizeText=True, ButtonColor=ButtonColor) as form: - layout = [[Text(Message,AutoSizeText=True)], - [InputText(DefaultText=DefaultPath, Size=Size), FolderBrowse()], +def GetPathBox(title, message, default_path='', button_color=None, size=(None, None)): + with FlexForm(title, auto_size_text=True, button_color=button_color) as form: + layout = [[Text(message, auto_size_text=True)], + [InputText(default_text=default_path, size=size), FolderBrowse()], [Submit(), Cancel()]] (button, input_values) = form.LayoutAndShow(layout) @@ -1668,10 +1669,10 @@ def GetPathBox(Title, Message, DefaultPath='', ButtonColor=None, Size=(None,None # ============================== GetFileBox =========# # Like the Get folder box but for files # # ===================================================# -def GetFileBox(Title, Message, DefaultPath='',FileTypes=(("ALL Files", "*.*"),), ButtonColor=None, Size=(None,None)): - with FlexForm(Title, AutoSizeText=True, ButtonColor=ButtonColor) as form: - layout = [[Text(Message,AutoSizeText=True)], - [InputText(DefaultText=DefaultPath, Size=Size), FileBrowse(FileTypes=FileTypes)], +def GetFileBox(title, message, default_path='', file_types=(("ALL Files", "*.*"),), button_color=None, size=(None, None)): + with FlexForm(title, auto_size_text=True, button_color=button_color) as form: + layout = [[Text(message, auto_size_text=True)], + [InputText(default_text=default_path, size=size), FileBrowse(file_types=file_types)], [Submit(), Cancel()]] (button, input_values) = form.LayoutAndShow(layout) @@ -1685,10 +1686,10 @@ def GetFileBox(Title, Message, DefaultPath='',FileTypes=(("ALL Files", "*.*"),), # ============================== GetTextBox =========# # Get a single line of text # # ===================================================# -def GetTextBox(Title, Message, Default='', ButtonColor=None, Size=(None, None)): - with FlexForm(Title, AutoSizeText=True, ButtonColor=ButtonColor) as form: - layout = [[Text(Message,AutoSizeText=True)], - [InputText(DefaultText=Default, Size=Size)], +def GetTextBox(title, message, Default='', button_color=None, size=(None, None)): + with FlexForm(title, auto_size_text=True, button_color=button_color) as form: + layout = [[Text(message, auto_size_text=True)], + [InputText(default_text=Default, size=size)], [Submit(), Cancel()]] (button, input_values) = form.LayoutAndShow(layout) @@ -1701,21 +1702,21 @@ def GetTextBox(Title, Message, Default='', ButtonColor=None, Size=(None, None)): # ============================== SetGlobalIcon ======# # Sets the icon to be used by default # # ===================================================# -def SetGlobalIcon(Icon): +def SetGlobalIcon(icon): global _my_windows try: - with open(Icon, 'r') as icon_file: + with open(icon, 'r') as icon_file: pass except: raise FileNotFoundError - _my_windows.user_defined_icon = Icon + _my_windows.user_defined_icon = icon return True -# ============================== SetGlobalIcon ======# -# Sets the icon to be used by default # +# ============================== SetButtonColor =====# +# Sets the defaul button color # # ===================================================# def SetButtonColor(foreground, background): global DEFAULT_BUTTON_COLOR diff --git a/readme.md b/readme.md index 9f139bf7b..2926d40da 100644 --- a/readme.md +++ b/readme.md @@ -1,69 +1,69 @@ -# PySimpleGUI - -This really is a simple GUI, but also powerfully customizable. +# PySimpleGUI + +This really is a simple GUI, but also powerfully customizable. ![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) -I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? +I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. - + Python itself doesn't have a simple GUI solution... nor did the *many* GUI packages I tried. Most tried to do TOO MUCH, making it impossible for users to get started quickly. Others were just plain broken, requiring multiple files or other packages that were missing. - -The PySimpleGUI solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. - + +The PySimpleGUI solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. + You can add a GUI to your command line with a single line of code. With 3 or 4 lines of code you can add a fully customized GUI. And for you Machine Learning folks out there, a **single line** progress meter call that you can drop into any loop. ![progress meter 2](https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg) - The customization is via the form/dialog box builder that enables users to experience all of the normal GUI widgets without having to write a lot of code. - + The customization is via the form/dialog box builder that enables users to experience all of the normal GUI widgets without having to write a lot of code. - Features of PySimpleGUI include: - Text - Single Line Input - Buttons including these types: + + Features of PySimpleGUI include: + Text + Single Line Input + Buttons including these types: File Browse Folder Browse Non-closing return - Close form - Checkboxes - Radio Buttons - Icons - Multi-line Text Input - Scroll-able Output - Progress Bar - Async/Non-Blocking Windows + Close form + Checkboxes + Radio Buttons + Icons + Multi-line Text Input + Scroll-able Output + Progress Bar + Async/Non-Blocking Windows Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling Window + Persistent Windows + Redirect Python Output/Errors to scrolling Window 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) - + An example of many widgets used on a single form. A little further down you'll find the FIFTEEN lines of code required to create this complex form. ![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) - -## Getting Started with PySimpleGUI - -### Installing - - pip install PySimpleGUI - or -Simply download the file - PySimpleGUI.py and import it into your code - - -### Prerequisites - -Python 3 -tkinter - -Should run on all Python platforms that have tkinter running on them. Has been thoroughly tested on Windows. While not tested elsewhere, should work on Linux, Mac, Pi, etc. - + +## Getting Started with PySimpleGUI + +### Installing + + pip install PySimpleGUI + or +Simply download the file - PySimpleGUI.py and import it into your code + + +### Prerequisites + +Python 3 +tkinter + +Should run on all Python platforms that have tkinter running on them. Has been thoroughly tested on Windows. While not tested elsewhere, should work on Linux, Mac, Pi, etc. + ### Using To use in your code, simply import.... @@ -106,18 +106,18 @@ This feature of the Python language is utilized ***heavily*** as a method of cus Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't have to be specified on each and every call. def MsgBox(*args, - ButtonColor=None, - ButtonType=MSG_BOX_OK, - AutoClose=False, - AutoCloseDuration=None, - Icon=DEFAULT_WINDOW_ICON, - LineWidth=MESSAGE_BOX_LINE_WIDTH, - Font=None): + button_color=None, + button_type=MSG_BOX_OK, + auto_close=False, + auto_close_duration=None, + icon=DEFAULT_WINDOW_ICON, + line_width=MESSAGE_BOX_LINE_WIDTH, + font=None): If the caller wanted to change the button color to be black on yellow, the call would look something like this: SG.MsgBox('This box has a custom button color', - ButtonColor=('black', 'yellow')) + button_color=('black', 'yellow')) ![custombuttoncolor](https://user-images.githubusercontent.com/13696193/42599212-84f3fe2e-852c-11e8-8a60-4aad669a1fd6.jpg) @@ -194,15 +194,15 @@ We all have loops in our code. 'Isn't it joyful waiting, watching a counter scr ![progress meter 3](https://user-images.githubusercontent.com/13696193/42696332-dca3ca6e-8685-11e8-846b-6bee8362ee5f.jpg) EasyProgressMeter(Title, - CurrentValue, - MaxValue, + current_value, + max_value, *args, - Orientation=None, - BarColor=DEFAULT_PROGRESS_BAR_COLOR, - ButtonColor=None, - Size=DEFAULT_PROGRESS_BAR_SIZE, - Scale=(None, None), - BorderWidth=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): + orientation=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): Here's the one-line Progress Meter in action! @@ -226,7 +226,7 @@ It's both not enjoyable nor helpful to immediately jump into tweaking each and e ## COPY THIS DESIGN PATTERN! - with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: + with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], [SG.InputText(), SG.FileBrowse()], [SG.Submit(), SG.Cancel()]] @@ -247,7 +247,7 @@ Some elements are shortcuts, again meant to make it easy on the programmer. Rat Going through each line of code - with SG.FlexForm('SHA-1 & 256 Hash', AutoSizeText=True) as form: + with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: This creates a new form, storing it in the variable `form`. form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], @@ -285,20 +285,20 @@ If you have a SINGLE value being returned, it is written this way: ## All Widgets / Elements This code utilizes as many of the elements in one form as possible. - with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: - layout = [[Text('Here they all are!', Size=(30,1), Font=("Helvetica", 25), TextColor='red')], - [Text('Here is some text with font sizing', Font=("Helvetica", 15))], + with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: + layout = [[Text('Here they all are!', size=(30,1), font=("Helvetica", 25), text_color='red')], + [Text('Here is some text with font sizing', font=("Helvetica", 15))], [InputText()], - [Checkbox('My first checkbox!'), Checkbox('My second checkbox!', Default=True)], - [Radio('My first Radio!', "RADIO1", Default=True), Radio('My second checkbox!', "RADIO1")], - [Multiline(DefaultText='This is the DEFAULT text should you decide not to type anything', Scale=(2, 10))], - [InputCombo(['choice 1', 'choice 2'], Size=(20, 3))], - [Text('_' * 90, Size=(60, 1))], - [Text('Choose Source and Destination Folders', Size=(35,1))], - [Text('Source Folder', Size=(15, 1), AutoSizeText=False), InputText('Source'), FolderBrowse()], - [Text('Destination Folder', Size=(15, 1), AutoSizeText=False), InputText('Dest'), FolderBrowse()], + [Checkbox('My first checkbox!'), Checkbox('My second checkbox!', default=True)], + [Radio('My first Radio!', "RADIO1", default=True), Radio('My second checkbox!', "RADIO1")], + [Multiline(DefaultText='This is the DEFAULT text should you decide not to type anything', scale=(2, 10))], + [InputCombo(['choice 1', 'choice 2'], size=(20, 3))], + [Text('_' * 90, size=(60, 1))], + [Text('Choose Source and Destination Folders', size=(35,1))], + [Text('Source Folder', size=(15, 1), auto_size_text=False), InputText('Source'), FolderBrowse()], + [Text('Destination Folder', size=(15, 1), auto_size_text=False), InputText('Dest'), FolderBrowse()], [SimpleButton('Your Button with any text you want')], - [SimpleButton('Big Text', Size=(12,1), Font=("Helvetica", 20))], + [SimpleButton('Big Text', size=(12,1), font=("Helvetica", 20))], [Submit(), Cancel()]] (button, (values)) = form.LayoutAndShow(layout) @@ -306,7 +306,7 @@ This code utilizes as many of the elements in one form as possible. - MsgBox('Results', 'You clicked {}'.format(button),'The values returned from form', values , Font = ("Helvetica", 15)) + MsgBox('Results', 'You clicked {}'.format(button),'The values returned from form', values , font = ("Helvetica", 15)) This is a somewhat complex form with quite a bit of custom sizing to make things line up well. This is code you only have to write once. When looking at the code, remember that what you're seeing is a list of lists. Each row contains a list of Graphical Elements that are used to create the form. @@ -336,27 +336,27 @@ You've already seen a number of examples above that use blocking forms. Anytime NON-BLOCKING form call: - form.Show(NonBlocking=True) + form.Show(non_blocking=True) ### Beginning a Form The first step is to create the form object using the desired form customization. - with FlexForm('Everything bagel', AutoSizeText=True, DefaultElementSize=(30,1)) as form: + with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: Let's go through the options available when creating a form. def __init__(self, title, - DefaultElementSize=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), - AutoSizeText=DEFAULT_AUTOSIZE_TEXT, - Scale=(None, None), - Size=(None, None), - Location=(None, None), - ButtonColor=None,Font=None, - ProgressBarColor=(None,None), - IsTabbedForm=False, - BorderDepth=None, - AutoClose=False, - AutoCloseDuration=DEFAULT_AUTOCLOSE_TIME, - Icon=DEFAULT_WINDOW_ICON): + default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), + auto_size_text=DEFAULT_AUTOSIZE_TEXT, + scale=(None, None), + size=(None, None), + location=(None, None), + button_color=None,Font=None, + progress_bar_color=(None,None), + is_tabbed_form=False, + border_depth=None, + auto_close=False, + auto_close_duration=DEFAULT_AUTOCLOSE_TIME, + icon=DEFAULT_WINDOW_ICON): #### Sizes @@ -364,25 +364,25 @@ Note several variables that deal with "size". Element sizes are measured in cha The default Element size for PySimpleGUI is `(45,1)`. -Sizes can be set at the element level, or in this case, the size variables apply to all elements in the form. Setting `Size=(20,1)` in the form creation call will set all elements in the form to that size. +Sizes can be set at the element level, or in this case, the size variables apply to all elements in the form. Setting `size=(20,1)` in the form creation call will set all elements in the form to that size. -In addition to `size` there is a `scale` option. Scale will take the Element's size and scale it up or down depending on the scale value. `scale=(1,1)` doesn't change the Element's size. `scale=(2,1)` will set the Element's size to be twice as wide as the size setting. +In addition to `size` there is a `scale` option. `scale` will take the Element's size and scale it up or down depending on the scale value. `scale=(1,1)` doesn't change the Element's size. `scale=(2,1)` will set the Element's size to be twice as wide as the size setting. #### FlexForm - form-level variables overview A summary of the variables that can be changed when a FlexForm is created - DefaultElementSize - set default size for all elements in the form - AutoSizeText - true/false autosizing turned on / off - Scale - set scale value for all elements - ButtonColor - default button color (foreground, background) - Font - font name and size for all text items - ProgressBarColor - progress bar colors - IsTabbedForm - true/false indicates form is a tabbed or normal form - BorderDepth - style setting for buttons, input fields - AutoClose - true/false indicates if form will automatically close - AutoCloseDuration - how long in seconds before closing form - Icon - filename for icon that's displayed on the window on taskbar + default_element_size - set default size for all elements in the form + auto_size_text- true/false autosizing turned on / off + scale - set scale value for all elements + button_color- default button color (foreground, background) + font - font name and size for all text items + progress_bar_color - progress bar colors + is_tabbed_form - true/false indicates form is a tabbed or normal form + border_depth - style setting for buttons, input fields + auto_close - true/false indicates if form will automatically close + auto_close_duration - how long in seconds before closing form + icon - filename for icon that's displayed on the window on taskbar ## Elements @@ -424,11 +424,11 @@ The code is a crude representation of the GUI, laid out in text. The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. Text(Text, - Scale=(None, None), - Size=(None, None), - AutoSizeText=None, - Font=None, - TextColor=None) + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None, + text_color=None) Some commonly used elements have 'shorthand' versions of the functions to make the code more compact. The functions `T` and `Txt` are the same as calling `Text`. @@ -448,8 +448,8 @@ The values foreground and background can be the color names or the hex value for "#RRGGBB" -**AutoSizeText** -A `True` value for `AutoSizeText`, when placed on any Element, indicates that the width of the Element should be shrunk do the width of the text. This is particularly useful with `Buttons` as fixed-width buttons are somewhat crude looking. The default value is `False`. You will often see this setting on FlexForm definitions. +**auto_size_text** +A `True` value for `auto_size_text`, when placed on any Element, indicates that the width of the Element should be shrunk do the width of the text. This is particularly useful with `Buttons` as fixed-width buttons are somewhat crude looking. The default value is `False`. You will often see this setting on FlexForm definitions. **Shorthand functions** The shorthand functions for `Text` are `Txt` and `T` @@ -457,55 +457,55 @@ The shorthand functions for `Text` are `Txt` and `T` #### Multiline Text Element - layout = [[SG.Multiline('This is what a Multi-line Text Element looks like', Size=(45,5))]] + layout = [[SG.Multiline('This is what a Multi-line Text Element looks like', size=(45,5))]] ![multiline text](https://user-images.githubusercontent.com/13696193/42670464-0824c754-8629-11e8-9741-6ed08f924618.jpg) This Element doubles as both an input and output Element. The `DefaultText` optional parameter is used to indicate what to output to the window. - Multiline(DefaultText='', - EnterSubmits = False, - Scale=(None, None), - Size=(None, None), - AutoSizeText=None) + Multiline(default_text='', + enter_submits = False, + scale=(None, None), + size=(None, None), + auto_size_text=None) . - DefaultText - Text to display in the text box - EnterSubmits - Bool. If True, pressing Enter key submits form - Scale - Element's scale - Size - Element's size - AutoSizeText - Bool. Change width to match size of text + default_text - Text to display in the text box + enter_submits - Bool. If True, pressing Enter key submits form + scale - Element's scale + size - Element's size + auto_size_text - Bool. Change width to match size of text #### Output Element Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. More on this later. - form.AddRow(gg.Output(Size=(100,20))) + form.AddRow(gg.Output(size=(100,20))) ![output element](https://user-images.githubusercontent.com/13696193/42704820-5446959c-869f-11e8-849e-047ea280387a.jpg) - Output(Scale=(None, None), - Size=(None, None)) + Output(scale=(None, None), + size=(None, None)) . - Scale - How much to scale size of element - Size - Size of element (width, height) in characters + scale - How much to scale size of element + size - Size of element (width, height) in characters ### Input Elements - These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `Size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. + These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. #### Text Input Element layout = [[SG.InputText('Default text')]] ![inputtext](https://user-images.githubusercontent.com/13696193/42693515-610a716c-867d-11e8-9a00-7e7fcf771230.jpg) - def InputText(DefaultText = '', - Scale=(None, None), - Size=(None, None), - AutoSizeText=None) + def InputText(default_text = '', + scale=(None, None), + size=(None, None), + auto_size_text=None) . - DefaultText - Text initially shown in the input box - Scale - Amount size is scaled by - Size - (width, height) of element in characters - AutoSizeText - Bool. True is element should be sized to fit text + default_text - Text initially shown in the input box + scale - Amount size is scaled by + size - (width, height) of element in characters + auto_size_text- Bool. True is element should be sized to fit text Shorthand functions that are equivalent to `InputText` are `Input` and `In` @@ -517,88 +517,88 @@ Also known as a drop-down list. Only required parameter is the list of choices. ![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) - InputCombo(Values, - Scale=(None, None), - Size=(None, None), - AutoSizeText=None) + InputCombo(values, + scale=(None, None), + size=(None, None), + auto_size_text=None) . - Values Choices to be displayed. List of strings - Scale - Amount to scale size by - Size - (width, height) of element in characters - AutoSizeText - Bool. True if size should fit the text length + values - Choices to be displayed. List of strings + scale - Amount to scale size by + size - (width, height) of element in characters + auto_size_text - Bool. True if size should fit the text length #### Radio Button Element Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. - layout = [[SG.Radio('My first Radio!', "RADIO1", Default=True), SG.Radio('My second radio!', "RADIO1")]] + layout = [[SG.Radio('My first Radio!', "RADIO1", default=True), SG.Radio('My second radio!', "RADIO1")]] ![radio element](https://user-images.githubusercontent.com/13696193/42705705-327b4b6c-86a2-11e8-81a7-740e57646ba8.jpg) - Radio(Text, - GroupID, - Default=False, - Scale=(None, None), - Size=(None, None), - AutoSizeText=None, - Font=None) + Radio(text, + group_id, + default=False, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None) . - Text - Text to display next to button - GroupID - Groups together multiple Radio Buttons. Can be any value - Default - Bool. Initial state - Scale - Amount to scale size of element - Size - (width, height) size of element in characters - AutoSizeText - Bool. True if should size width to fit text - Font - Font type and size for text display + text - Text to display next to button + group_id - Groups together multiple Radio Buttons. Can be any value + default - Bool. Initial state + scale - Amount to scale size of element + size- (width, height) size of element in characters + auto_size_text - Bool. True if should size width to fit text + font - Font type and size for text display #### Checkbox Element Checkbox elements are like Radio Button elements. They return a bool indicating whether or not they are checked. - layout = [[SG.Checkbox('My first Checkbox!', Default=True), SG.Checkbox('My second Checkbox!')]] + layout = [[SG.Checkbox('My first Checkbox!', default=True), SG.Checkbox('My second Checkbox!')]] ![checkbox element](https://user-images.githubusercontent.com/13696193/42717015-655d73d2-86cc-11e8-9c69-3c810f48e578.jpg) - Checkbox(Text, - Default=False, - Scale=(None, None), - Size=(None, None), - AutoSizeText=None, - Font=None): + Checkbox(text, + default=False, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None): . - Text - Text to display next to checkbox - Default - Bool. Initial state - Scale - Amount to scale size of element - Size - (width, height) size of element in characters - AutoSizeText - Bool. True if should size width to fit text - Font - Font type and size for text display + text - Text to display next to checkbox + default- Bool. Initial state + scale - Amount to scale size of element + size - (width, height) size of element in characters + auto_size_text- Bool. True if should size width to fit text + font- Font type and size for text display #### Spin Element An up/down spinner control. The valid values are passed in as a list. - layout = [[SG.Spin([i for i in range(1,11)], InitialValue=1), SG.Text('Volume level')]] + layout = [[SG.Spin([i for i in range(1,11)], initial_value=1), SG.Text('Volume level')]] ![spin element](https://user-images.githubusercontent.com/13696193/42717231-8ddb51d4-86cd-11e8-827a-75f2237477fa.jpg) - Spin(Values, - InitialValue=None, - Scale=(None, None), - Size=(None, None), - AutoSizeText=None, - Font=None) + Spin(values, + intiial_value=None, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None) . - Values - List of valid values - InitialValue - String with initial value - Scale - Amount to scale size of element - Size - (width, height) size of element in characters - AutoSizeText - Bool. True if should size width to fit text - Font - Font type and size for text display + values - List of valid values + initial_value - String with initial value + scale - Amount to scale size of element + size - (width, height) size of element in characters + auto_size_text - Bool. True if should size width to fit text + font - Font type and size for text display #### Button Element Buttons are the most important element of all! They cause the majority of the action to happen. After all, it's a button press that will get you out of a form, whether it but Submit or Cancel, one way or another a button is involved in all forms. The only exception is to this is when the user closes the window using the "X" in the upper corner which means no button was involved. @@ -620,12 +620,12 @@ Read Form - This is an async form button that will read a snapshot of all of the While it's possible to build forms using the Button Element directly, you should never need to do that. There are pre-made buttons and shortcuts that will make life much easier. The most basic Button element call to use is `SimpleButton` - SimpleButton(Text, - Scale=(None, None), - Size=(None, None), - AutoSizeText=None, - ButtonColor=None, - Font=None) + SimpleButton(text, + scale=(None, None), + size=(None, None), + auto_size_text=None, + button_color=None, + font=None) Pre-made buttons include: @@ -667,16 +667,16 @@ layout = [[SG.SimpleButton('My Button')]] ![singlebutton](https://user-images.githubusercontent.com/13696193/42718281-9453deca-86d5-11e8-83c7-4b6d33720858.jpg) -All buttons can have their text changed by changing the `ButtonText` variable. +All buttons can have their text changed by changing the `button_text` variable. **File Types** -The `FileBrowse` button has an additional setting named `FileTypes`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is +The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is FileTypes=(("ALL Files", "*.*"),) This code produces a form where the Browse button only shows files of type .TXT - layout = [[SG.In() ,SG.FileBrowse(FileTypes=(("Text Files", "*.txt"),))]] + layout = [[SG.In() ,SG.FileBrowse(file_types=(("Text Files", "*.txt"),))]] ***The ENTER key*** The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. Keep this in mind when designing forms. @@ -693,23 +693,23 @@ If you want a bit more customization of your meter, then you can go up 1 level a You setup the progress meter by calling - my_meter = ProgressMeter(Title, - MaxValue, + my_meter = ProgressMeter(title, + max_value, *args, - Orientation=None, - BarColor=DEFAULT_PROGRESS_BAR_COLOR, - ButtonColor=None, - Size=DEFAULT_PROGRESS_BAR_SIZE, - Scale=(None, None), - BorderWidth=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) + orientantion=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) Then to update the bar within your loop return_code = ProgressMeterUpdate(my_meter, - Value, + value, *args): Putting it all together you get this design pattern - my_meter = SG.ProgressMeter('Meter Title', 100000, Orientation='Vert') + my_meter = SG.ProgressMeter('Meter Title', 100000, orentation='Vert') for i in range(0, 100000): SG.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') @@ -720,17 +720,17 @@ The final way of using a Progress Meter with PySimpleGUI is to build a custom fo #### Output The Output Element is a re-direction of Stdout. Anything "printed" will be displayed in this element. - Output(Scale=(None, None), - Size=(None, None)) + Output(scale=(None, None), + size=(None, None)) Here's a complete solution for a chat-window using an Async form with an Output Element import PySimpleGUI as g - with g.FlexForm('Chat Window', AutoSizeText=True, DefaultElementSize=(30, 2)) as form: - form.AddRow(g.Text('This is where standard out is being routed', Size=[40,1])) - form.AddRow(g.Output(Size=(80, 20))) - form.AddRow(g.Multiline(Size=(70, 5), EnterSubmits=True), g.ReadFormButton('SEND', ButtonColor=(g.YELLOWS[0], g.BLUES[0])), g.SimpleButton('EXIT', ButtonColor=(g.YELLOWS[0], g.GREENS[0]))) + with g.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + form.AddRow(g.Text('This is where standard out is being routed', size=[40,1])) + form.AddRow(g.Output(size=(80, 20))) + form.AddRow(g.Multiline(size=(70, 5), enter_submits=True), g.ReadFormButton('SEND', button_color=(g.YELLOWS[0], g.BLUES[0])), g.SimpleButton('EXIT', button_color=(g.YELLOWS[0], g.GREENS[0]))) # ---===--- Loop taking in user input and printing it --- # while True: @@ -773,9 +773,11 @@ While not an "issue" this is a *stern warning* A MikeTheWatchGuy production... entirely responsible for this code.... unless it causes you trouble in which case I'm not at all responsible. ## Versioning - -1.0.9 - July 10, 2018 - Initial Release -1.0.21 - July 13, 2018 - Readme updates +|Version | Description | +|--|--| +| 1.0.9 | July 10, 2018 - Initial Release | +| 1.0.21 | July 13, 2018 - Readme updates | +| 2.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case ## Code Condition From 7668681af32a0ac03eb6ba677ce21ed7f47a448f Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 16 Jul 2018 16:10:28 -0400 Subject: [PATCH 031/209] Update readme.md --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index 2926d40da..848228613 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,8 @@ # PySimpleGUI +[note - if you are using version 1.x, you'll need to change all of your options variables in the SDK calls so that they are lower case. Sorry for this change, but this change was required] + This really is a simple GUI, but also powerfully customizable. ![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) From ed79ffca939711c0ae5abd553cffe837ea0dfa68 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 16 Jul 2018 18:36:17 -0400 Subject: [PATCH 032/209] Fixed Font variable, new Quit lazy function Forgot a couple of variables named Font that should be font. Added a new Lazy function Quit() which adds a SimpleButton with text 'Quit'. --- PySimpleGUI.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index aaf030a01..17e039e41 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -777,6 +777,10 @@ def Ok(button_text='Ok', scale=(None, None), size=(None, None), auto_size_text=N def Cancel(button_text='Cancel', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None, font=None): return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color, font=font) +# ------------------------- QUIT BUTTON Element lazy function ------------------------- # +def Quit(button_text='Quit', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None, font=None): + return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color, font=font) + # ------------------------- YES BUTTON Element lazy function ------------------------- # def Yes(button_text='Yes', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None): return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color) @@ -792,8 +796,8 @@ def SimpleButton(button_text, scale=(None, None), size=(None, None), auto_size_t # ------------------------- GENERIC BUTTON Element lazy function ------------------------- # # this is the only button that REQUIRES button text field -def ReadFormButton(button_text, scale=(None, None), size=(None, None), auto_size_text=None, button_color=None, Font=None): - return Button(READ_FORM, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color, font=Font) +def ReadFormButton(button_text, scale=(None, None), size=(None, None), auto_size_text=None, button_color=None, font=None): + return Button(READ_FORM, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color, font=font) #------------------------------------------------------------------------------------------------------# # ------- FUNCTION InitializeResults. Sets up form results matrix ------- # @@ -1302,17 +1306,17 @@ def MsgBoxAutoClose(*args, button_color=None, auto_close=True, auto_close_durati # ============================== MsgBoxError =====# # Like MsgBox but presents RED BUTTONS # # ===================================================# -def MsgBoxError(*args, button_color=DEFAULT_ERROR_BUTTON_COLOR, auto_close=False, auto_close_duration=None, Font=None): +def MsgBoxError(*args, button_color=DEFAULT_ERROR_BUTTON_COLOR, auto_close=False, auto_close_duration=None, font=None): ''' Display a MsgBox with a red button :param args: :param button_color: :param auto_close: :param auto_close_duration: - :param Font: + :param font: :return: ''' - MsgBox(*args, button_color=button_color, auto_close=auto_close, auto_close_duration=auto_close_duration, font=Font) + MsgBox(*args, button_color=button_color, auto_close=auto_close, auto_close_duration=auto_close_duration, font=font) return # ============================== MsgBoxCancel =====# From d6c80477702e134e209e0abeb9a465e1e08999ab Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 16 Jul 2018 19:22:03 -0400 Subject: [PATCH 033/209] Readme updates --- readme.md | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/readme.md b/readme.md index 848228613..70ab9875c 100644 --- a/readme.md +++ b/readme.md @@ -1,11 +1,13 @@ # PySimpleGUI -[note - if you are using version 1.x, you'll need to change all of your options variables in the SDK calls so that they are lower case. Sorry for this change, but this change was required] - This really is a simple GUI, but also powerfully customizable. -![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) + import PySimpleGUI as SG + + SG.MsgBox('My Message Box', 'This is the shortest GUI program ever!') + +![snap0102](https://user-images.githubusercontent.com/13696193/42781058-1d28d9fa-8913-11e8-847e-5c2afc16ca4c.jpg) I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? @@ -13,15 +15,14 @@ With a simple GUI, it becomes practical to "associate" .py files with the python Python itself doesn't have a simple GUI solution... nor did the *many* GUI packages I tried. Most tried to do TOO MUCH, making it impossible for users to get started quickly. Others were just plain broken, requiring multiple files or other packages that were missing. -The PySimpleGUI solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. +The `PySimpleGUI` solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? -You can add a GUI to your command line with a single line of code. With 3 or 4 lines of code you can add a fully customized GUI. And for you Machine Learning folks out there, a **single line** progress meter call that you can drop into any loop. +You can add a GUI to your command line with a single line of code. With 3 or 4 lines of code you can add a fully customized GUI. And for you Machine Learning folks out there, a **single line** progress meter call that you can drop into any loop to get a graphic like this one: ![progress meter 2](https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg) - The customization is via the form/dialog box builder that enables users to experience all of the normal GUI widgets without having to write a lot of code. Features of PySimpleGUI include: @@ -76,7 +77,7 @@ Then use either "high level" API calls or build your own forms. SG.MsgBox('This is my first message box') ![simple msgbox](https://user-images.githubusercontent.com/13696193/42597824-1749b160-8528-11e8-9114-374bf9731b30.jpg) -Yes, it's just that easy to have a window appear on the screen using Python. +Yes, it's just that easy to have a window appear on the screen using Python. With PySimpleGUI, making a custom form appear isn't much more difficult. The goal is to get you running on your GUI within ***minutes***, not hours nor days. ## APIs @@ -166,11 +167,15 @@ The differences tend to be the number and types of buttons. Here are the calls ![msgbox autoclose](https://user-images.githubusercontent.com/13696193/42599855-8e147572-852e-11e8-8c23-7ec771909062.jpg) - SG.ScrolledTextBox(my_text, Height=10) + SG.ScrolledTextBox(my_text, height=10) ![scrolledtextbox](https://user-images.githubusercontent.com/13696193/42600800-a44f4562-8531-11e8-8c21-51dd70316879.jpg) -Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. +Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. Your code could contain a line like: + + sprint(f'My variables values include x={x}', f'y={y}') + +This becomes a debug print of sorts that will route to a scrolled window. #### High Level User Input @@ -195,7 +200,7 @@ There are 3 very basic user input high-level function calls. It's expected that We all have loops in our code. 'Isn't it joyful waiting, watching a counter scrolling past in a text window? How about one line of code to get a progress meter, that contains statistics about your code? ![progress meter 3](https://user-images.githubusercontent.com/13696193/42696332-dca3ca6e-8685-11e8-846b-6bee8362ee5f.jpg) - EasyProgressMeter(Title, + EasyProgressMeter(title, current_value, max_value, *args, @@ -218,7 +223,8 @@ That line of code resulted in this window popping up and updating. A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. - if not SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message'): break + if not SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message'): + break # Custom Form API Calls @@ -243,11 +249,13 @@ You will use this design pattern or code template for all of your "normal" (bloc > Copy, Paste, Run. -PySimpleGUI's goal with the API is to be easy on the programmer. An attempt was made to make the program's code visually match the window on the screen. The way this is done is that a GUI is broken up into "Rows". Then each row is broke up into "Elements" or "Widgets". Each element is specified by names such as Text, Button, Checkbox, etc. +PySimpleGUI's goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the SDK to visually match what's on the screen. + +Forms are represented as Python lists. There are 2 lists in particular. One is a list of rows that form up a GUI screen. The other is a list of Elements (or Widgets) on each row. Each Elements is specified by names such as Text, Button, Checkbox, etc. -Some elements are shortcuts, again meant to make it easy on the programmer. Rather than writing a `Button`, with name = "Submit", etc, the caller simply writes `Submit`. +Some elements are shortcuts, again meant to make it easy on the programmer. Rather than writing a `Button`, with name = "Submit", etc, the caller can simply writes `Submit`. Some examples include: `Text` has a short-cut function named `T`. `TextInput` has `In`. See each API call for the shortcuts. -Going through each line of code +Going through each line of code in the above form will help explain how to use this design patter. Copy, modify and run it! with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: This creates a new form, storing it in the variable `form`. @@ -327,7 +335,7 @@ You can see in the MsgBox that the values returned are a list. Each input field # Building Custom Forms -You will find it much easier to write code using PySimpleGUI is you use features that show you documentation about the API call you are making. In PyCharm 2 commands are helpful. +You will find it much easier to write code using PySimpleGUI if you use an IDE such as PyCharm. The features that show you documentation about the API call you are making will help you determine which settings you want to change, if any. In PyCharm, two commands are particularly helpful. Control-Q (when cursor is on function name) brings up a box with the function definition Control-P (when cursor inside function call "()") shows a list of parameters and their default values @@ -344,9 +352,10 @@ NON-BLOCKING form call: The first step is to create the form object using the desired form customization. with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: -Let's go through the options available when creating a form. - def __init__(self, title, +This is the definition of the FlexForm object: + + def FlexForm(title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=DEFAULT_AUTOSIZE_TEXT, scale=(None, None), @@ -764,6 +773,7 @@ Use the example programs as a starting basis for your GUI. Copy, paste, modify ## Fun Stuff + ## Known Issues While not an "issue" this is a *stern warning* **Do not attempt** to call `PySimpleGUI` from multiple threads! It's `tkinter` based and `tkinter` has issues with multiple threads @@ -801,3 +811,5 @@ This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence + + From e2ee6bd9af8a77e19519b18f79bb9edc8c218066 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 17 Jul 2018 11:50:37 -0400 Subject: [PATCH 034/209] More readme changes --- readme.md | 101 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 71 insertions(+), 30 deletions(-) diff --git a/readme.md b/readme.md index 70ab9875c..a1d078d24 100644 --- a/readme.md +++ b/readme.md @@ -50,7 +50,7 @@ An example of many widgets used on a single form. A little further down you'll ![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) - + ----- ## Getting Started with PySimpleGUI ### Installing @@ -79,6 +79,7 @@ Then use either "high level" API calls or build your own forms. Yes, it's just that easy to have a window appear on the screen using Python. With PySimpleGUI, making a custom form appear isn't much more difficult. The goal is to get you running on your GUI within ***minutes***, not hours nor days. +--- ## APIs PySimpleGUI can be broken down into 2 types of API's: @@ -123,6 +124,7 @@ If the caller wanted to change the button color to be black on yellow, the call button_color=('black', 'yellow')) ![custombuttoncolor](https://user-images.githubusercontent.com/13696193/42599212-84f3fe2e-852c-11e8-8a60-4aad669a1fd6.jpg) +--- ### High Level API Calls @@ -214,7 +216,7 @@ We all have loops in our code. 'Isn't it joyful waiting, watching a counter scr Here's the one-line Progress Meter in action! for i in range(1,10000): - SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') + SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') That line of code resulted in this window popping up and updating. @@ -226,6 +228,9 @@ With a little trickery you can provide a way to break out of your loop using the if not SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message'): break +***Be sure and add one to your loop counter*** so that your counter goes from 1 to the max value. If you do not add one, your counter will never hit the max value. Instead it will go from 0 to max-1. + +--- # Custom Form API Calls This is the FUN part of the programming of this GUI. In order to really get the most out of the API, you should be using an IDE that supports auto complete or will show you the definition of the function. This will make customizing go smoother. @@ -240,20 +245,26 @@ It's both not enjoyable nor helpful to immediately jump into tweaking each and e [SG.Submit(), SG.Cancel()]] (button, (source_filename, )) = form.LayoutAndShow(form_rows) -This context manager contains all of the code needed to specify, show and retrieve results for this form: -![sha hash](https://user-images.githubusercontent.com/13696193/42603149-a56acf3a-853a-11e8-91de-771efd3a65a8.jpg) +## COPY this non-context manager design pattern TOO + + form = SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + [SG.InputText(), SG.FileBrowse()], + [SG.Submit(), SG.Cancel()]] + (button, (source_filename,)) = form.LayoutAndShow(form_rows) -It's important to use the "with" context manager. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. -You will use this design pattern or code template for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. +These 2 design patters both produce this custom form: -> Copy, Paste, Run. +![sha hash](https://user-images.githubusercontent.com/13696193/42603149-a56acf3a-853a-11e8-91de-771efd3a65a8.jpg) -PySimpleGUI's goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the SDK to visually match what's on the screen. +It's important to use the "with" context manager so that resources are freed as quickly as possible, using the currently executing thread. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. -Forms are represented as Python lists. There are 2 lists in particular. One is a list of rows that form up a GUI screen. The other is a list of Elements (or Widgets) on each row. Each Elements is specified by names such as Text, Button, Checkbox, etc. +The second design pattern is not context manager based. There are times when the context manager hides errors. If you are struggling with an unknown error, try modifying the code to run without a context manager. -Some elements are shortcuts, again meant to make it easy on the programmer. Rather than writing a `Button`, with name = "Submit", etc, the caller can simply writes `Submit`. Some examples include: `Text` has a short-cut function named `T`. `TextInput` has `In`. See each API call for the shortcuts. +You will use these design patterns or code templates for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. This is the most basic / normal of the design patterns. + +### Line by line explanation Going through each line of code in the above form will help explain how to use this design patter. Copy, modify and run it! @@ -271,7 +282,20 @@ Now we're on the second row of the form. On this row there are 2 elements. The The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its value to the caller. (button, (source_filename, )) = form.LayoutAndShow(form_rows) -This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field. +This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field + +--- +### Design Goals +> Copy, Paste, Run. + +`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the SDK to visually match what's on the screen. + +Forms are represented as Python lists. There are 2 lists in particular. One is a list of rows that form up a GUI screen. The other is a list of Elements (or Widgets) on each row. Each Elements is specified by names such as Text, Button, Checkbox, etc. + +Some elements are shortcuts, meant to make it easy on the programmer who will write less code using them. Rather than writing a `Button`, with `button_name = "Submit"`, etc, the caller can simply writes `Submit`. Some examples include: `Text` has a short-cut function named `T`. `TextInput` has `In`. See each API call for the shortcuts. + + +--- ## Return values @@ -279,19 +303,22 @@ This is the code that **displays** the form, collects the information and return (button, (value1, value2, ...)) -Don't forget all those ()'s of your values won't be coreectly assigned. +Each of the Elements that are Input Elements will have a value in the list of return values. You can unpack your GUI directly into the variables you want to use. + + (button, (filename, folder1, folder2, should_overwrite) = form.LayoutAndShow(form_rows) + If you have a SINGLE value being returned, it is written this way: (button, (value1,)) = form.LayoutAndShow(form_rows) - Another way of parsing the return values is to store the list of values into a variable that is then referenced. + Another way of parsing the return values is to store the list of values into a variable representing the list of values. - (button, (value)) = form.LayoutAndShow(form_rows) - value1 = values[0] - value2 = values[1] + (button, (value_list)) = form.LayoutAndShow(form_rows) + value1 = value_list[0] + value2 = value_list[1] ... - +--- ## All Widgets / Elements This code utilizes as many of the elements in one form as possible. @@ -313,9 +340,6 @@ This code utilizes as many of the elements in one form as possible. (button, (values)) = form.LayoutAndShow(layout) - - - MsgBox('Results', 'You clicked {}'.format(button),'The values returned from form', values , font = ("Helvetica", 15)) This is a somewhat complex form with quite a bit of custom sizing to make things line up well. This is code you only have to write once. When looking at the code, remember that what you're seeing is a list of lists. Each row contains a list of Graphical Elements that are used to create the form. @@ -325,15 +349,13 @@ This is a somewhat complex form with quite a bit of custom sizing to make things Clicking the Submit button caused the form call to return. The call to MsgBox resulted in this dialog box. ![results](https://user-images.githubusercontent.com/13696193/42604952-502f64e6-8543-11e8-8045-bc10d38c5fd4.jpg) -One important aspect of this example is the return codes: (button, (values)) = form.LayoutAndShow(layout) -The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. +**`Note, button value can be None`**. The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. - - +--- # Building Custom Forms You will find it much easier to write code using PySimpleGUI if you use an IDE such as PyCharm. The features that show you documentation about the API call you are making will help you determine which settings you want to change, if any. In PyCharm, two commands are particularly helpful. @@ -690,24 +712,30 @@ This code produces a form where the Browse button only shows files of type .TXT layout = [[SG.In() ,SG.FileBrowse(file_types=(("Text Files", "*.txt"),))]] ***The ENTER key*** - The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. Keep this in mind when designing forms. + The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. + +--- #### ProgressBar The `ProgressBar` element is used to build custom Progress Bar forms. It is HIGHLY recommended that you use the functions that provide a complete progress meter solution for you. Progress Meters are not easy to work with because the forms have to be non-blocking and they are tricky to debug. -The "easiest" way to get progress meters into your code is to use the `EasyProgessMeter` API. This consists of a pair of functions, `EasyProgessMeter` and `EasyProgressMeterCancel`. You can easily cancel any progress meter by calling it with the current value = max value. This will mark the meter as expired and close the window. +The **easiest** way to get progress meters into your code is to use the `EasyProgessMeter` API. This consists of a pair of functions, `EasyProgessMeter` and `EasyProgressMeterCancel`. You can easily cancel any progress meter by calling it with the current value = max value. This will mark the meter as expired and close the window. You've already seen EasyProgressMeter calls presented earlier in this readme. SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') -If you want a bit more customization of your meter, then you can go up 1 level and use the calls to `ProgressMeter` and `ProgressMeterUpdate` +The return value for `EasyProgressMeter` is: +`True` if meter updated correctly +`False` if user clicked the Cancel button, closed the form, or vale reached the max value. +**Customized Progress Bar** +If you want a bit more customization of your meter, then you can go up 1 level and use the calls to `ProgressMeter` and `ProgressMeterUpdate`. These APIs behave like an object we're all used to. First you create the `ProgressMeter` object, then you call the `Update` method to update it. You setup the progress meter by calling my_meter = ProgressMeter(title, max_value, *args, - orientantion=None, + d orientantion=None, bar_color=DEFAULT_PROGRESS_BAR_COLOR, button_color=None, size=DEFAULT_PROGRESS_BAR_SIZE, @@ -725,6 +753,7 @@ Putting it all together you get this design pattern for i in range(0, 100000): SG.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') + The final way of using a Progress Meter with PySimpleGUI is to build a custom form with a `ProgressBar` Element in the form. You will need to run your form as a non-blocking form. When you are ready to update your progress bar, you call the `UpdateBar` method for the `ProgressBar` element itself. @@ -772,7 +801,19 @@ Use the example programs as a starting basis for your GUI. Copy, paste, modify `Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. ## Fun Stuff +Here are some things to try if you're bored or want to further customize + +**Random colors** +To set a button or text to a random color, use the string `'random'` as the color value. You can also call `PySimpleGUI.GetRandomColor`. +To get a random color pair call `PySimpleGUI.GetRandomColorPair`. This returns a tuple containing a random color and that color's compliment. +sprint +Call `PySimpleGUI.sprint` to "print" to a scrolled Text Box. This is simply a function pointing to + +**Task Bar Icon** +Call `PySimpleGUI.SetGlobalIcon` to change the icon shown on the Windows Task Bar and on the program's Task Bar in the upper left corner. +**Button Color** +To change the button color globally call `PySimpleGUI.SetButtonColor`. Removes need to specify in every form or button call if you have a single button color for all buttons. ## Known Issues While not an "issue" this is a *stern warning* @@ -789,7 +830,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it |--|--| | 1.0.9 | July 10, 2018 - Initial Release | | 1.0.21 | July 13, 2018 - Readme updates | -| 2.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case +| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case ## Code Condition @@ -804,7 +845,7 @@ It's a recipe for success if done right. PySimpleGUI has completed the "Make it ## License -This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details +This project is limited to non-commercial applications. If you wish to use it commercially, please contact one of the authors. ## Acknowledgments From 951f3f1a6dd3a6b82661ff1c356c13a1feaa2f86 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 17 Jul 2018 13:43:58 -0400 Subject: [PATCH 035/209] New Form Function - CloseNonBlockingForm, fix for context managers Previously an exception within the "with" block was not correctly passing along exceptions. New function to help with non-blocking forms. For forms that need to be closed that haven't been closed by a button, a new function was needed. CloseNonBlockingForm is the new function. --- PySimpleGUI.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 17e039e41..d3724cd7c 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -686,6 +686,10 @@ def Close(self): self.RootNeedsDestroying = True return results + def CloseNonBlockingForm(self): + self.TKroot.destroy() + _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 + def OnClosingCallback(self): return @@ -694,7 +698,7 @@ def __enter__(self): def __exit__(self, *a): self.__del__() - return self + return False def __del__(self): for row in self.Rows: From bd42d2410dc6a083f5a5e72f7d74839ef601971a Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 17 Jul 2018 16:47:19 -0400 Subject: [PATCH 036/209] More readme updates! --- readme.md | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/readme.md b/readme.md index a1d078d24..d666a286d 100644 --- a/readme.md +++ b/readme.md @@ -11,9 +11,11 @@ This really is a simple GUI, but also powerfully customizable. I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? -With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. +There are a number of 'easy to use' Python GUIs, but they're quite limiting. PySimpleGUI tried to take the best of packages like `EasyGUI`(no longer maintained) and `WxSimpleGUI` (a great package, but was too limited for my application). `PySimpleGUI` provides similar single-call-message-box solutions as you'll see. + +GUI Packages with more functionality, like QT and WxPython, require configuring and can take a ***week*** to get *reasonably familiar* with the interfaces. -Python itself doesn't have a simple GUI solution... nor did the *many* GUI packages I tried. Most tried to do TOO MUCH, making it impossible for users to get started quickly. Others were just plain broken, requiring multiple files or other packages that were missing. +With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. The `PySimpleGUI` solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? @@ -236,8 +238,8 @@ With a little trickery you can provide a way to break out of your loop using the This is the FUN part of the programming of this GUI. In order to really get the most out of the API, you should be using an IDE that supports auto complete or will show you the definition of the function. This will make customizing go smoother. It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. Let's start with a basic Browse for a file and do something with it. - -## COPY THIS DESIGN PATTERN! +# Copy these design patterns! +## Pattern 1 - With Context Manager with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], @@ -245,12 +247,12 @@ It's both not enjoyable nor helpful to immediately jump into tweaking each and e [SG.Submit(), SG.Cancel()]] (button, (source_filename, )) = form.LayoutAndShow(form_rows) -## COPY this non-context manager design pattern TOO +## Pattern 2 - No Context Manager - form = SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], - [SG.InputText(), SG.FileBrowse()], - [SG.Submit(), SG.Cancel()]] + form = SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + [SG.InputText(), SG.FileBrowse()], + [SG.Submit(), SG.Cancel()]] (button, (source_filename,)) = form.LayoutAndShow(form_rows) @@ -792,6 +794,10 @@ Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format Each of the tabs of the form is in fact a form. The same steps are taken to create the form as before. A `FlexForm` is created, then rows are filled with Elements, and finally the form is shown. When calling `ShowTabbedForm`, each form is passed in as a tuple. The tuple has the format: `(the form, the rows, a label shown on the tab)` ## Asynchronous (Non-Blocking) Forms +While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. + + +## ## Sample Applications Use the example programs as a starting basis for your GUI. Copy, paste, modify and run! The demo files are: @@ -832,20 +838,23 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 1.0.21 | July 13, 2018 - Readme updates | | 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case - ## Code Condition +## Code Condition Make it run Make it right Make it fast -It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor on hiding implementation details, naming conventions, PEP 8. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. +It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor for PEP 8 compliance. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. -## Authors +While the internals to PySimpleGUI are a tad sketchy, the public interfaces into the SDK are more strictly defined and comply with PEP 8 for the most part. +## Authors +MikeTheWatchGuy ## License This project is limited to non-commercial applications. If you wish to use it commercially, please contact one of the authors. +For non-commercial individual, the GNU Lesser General Public License (LGPL 3) applies. ## Acknowledgments From e1ce8d591b26be97da5f3f2dc66a04ebe8ec3571 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 17 Jul 2018 22:08:11 -0400 Subject: [PATCH 037/209] password_char option. SetOptions function Added a new "password_char" option to the InputText Element . Set to "*" to hide characters entered. SetOptions function - sets global defaults. --- PySimpleGUI.py | 65 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 5 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index d3724cd7c..6bf261425 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -157,12 +157,13 @@ def __del__(self): pass # ---------------------------------------------------------------------- # -# Input Class # +# Input Class # # ---------------------------------------------------------------------- # class InputText(Element): - def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto_size_text=None): + def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char=''): self.DefaultText = default_text + self.PasswordCharacter = password_char super().__init__(INPUT_TEXT, scale, size, auto_size_text) return @@ -175,6 +176,7 @@ def ReturnKeyHandler(self, event): if element.BType == CLOSES_WIN or element.BType == READ_FORM: element.ButtonCallBack() return + def __del__(self): super().__del__() @@ -1011,7 +1013,7 @@ def ConvertFlexToTK(MyFlexForm): tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height,command=element.ButtonCallBack, justify=tk.LEFT, foreground=bc[0], background=bc[1], bd=border_depth) element.TKButton = tkbutton # not used yet but save the TK button in case wraplen = tkbutton.winfo_reqwidth() # width of widget in Pixels - tkbutton.configure(wraplength=wraplen, font=font) # set wrap to width of widget + tkbutton.configure(wraplength=wraplen+10, font=font) # set wrap to width of widget tkbutton.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) if not focus_set and btype == CLOSES_WIN: focus_set = True @@ -1023,7 +1025,8 @@ def ConvertFlexToTK(MyFlexForm): default_text = element.DefaultText element.TKStringVar = tk.StringVar() element.TKStringVar.set(default_text) - element.TKEntry = tk.Entry(tk_row_frame, width=element_size[0], textvariable=element.TKStringVar, bd=border_depth, font=font) + show = element.PasswordCharacter if element.PasswordCharacter else "" + element.TKEntry = tk.Entry(tk_row_frame, width=element_size[0], textvariable=element.TKStringVar, bd=border_depth, font=font, show=show) element.TKEntry.bind('', element.ReturnKeyHandler) element.TKEntry.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) if not focus_set: @@ -1718,11 +1721,63 @@ def SetGlobalIcon(icon): pass except: raise FileNotFoundError - _my_windows.user_defined_icon = icon return True +# ============================== SetOptions =========# +# Sets the icon to be used by default # +# ===================================================# +def SetOptions(icon=None, default_button_color=(None,None), default_element_size=(None,None), default_margins=(None,None), default_element_padding=(None,None), + default_auto_size_text=None, default_font=None, default_border_width=None, default_autoclose_time=None): + global DEFAULT_ELEMENT_SIZE + global DEFAULT_MARGINS # Margins for each LEFT/RIGHT margin is first term + global DEFAULT_ELEMENT_PADDING # Padding between elements (row, col) in pixels + global DEFAULT_AUTOSIZE_TEXT + global DEFAULT_FONT + global DEFAULT_BORDER_WIDTH + global DEFAULT_AUTOCLOSE_TIME + global DEFAULT_BUTTON_COLOR + + global _my_windows + + if icon: + try: + with open(icon, 'r') as icon_file: + pass + except: + raise FileNotFoundError + _my_windows.user_defined_icon = icon + + if default_button_color != (None,None): + DEFAULT_BUTTON_COLOR = (default_button_color[0], default_button_color[1]) + + if default_element_size != (None,None): + DEFAULT_ELEMENT_SIZE = default_element_size + + if default_margins != (None,None): + DEFAULT_MARGINS = default_margins + + if default_element_padding != (None,None): + DEFAULT_ELEMENT_PADDING = default_element_padding + + if default_auto_size_text: + DEFAULT_AUTOSIZE_TEXT = default_auto_size_text + + if default_font !=None: + DEFAULT_FONT = default_font + + if default_border_width != None: + DEFAULT_BORDER_WIDTH = default_border_width + + if default_autoclose_time != None: + DEFAULT_AUTOCLOSE_TIME = default_autoclose_time + + + + return True + + # ============================== SetButtonColor =====# # Sets the defaul button color # # ===================================================# From 7a3352946e790b6a2f500df00ae851fa4bedb493 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 17 Jul 2018 22:49:16 -0400 Subject: [PATCH 038/209] More readme changes --- readme.md | 48 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/readme.md b/readme.md index d666a286d..4d0cecad8 100644 --- a/readme.md +++ b/readme.md @@ -77,7 +77,7 @@ To use in your code, simply import.... Then use either "high level" API calls or build your own forms. SG.MsgBox('This is my first message box') -![simple msgbox](https://user-images.githubusercontent.com/13696193/42597824-1749b160-8528-11e8-9114-374bf9731b30.jpg) +![snap0103](https://user-images.githubusercontent.com/13696193/42844641-a04bb798-89e1-11e8-8a37-50ddd9905772.jpg) Yes, it's just that easy to have a window appear on the screen using Python. With PySimpleGUI, making a custom form appear isn't much more difficult. The goal is to get you running on your GUI within ***minutes***, not hours nor days. @@ -99,17 +99,18 @@ PySimpleGUI can be broken down into 2 types of API's: The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. - SG.MsgBox('Variable number of parameters example', my_variable, second_variable, "etc") + SG.MsgBox('Variable number of parameters example', var1, var2, "etc") Each new item begins on a new line in the Message Box - ![variablearguments](https://user-images.githubusercontent.com/13696193/42598375-022bc51e-852a-11e8-8f77-4d664ae1a560.jpg) + ![snap0104](https://user-images.githubusercontent.com/13696193/42844739-ebea22ac-89e1-11e8-8dd1-e61441325701.jpg) + #### Optional Parameters to a Function Call -This feature of the Python language is utilized ***heavily*** as a method of customizing forms and part of forms. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. +This feature of the Python language is utilized ***heavily*** as a method of customizing forms and form Elements. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. -Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't have to be specified on each and every call. +Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't *have* to be specified on each and every call. def MsgBox(*args, button_color=None, @@ -125,7 +126,10 @@ If the caller wanted to change the button color to be black on yellow, the call SG.MsgBox('This box has a custom button color', button_color=('black', 'yellow')) -![custombuttoncolor](https://user-images.githubusercontent.com/13696193/42599212-84f3fe2e-852c-11e8-8a60-4aad669a1fd6.jpg) + +![snap0105](https://user-images.githubusercontent.com/13696193/42844830-2d7e8b9a-89e2-11e8-8ef4-5af9e36f30f3.jpg) + + --- ### High Level API Calls @@ -534,13 +538,15 @@ Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. def InputText(default_text = '', scale=(None, None), size=(None, None), - auto_size_text=None) + auto_size_text=None, + password_char='') . default_text - Text initially shown in the input box scale - Amount size is scaled by size - (width, height) of element in characters auto_size_text- Bool. True is element should be sized to fit text + password_char - Character that will be used to replace each entered character. Setting to a value indicates this field is a password entry field Shorthand functions that are equivalent to `InputText` are `Input` and `In` @@ -811,9 +817,28 @@ Here are some things to try if you're bored or want to further customize **Random colors** To set a button or text to a random color, use the string `'random'` as the color value. You can also call `PySimpleGUI.GetRandomColor`. -To get a random color pair call `PySimpleGUI.GetRandomColorPair`. This returns a tuple containing a random color and that color's compliment. +To get a random color pair call `PySimpleGUI.GetRandomColorPair`. This returns a tuple containing a random color and +that color's compliment. sprint -Call `PySimpleGUI.sprint` to "print" to a scrolled Text Box. This is simply a function pointing to + +**sprint** +Call `sprint` with as many parameters as you want and it'll print them all out in a `ScrolledTextBox`. This is simply a function pointing to `PySimpleGUI.ScrolledTextBox`. + +**Global Settings** +You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. + + SetOptions(icon=None, + default_button_color=(None,None), + default_element_size=(None,None), + default_margins=(None,None), + default_element_padding=(None,None), + default_auto_size_text=None, + default_font=None, + default_border_width=None, + default_autoclose_time=None) + +These settings apply to all forms following the call to `SetOptions`. + **Task Bar Icon** Call `PySimpleGUI.SetGlobalIcon` to change the icon shown on the Windows Task Bar and on the program's Task Bar in the upper left corner. @@ -821,7 +846,7 @@ Call `PySimpleGUI.SetGlobalIcon` to change the icon shown on the Windows Task Ba **Button Color** To change the button color globally call `PySimpleGUI.SetButtonColor`. Removes need to specify in every form or button call if you have a single button color for all buttons. -## Known Issues + ## Known Issues While not an "issue" this is a *stern warning* **Do not attempt** to call `PySimpleGUI` from multiple threads! It's `tkinter` based and `tkinter` has issues with multiple threads @@ -848,7 +873,7 @@ It's a recipe for success if done right. PySimpleGUI has completed the "Make it While the internals to PySimpleGUI are a tad sketchy, the public interfaces into the SDK are more strictly defined and comply with PEP 8 for the most part. -## Authors +## Authors MikeTheWatchGuy ## License @@ -863,3 +888,4 @@ For non-commercial individual, the GNU Lesser General Public License (LGPL 3) a + From 41a35675017be2e7f6279f9610de4a7a38df1621 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 18 Jul 2018 15:11:22 -0400 Subject: [PATCH 039/209] Changed default border widths, global options, color charts Added ability to get a ton of global options. Also made the defaults look a little more "flat". The super-raised look was dated. Changes made to Progress Meters optional parms. Checking in 3 color naming guides --- Color-Guide.png | Bin 0 -> 97113 bytes Color-names.png | Bin 0 -> 304696 bytes Colours.gif | Bin 0 -> 41396 bytes PySimpleGUI.py | 89 ++++++++++++++++++++++++++---------------------- 4 files changed, 49 insertions(+), 40 deletions(-) create mode 100644 Color-Guide.png create mode 100644 Color-names.png create mode 100644 Colours.gif diff --git a/Color-Guide.png b/Color-Guide.png new file mode 100644 index 0000000000000000000000000000000000000000..bd9edbe4a077c699e81b4f5ae8c9de750e54cbf5 GIT binary patch literal 97113 zcmbTec{r5s|NkwNeV1kI1`*jWYbo0pLW2s~cZOsaS+WyjFH020GAc_UTedKES;mr5 z_N>{%e|8^D6Ca}ojz0c2UJgX6_77|wc(w1_ zI5`+P*w_bn_BdQ6Iv2R6t)Y7R;nez{N6B}LpDj_WN<0lG*GS>ErziE2Vw=BWCtPz8 zF9~DxPH4+x!`vPl9WXJ|VAOxoMny_|3w7?w)qLxRn1**E@@wZv=R`V=OLJg|tE99F zblMNu@93a3}V-%OTn+!eH{Lcjf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W3QkIVegUejAR0bMDGW_@2;MgXSF2N7o|Z27~|ZmEo=TXY9e{Vk1q7Sf&wEI zX7c{$WV20iSihu1Wqpg+gf~K+Z)vZmuh<{!73q>{pu2DH9c_mN2NYm4Y%{X7b}*ku zEoVKvd^moV?uk{1NaRz50BZtdev$v}XzmvHQcu z?-*R2=>S=N64m)g@B9B}Ei-?9ijBXP7m zZbUd6IecxAyXeK6KApN)QOhrJn!S4E(XVR0GYO9yMNpYUTOr^&f1(`t$reEV8)&i? z=G|#4t^e$Y>Xutvrta9LWVRWPxz`x8^tL4lhmSO&U!kxN z2ZU66zrQ>p&)IyuRq>}HUp%Q*$M^zNJ`Lk68WS;R^neZjGo}wbIIU5gpbCC;oq}`m+p&{P{fczikI~Px-U;$@X{UfL5-_-}lXbDBl0pukworEcpM~uY6cj YYy9nh%}iEmu2$fS+1-W-2DWSe4{LzSdjJ3c literal 0 HcmV?d00001 diff --git a/Colours.gif b/Colours.gif new file mode 100644 index 0000000000000000000000000000000000000000..e730fd303a68dcfa5842ec28b8150eb970bfaf59 GIT binary patch literal 41396 zcmdpd1y3bB*X@D92X}XOcNpB=-QC?`aCdh-xVyW%ySwWE0}LGQ^L{_$uCz_F+pfKK z+B7>&Dk&|&&0~B3o(k>>0Fb;x0R9L1|26-!Mf|S=kOBbQ0DwRMAO--K1pvMQQc?h^ zT!7hsW;cLa|Nlk;0|7BHfc|g5+#=v3`@boG@85v$ZyX#a!o+XlrYh1HQpOlfCPhWo zSyujLXQ6`yVe3PQ;FkZW|KpMZxJe1b{Ezj2$d$@HkXoFP1q7?xG8yIZme3QEc$b*sw4DlA&it2|#X6Hc%bF_%$o-#` z|FP!w=jI;t=N=s79()(7FqG2LR#sNlZk*MAGu7YSHH_>v9Go?gl6Hju>{4IuNl55z zx9xWW^yfuC3%8|%et7u)eg+!7 z>@~l|Lwzn+kl?(Ee`lLmHf7D`Tni+9Sis_ z^!Y9Ye76mL_q%-$Onc)lfJX0)s}YH_=cu9Dz(GlPlF&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jkL4Lg~4gOjtT+SF;!P)=2{=u~ha)apO5aJ$HGDzLD;CIYiS3cs`<=4&@MD=+GtVtv>FM4;PUU8_^LT5fUR&5+{)o VE71}!5fd{}6E~3)H6kDY06Rea6Da@y literal 0 HcmV?d00001 diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 6bf261425..99252d115 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -9,7 +9,6 @@ import sys import textwrap - # ----====----====----==== Constants the use CAN safely change ====----====----====----# DEFAULT_WINDOW_ICON = '' DEFAULT_ELEMENT_SIZE = (45,1) # In CHARACTERS @@ -18,7 +17,7 @@ DEFAULT_AUTOSIZE_TEXT = False DEFAULT_FONT = ("Helvetica", 10) -DEFAULT_BORDER_WIDTH = 6 +DEFAULT_BORDER_WIDTH = 4 DEFAULT_AUTOCLOSE_TIME = 3 # time in seconds to show an autoclose form MAX_SCROLLED_TEXT_BOX_HEIGHT = 50 #################### COLOR STUFF #################### @@ -42,8 +41,8 @@ # DEFAULT_PROGRESS_BAR_COLOR = (BLUES[1], BLUES[1]) # a nice green progress bar # DEFAULT_PROGRESS_BAR_COLOR = (BLUES[0], BLUES[0]) # a nice green progress bar # DEFAULT_PROGRESS_BAR_COLOR = (PURPLES[1],PURPLES[0]) # a nice purple progress bar -DEFAULT_PROGRESS_BAR_SIZE = (30,25) # Size of Progress Bar (characters for length, pixels for width) -DEFAULT_PROGRESS_BAR_BORDER_WIDTH=8 +DEFAULT_PROGRESS_BAR_SIZE = (35,25) # Size of Progress Bar (characters for length, pixels for width) +DEFAULT_PROGRESS_BAR_BORDER_WIDTH=2 DEFAULT_PROGRESS_BAR_RELIEF = tk.SUNKEN DEFAULT_PROGRESS_BAR_STYLE = 'default' DEFAULT_METER_ORIENTATION = 'Horizontal' @@ -495,7 +494,7 @@ def __del__(self): # ProgreessBar # # ---------------------------------------------------------------------- # class ProgressBar(Element): - def __init__(self, max_value, orientation=None, target=(None, None), scale=(None, None), size=(None, None), auto_size_text=None, bar_color=(None, None), style=None, broder_width=None, relief=None): + def __init__(self, max_value, orientation=None, target=(None, None), scale=(None, None), size=(None, None), auto_size_text=None, bar_color=(None, None), style=None, border_width=None, relief=None): self.MaxValue = max_value self.TKProgressBar = None self.Cancelled = False @@ -504,7 +503,7 @@ def __init__(self, max_value, orientation=None, target=(None, None), scale=(None self.BarColor = bar_color self.BarStyle = style if style else DEFAULT_PROGRESS_BAR_STYLE self.Target = target - self.BorderWidth = broder_width if broder_width else DEFAULT_PROGRESS_BAR_BORDER_WIDTH + self.BorderWidth = border_width if border_width else DEFAULT_PROGRESS_BAR_BORDER_WIDTH self.Relief = relief if relief else DEFAULT_PROGRESS_BAR_RELIEF self.BarExpired = False super().__init__(PROGRESS_BAR, scale, size, auto_size_text) @@ -565,12 +564,11 @@ class FlexForm: ''' Display a user defined for and return the filled in data ''' - def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=DEFAULT_AUTOSIZE_TEXT, scale=(None, None), size=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON): + def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=DEFAULT_AUTOSIZE_TEXT, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON): self.AutoSizeText = auto_size_text self.Title = title self.Rows = [] # a list of ELEMENTS for this row self.DefaultElementSize = default_element_size - self.Size = size self.Scale = scale self.Location = location self.ButtonColor = button_color if button_color else DEFAULT_BUTTON_COLOR @@ -1123,7 +1121,6 @@ def ConvertFlexToTK(MyFlexForm): screen_width = master.winfo_screenwidth() # get window info to move to middle of screen screen_height = master.winfo_screenheight() if MyFlexForm.Location != (None, None): - loc = MyFlexForm.Location x,y = MyFlexForm.Location else: master.update_idletasks() # don't forget @@ -1236,7 +1233,7 @@ def _GetNumLinesNeeded(text, max_line_width): # Exits via an OK button2 press # # Returns nothing # # ===================================================# -def MsgBox(*args, button_color=None, button_type=MSG_BOX_OK, auto_close=False, auto_close_duration=None, icon=DEFAULT_WINDOW_ICON, line_width=MESSAGE_BOX_LINE_WIDTH, font=None): +def MsgBox(*args, button_color=None, button_type=MSG_BOX_OK, auto_close=False, auto_close_duration=None, icon=DEFAULT_WINDOW_ICON, line_width=None, font=None): ''' Show message box. Displays one line per user supplied argument. Takes any Type of variable to display. :param args: @@ -1253,6 +1250,10 @@ def MsgBox(*args, button_color=None, button_type=MSG_BOX_OK, auto_close=False, a args_to_print = [''] else: args_to_print = args + if line_width != None: + local_line_width = line_width + else: + local_line_width = MESSAGE_BOX_LINE_WIDTH with FlexForm(args_to_print[0], auto_size_text=True, button_color=button_color, auto_close=auto_close, auto_close_duration=auto_close_duration, icon=icon, font=font) as form: max_line_total, total_lines = 0,0 for message in args_to_print: @@ -1262,10 +1263,10 @@ def MsgBox(*args, button_color=None, button_type=MSG_BOX_OK, auto_close=False, a if message.count('\n'): message_wrapped = message else: - message_wrapped = textwrap.fill(message, line_width) + message_wrapped = textwrap.fill(message, local_line_width) message_wrapped_lines = message_wrapped.count('\n')+1 longest_line_len = max([len(l) for l in message.split('\n')]) - width_used = min(longest_line_len, line_width) + width_used = min(longest_line_len, local_line_width) max_line_total = max(max_line_total, width_used) # height = _GetNumLinesNeeded(message, width_used) height = message_wrapped_lines @@ -1412,13 +1413,13 @@ def ConvertArgsToSingleString(*args): # ============================== ProgressMeter =====# # ===================================================# -def ProgressMeter(title, max_value, *args, Orientation=None, bar_color=DEFAULT_PROGRESS_BAR_COLOR, button_color=None, size=DEFAULT_PROGRESS_BAR_SIZE, scale=(None, None), border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): +def ProgressMeter(title, max_value, *args, orientation=None, bar_color=DEFAULT_PROGRESS_BAR_COLOR, button_color=None, size=DEFAULT_PROGRESS_BAR_SIZE, scale=(None, None), border_width=None): ''' Create and show a form on tbe caller's behalf. :param title: :param max_value: :param args: ANY number of arguments the caller wants to display - :param Orientation: + :param orientation: :param bar_color: :param size: :param scale: @@ -1426,13 +1427,14 @@ def ProgressMeter(title, max_value, *args, Orientation=None, bar_color=DEFAULT_P :param StyleOffset: :return: ProgressBar object that is in the form ''' - orientation = DEFAULT_METER_ORIENTATION if Orientation is None else Orientation - target = (0,0) if orientation[0].lower() == 'h' else (0,1) - bar2 = ProgressBar(max_value, orientation=orientation, size=size, bar_color=bar_color, scale=scale, target=target, broder_width=border_width) + local_orientation = DEFAULT_METER_ORIENTATION if orientation is None else orientation + local_border_width = DEFAULT_PROGRESS_BAR_BORDER_WIDTH if border_width is None else border_width + target = (0,0) if local_orientation[0].lower() == 'h' else (0,1) + bar2 = ProgressBar(max_value, orientation=local_orientation, size=size, bar_color=bar_color, scale=scale, target=target, border_width=local_border_width) form = FlexForm(title, auto_size_text=True) # Form using a horizontal bar - if orientation[0].lower() == 'h': + if local_orientation[0].lower() == 'h': single_line_message, width, height = ConvertArgsToSingleString(*args) bar2.TextToDisplay = single_line_message bar2.MaxValue = max_value @@ -1445,7 +1447,7 @@ def ProgressMeter(title, max_value, *args, Orientation=None, bar_color=DEFAULT_P bar2.TextToDisplay = single_line_message bar2.MaxValue = max_value bar2.CurrentValue = 0 - form.AddRow(bar2, Text(single_line_message, size=(width + 20, height + 3), auto_size_text=True)) + form.AddRow(bar2, Text(single_line_message, size=(width +20, height + 3), auto_size_text=True)) form.AddRow((Cancel(button_color=button_color))) form.NonBlocking = True @@ -1526,7 +1528,7 @@ def ComputeProgressStats(self): # ============================== EasyProgressMeter =====# -def EasyProgressMeter(title, current_value, max_value, *args, orientation=None, bar_color=DEFAULT_PROGRESS_BAR_COLOR, button_color=None, size=DEFAULT_PROGRESS_BAR_SIZE, scale=(None, None), border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): +def EasyProgressMeter(title, current_value, max_value, *args, orientation=None, bar_color=DEFAULT_PROGRESS_BAR_COLOR, button_color=None, size=DEFAULT_PROGRESS_BAR_SIZE, scale=(None, None), border_width=None): ''' A ONE-LINE progress meter. Add to your code where ever you need a meter. No need for a second function call before your loop. You've got enough code to write! @@ -1542,6 +1544,7 @@ def EasyProgressMeter(title, current_value, max_value, *args, orientation=None, :param StyleOffset: :return: False if should stop the meter ''' + local_border_width = DEFAULT_PROGRESS_BAR_BORDER_WIDTH if not border_width else border_width # STATIC VARIABLE! # This is a very clever form of static variable using a function attribute # If the variable doesn't yet exist, then it will create it and initialize with the 3rd parameter @@ -1554,7 +1557,7 @@ def EasyProgressMeter(title, current_value, max_value, *args, orientation=None, EasyProgressMeter.EasyProgressMeterData = EasyProgressMeterDataClass(title, 1, int(max_value), datetime.datetime.utcnow(), []) EasyProgressMeter.EasyProgressMeterData.ComputeProgressStats() message = "\n".join([line for line in EasyProgressMeter.EasyProgressMeterData.StatMessages]) - EasyProgressMeter.EasyProgressMeterData.MeterID = ProgressMeter(title, int(max_value), message, *args, Orientation=orientation, bar_color=bar_color, size=size, scale=scale, button_color=button_color, border_width=border_width) + EasyProgressMeter.EasyProgressMeterData.MeterID = ProgressMeter(title, int(max_value), message, *args, orientation=orientation, bar_color=bar_color, size=size, scale=scale, button_color=button_color, border_width=local_border_width) EasyProgressMeter.EasyProgressMeterData.ParentForm = EasyProgressMeter.EasyProgressMeterData.MeterID.ParentForm return True # if exactly the same values as before, then ignore. @@ -1728,8 +1731,9 @@ def SetGlobalIcon(icon): # ============================== SetOptions =========# # Sets the icon to be used by default # # ===================================================# -def SetOptions(icon=None, default_button_color=(None,None), default_element_size=(None,None), default_margins=(None,None), default_element_padding=(None,None), - default_auto_size_text=None, default_font=None, default_border_width=None, default_autoclose_time=None): +def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), margins=(None,None), element_padding=(None,None), + auto_size_text=None, font=None, border_width=None, autoclose_time=None, message_box_line_width=None, + progress_meter_border_depth=None): global DEFAULT_ELEMENT_SIZE global DEFAULT_MARGINS # Margins for each LEFT/RIGHT margin is first term global DEFAULT_ELEMENT_PADDING # Padding between elements (row, col) in pixels @@ -1738,7 +1742,8 @@ def SetOptions(icon=None, default_button_color=(None,None), default_element_size global DEFAULT_BORDER_WIDTH global DEFAULT_AUTOCLOSE_TIME global DEFAULT_BUTTON_COLOR - + global MESSAGE_BOX_LINE_WIDTH + global DEFAULT_PROGRESS_BAR_BORDER_WIDTH global _my_windows if icon: @@ -1749,31 +1754,35 @@ def SetOptions(icon=None, default_button_color=(None,None), default_element_size raise FileNotFoundError _my_windows.user_defined_icon = icon - if default_button_color != (None,None): - DEFAULT_BUTTON_COLOR = (default_button_color[0], default_button_color[1]) + if button_color != (None,None): + DEFAULT_BUTTON_COLOR = (button_color[0], button_color[1]) - if default_element_size != (None,None): - DEFAULT_ELEMENT_SIZE = default_element_size + if element_size != (None,None): + DEFAULT_ELEMENT_SIZE = element_size - if default_margins != (None,None): - DEFAULT_MARGINS = default_margins + if margins != (None,None): + DEFAULT_MARGINS = margins - if default_element_padding != (None,None): - DEFAULT_ELEMENT_PADDING = default_element_padding + if element_padding != (None,None): + DEFAULT_ELEMENT_PADDING = element_padding - if default_auto_size_text: - DEFAULT_AUTOSIZE_TEXT = default_auto_size_text + if auto_size_text: + DEFAULT_AUTOSIZE_TEXT = auto_size_text - if default_font !=None: - DEFAULT_FONT = default_font + if font !=None: + DEFAULT_FONT = font - if default_border_width != None: - DEFAULT_BORDER_WIDTH = default_border_width + if border_width != None: + DEFAULT_BORDER_WIDTH = border_width - if default_autoclose_time != None: - DEFAULT_AUTOCLOSE_TIME = default_autoclose_time + if autoclose_time != None: + DEFAULT_AUTOCLOSE_TIME = autoclose_time + if message_box_line_width != None: + MESSAGE_BOX_LINE_WIDTH = message_box_line_width + if progress_meter_border_depth != None: + DEFAULT_PROGRESS_BAR_BORDER_WIDTH = progress_meter_border_depth return True From b48d9c9755641045860adcefd5f0eceee1503a1c Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 18 Jul 2018 15:13:11 -0400 Subject: [PATCH 040/209] More readme changes --- readme.md | 87 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 29 deletions(-) diff --git a/readme.md b/readme.md index 4d0cecad8..218343e0d 100644 --- a/readme.md +++ b/readme.md @@ -387,7 +387,6 @@ This is the definition of the FlexForm object: default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=DEFAULT_AUTOSIZE_TEXT, scale=(None, None), - size=(None, None), location=(None, None), button_color=None,Font=None, progress_bar_color=(None,None), @@ -397,6 +396,20 @@ This is the definition of the FlexForm object: auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON): +Parameter Descriptions. You will find these same parameters specified for each `Element` and some of them in `Row` specifications. The `Element` specified value will take precedence over the `Row` and `Form` values. + + default_element_size - Size of elements in form in characters (width, height) + auto_size_text - Bool. True is elements should size themselves according to contents + scale - Set size of element to be a multiple of the Element size + location - Location to place window in pixels + button_color - Default color for buttons (foreground, background). Can be text or hex + progress_bar_color - Foreground and background colors for progress bars + is_tabbed_form - Bool. If True then form is a tabbed form + border_depth - Amount of 'bezel' to put on input boxes, buttons, etc. + auto_close - Bool. If True form will autoclose + auto_close_duration - Duration in seconds before form closes + icon - .ICO file that will appear on the Task Bar and end of Title Bar + #### Sizes Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. @@ -790,7 +803,7 @@ Here's a complete solution for a chat-window using an Async form with an Output break -#### Tabbed Forms +## Tabbed Forms Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format results = ShowTabbedForm('Title for the form', @@ -799,12 +812,48 @@ Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format Each of the tabs of the form is in fact a form. The same steps are taken to create the form as before. A `FlexForm` is created, then rows are filled with Elements, and finally the form is shown. When calling `ShowTabbedForm`, each form is passed in as a tuple. The tuple has the format: `(the form, the rows, a label shown on the tab)` +## Global Settings +**Global Settings** +You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. + + SetOptions(icon=None, + button_color=(None,None), + element_size=(None,None), + margins=(None,None), + element_padding=(None,None), + auto_size_text=None, + font=None, border_width=None, + autoclose_time=None, + message_box_line_width=None, + progress_meter_border_depth=None): + +Explanation of parameters + + icon - filename of icon used for taskbar and title bar + button_color - button color (foreground, background) + element_size - element size (width, height) in characters + margins - tkinter margins around outsize + element_padding - tkinter padding around each element + auto_size_text - autosize the elements to fit their text + font - font used for elements + border_width - amount of bezel or border around sunken or raised elements + autoclose_time - time in seconds for autoclose boxes + message_box_line_width - number of characers in a line of text in message boxes + progress_meter_border_depth - amount of border around raised or lowered progress meters + + +These settings apply to all forms `SetOptions`. The Row options and Element options will take precedence over these settings. Settings can be thought of as levels of settings with the Form-level being the highest and the Element-level the lowest. Thus the levels are: + + - Form level + - Row level + - Element level + +Each lower level overrides the settings of the higher level + ## Asynchronous (Non-Blocking) Forms While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. -## - ## Sample Applications Use the example programs as a starting basis for your GUI. Copy, paste, modify and run! The demo files are: `Demo DisplayHash1and256.py` - Demonstrates using High Level API calls to get a filename @@ -824,31 +873,11 @@ sprint **sprint** Call `sprint` with as many parameters as you want and it'll print them all out in a `ScrolledTextBox`. This is simply a function pointing to `PySimpleGUI.ScrolledTextBox`. -**Global Settings** -You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. - - SetOptions(icon=None, - default_button_color=(None,None), - default_element_size=(None,None), - default_margins=(None,None), - default_element_padding=(None,None), - default_auto_size_text=None, - default_font=None, - default_border_width=None, - default_autoclose_time=None) - -These settings apply to all forms following the call to `SetOptions`. - - -**Task Bar Icon** -Call `PySimpleGUI.SetGlobalIcon` to change the icon shown on the Windows Task Bar and on the program's Task Bar in the upper left corner. - -**Button Color** -To change the button color globally call `PySimpleGUI.SetButtonColor`. Removes need to specify in every form or button call if you have a single button color for all buttons. +--- +## Known Issues +While not an "issue" this is a ***stern warning*** - ## Known Issues -While not an "issue" this is a *stern warning* -**Do not attempt** to call `PySimpleGUI` from multiple threads! It's `tkinter` based and `tkinter` has issues with multiple threads +## **Do not attempt** to call `PySimpleGUI` from multiple threads! It's `tkinter` based and `tkinter` has issues with multiple threads **Progress Meters** - the visual graphic portion of the meter may be off. May return to the native tkinter progress meter solution in the future. Right now a "custom" progress meter is used. On the bright side, the statistics shown are extremely accurate and can tell you something about the performance of your code. @@ -873,7 +902,7 @@ It's a recipe for success if done right. PySimpleGUI has completed the "Make it While the internals to PySimpleGUI are a tad sketchy, the public interfaces into the SDK are more strictly defined and comply with PEP 8 for the most part. -## Authors +## Authors MikeTheWatchGuy ## License From fe6d44a4655e79a8f3b037d07d546f796474946e Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 18 Jul 2018 15:26:31 -0400 Subject: [PATCH 041/209] Trying to get auto docs working --- readme.rst | 920 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 920 insertions(+) create mode 100644 readme.rst diff --git a/readme.rst b/readme.rst new file mode 100644 index 000000000..218343e0d --- /dev/null +++ b/readme.rst @@ -0,0 +1,920 @@ + +# PySimpleGUI + +This really is a simple GUI, but also powerfully customizable. + + import PySimpleGUI as SG + + SG.MsgBox('My Message Box', 'This is the shortest GUI program ever!') + +![snap0102](https://user-images.githubusercontent.com/13696193/42781058-1d28d9fa-8913-11e8-847e-5c2afc16ca4c.jpg) + +I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? + +There are a number of 'easy to use' Python GUIs, but they're quite limiting. PySimpleGUI tried to take the best of packages like `EasyGUI`(no longer maintained) and `WxSimpleGUI` (a great package, but was too limited for my application). `PySimpleGUI` provides similar single-call-message-box solutions as you'll see. + +GUI Packages with more functionality, like QT and WxPython, require configuring and can take a ***week*** to get *reasonably familiar* with the interfaces. + +With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. + +The `PySimpleGUI` solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? + +You can add a GUI to your command line with a single line of code. With 3 or 4 lines of code you can add a fully customized GUI. And for you Machine Learning folks out there, a **single line** progress meter call that you can drop into any loop to get a graphic like this one: + + +![progress meter 2](https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg) + + + + + Features of PySimpleGUI include: + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Checkboxes + Radio Buttons + Icons + Multi-line Text Input + Scroll-able Output + Progress Bar + Async/Non-Blocking Windows + Tabbed forms + Persistent Windows + Redirect Python Output/Errors to scrolling Window + 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + + +An example of many widgets used on a single form. A little further down you'll find the FIFTEEN lines of code required to create this complex form. + +![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) + + ----- +## Getting Started with PySimpleGUI + +### Installing + + pip install PySimpleGUI + or +Simply download the file - PySimpleGUI.py and import it into your code + + +### Prerequisites + +Python 3 +tkinter + +Should run on all Python platforms that have tkinter running on them. Has been thoroughly tested on Windows. While not tested elsewhere, should work on Linux, Mac, Pi, etc. + +### Using + +To use in your code, simply import.... + `import PySimpleGUI as SG` + +Then use either "high level" API calls or build your own forms. + + SG.MsgBox('This is my first message box') +![snap0103](https://user-images.githubusercontent.com/13696193/42844641-a04bb798-89e1-11e8-8a37-50ddd9905772.jpg) + +Yes, it's just that easy to have a window appear on the screen using Python. With PySimpleGUI, making a custom form appear isn't much more difficult. The goal is to get you running on your GUI within ***minutes***, not hours nor days. + +--- +## APIs + +PySimpleGUI can be broken down into 2 types of API's: + * High Level single call functions + * Custom form functions + + +### Python Language Features + + There are a couple of Python language features that PySimpleGUI utilizes heavily that should be understood first... + * Variable number of arguments to a function call + * Optional parameters to a function call + +#### Variable Number of Arguments + + The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. + + SG.MsgBox('Variable number of parameters example', var1, var2, "etc") + +Each new item begins on a new line in the Message Box + + ![snap0104](https://user-images.githubusercontent.com/13696193/42844739-ebea22ac-89e1-11e8-8dd1-e61441325701.jpg) + + +#### Optional Parameters to a Function Call + +This feature of the Python language is utilized ***heavily*** as a method of customizing forms and form Elements. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. + +Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't *have* to be specified on each and every call. + + def MsgBox(*args, + button_color=None, + button_type=MSG_BOX_OK, + auto_close=False, + auto_close_duration=None, + icon=DEFAULT_WINDOW_ICON, + line_width=MESSAGE_BOX_LINE_WIDTH, + font=None): + +If the caller wanted to change the button color to be black on yellow, the call would look something like this: + + SG.MsgBox('This box has a custom button color', + button_color=('black', 'yellow')) + + +![snap0105](https://user-images.githubusercontent.com/13696193/42844830-2d7e8b9a-89e2-11e8-8ef4-5af9e36f30f3.jpg) + + +--- + +### High Level API Calls + +The classic "input a value, print result" example. +Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. +This code prompts user to input a line of text and then displays that text in a messages box: + + import PySimpleGUI_local as SG + + rc = SG.GetTextBox('Title', 'Please input something') + SG.MsgBox('Results', 'The value returned from GetTextBox', rc) + +![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) + +![MsgBox](https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg) + +#### Message Boxes +In addition to MsgBox, you'll find a several API calls that are shortcuts to common messages boxes. You can achieve similar results by calling MsgBox with the correct parameters. + +The differences tend to be the number and types of buttons. Here are the calls and the windows that are created. + + import PySimpleGUI as SG + + `SG.MsgBoxOK('This is an OK MsgBox')` + + ![msgboxok](https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg) + + SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') + +![msgboxokcancel](https://user-images.githubusercontent.com/13696193/42599858-8e8eff22-852e-11e8-8d5c-3fe99237eb7f.jpg) + + SG.MsgBoxCancel('This is a Cancel MsgBox') +![msgboxcancel](https://user-images.githubusercontent.com/13696193/42599857-8e53dc4e-852e-11e8-8e83-6a8cccf8e706.jpg) + + SG.MsgBoxYesNo('This is a Yes No MsgBox') +![msgboxyesno](https://user-images.githubusercontent.com/13696193/42599856-8e304540-852e-11e8-975d-fb2b62e94300.jpg) + + SG.MsgBoxError('This is an error MsgBox') +![msgbox error](https://user-images.githubusercontent.com/13696193/42599853-8df8e078-852e-11e8-90dc-7815d69bff7e.jpg) + + SG.MsgBoxAutoClose('This is an autoclose MsgBox') + +![msgbox autoclose](https://user-images.githubusercontent.com/13696193/42599855-8e147572-852e-11e8-8c23-7ec771909062.jpg) + + SG.ScrolledTextBox(my_text, height=10) + +![scrolledtextbox](https://user-images.githubusercontent.com/13696193/42600800-a44f4562-8531-11e8-8c21-51dd70316879.jpg) + +Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. Your code could contain a line like: + + sprint(f'My variables values include x={x}', f'y={y}') + +This becomes a debug print of sorts that will route to a scrolled window. + +#### High Level User Input + +There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. If you need only 1 value, then perhaps one of these high level functions will work. + - GetTextBox + - GetFileBox + - GetFolderBox + + `submit_clicked, value = SG.GetTextBox('Title', 'Please enter anything')` + +![gettextbox](https://user-images.githubusercontent.com/13696193/42600399-1ef66a5e-8530-11e8-9bc4-78ea839213cd.jpg) + + submit_clicked, value = SG.GetFileBox('Title', 'Choose a file') + +![getfilebox](https://user-images.githubusercontent.com/13696193/42600398-1ed8a122-8530-11e8-9f74-88b101efcea4.jpg) + + submit_clicked, value = SG.GetPathBox('Title', 'Choose a folder') + +![getfolderbox](https://user-images.githubusercontent.com/13696193/42600397-1ea7cef8-8530-11e8-8d43-e1000c0933cd.jpg) + +#### Progress Meter! +We all have loops in our code. 'Isn't it joyful waiting, watching a counter scrolling past in a text window? How about one line of code to get a progress meter, that contains statistics about your code? +![progress meter 3](https://user-images.githubusercontent.com/13696193/42696332-dca3ca6e-8685-11e8-846b-6bee8362ee5f.jpg) + + EasyProgressMeter(title, + current_value, + max_value, + *args, + orientation=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): + +Here's the one-line Progress Meter in action! + + for i in range(1,10000): + SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') + +That line of code resulted in this window popping up and updating. + +![progress meter 5](https://user-images.githubusercontent.com/13696193/42696912-a5c958b8-8687-11e8-9a7d-a390a465407a.jpg) + +A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. +With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. + + if not SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message'): + break + +***Be sure and add one to your loop counter*** so that your counter goes from 1 to the max value. If you do not add one, your counter will never hit the max value. Instead it will go from 0 to max-1. + +--- +# Custom Form API Calls + +This is the FUN part of the programming of this GUI. In order to really get the most out of the API, you should be using an IDE that supports auto complete or will show you the definition of the function. This will make customizing go smoother. + +It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. Let's start with a basic Browse for a file and do something with it. +# Copy these design patterns! +## Pattern 1 - With Context Manager + + with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + [SG.InputText(), SG.FileBrowse()], + [SG.Submit(), SG.Cancel()]] + (button, (source_filename, )) = form.LayoutAndShow(form_rows) + +## Pattern 2 - No Context Manager + + form = SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + [SG.InputText(), SG.FileBrowse()], + [SG.Submit(), SG.Cancel()]] + (button, (source_filename,)) = form.LayoutAndShow(form_rows) + + +These 2 design patters both produce this custom form: + +![sha hash](https://user-images.githubusercontent.com/13696193/42603149-a56acf3a-853a-11e8-91de-771efd3a65a8.jpg) + +It's important to use the "with" context manager so that resources are freed as quickly as possible, using the currently executing thread. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. + +The second design pattern is not context manager based. There are times when the context manager hides errors. If you are struggling with an unknown error, try modifying the code to run without a context manager. + +You will use these design patterns or code templates for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. This is the most basic / normal of the design patterns. + +### Line by line explanation + +Going through each line of code in the above form will help explain how to use this design patter. Copy, modify and run it! + + with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: +This creates a new form, storing it in the variable `form`. + + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], +The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. + + [SG.InputText(), SG.FileBrowse()], +Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. + + [SG.Submit(), SG.Cancel()]] + +The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its value to the caller. + + (button, (source_filename, )) = form.LayoutAndShow(form_rows) +This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field + +--- +### Design Goals +> Copy, Paste, Run. + +`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the SDK to visually match what's on the screen. + +Forms are represented as Python lists. There are 2 lists in particular. One is a list of rows that form up a GUI screen. The other is a list of Elements (or Widgets) on each row. Each Elements is specified by names such as Text, Button, Checkbox, etc. + +Some elements are shortcuts, meant to make it easy on the programmer who will write less code using them. Rather than writing a `Button`, with `button_name = "Submit"`, etc, the caller can simply writes `Submit`. Some examples include: `Text` has a short-cut function named `T`. `TextInput` has `In`. See each API call for the shortcuts. + + +--- + +## Return values + + Return information from FlexForm, SG's primary form builder interface, is in this format: + + (button, (value1, value2, ...)) + +Each of the Elements that are Input Elements will have a value in the list of return values. You can unpack your GUI directly into the variables you want to use. + + (button, (filename, folder1, folder2, should_overwrite) = form.LayoutAndShow(form_rows) + + +If you have a SINGLE value being returned, it is written this way: + + (button, (value1,)) = form.LayoutAndShow(form_rows) + Another way of parsing the return values is to store the list of values into a variable representing the list of values. + + (button, (value_list)) = form.LayoutAndShow(form_rows) + value1 = value_list[0] + value2 = value_list[1] + ... + +--- +## All Widgets / Elements +This code utilizes as many of the elements in one form as possible. + + with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: + layout = [[Text('Here they all are!', size=(30,1), font=("Helvetica", 25), text_color='red')], + [Text('Here is some text with font sizing', font=("Helvetica", 15))], + [InputText()], + [Checkbox('My first checkbox!'), Checkbox('My second checkbox!', default=True)], + [Radio('My first Radio!', "RADIO1", default=True), Radio('My second checkbox!', "RADIO1")], + [Multiline(DefaultText='This is the DEFAULT text should you decide not to type anything', scale=(2, 10))], + [InputCombo(['choice 1', 'choice 2'], size=(20, 3))], + [Text('_' * 90, size=(60, 1))], + [Text('Choose Source and Destination Folders', size=(35,1))], + [Text('Source Folder', size=(15, 1), auto_size_text=False), InputText('Source'), FolderBrowse()], + [Text('Destination Folder', size=(15, 1), auto_size_text=False), InputText('Dest'), FolderBrowse()], + [SimpleButton('Your Button with any text you want')], + [SimpleButton('Big Text', size=(12,1), font=("Helvetica", 20))], + [Submit(), Cancel()]] + + (button, (values)) = form.LayoutAndShow(layout) + + MsgBox('Results', 'You clicked {}'.format(button),'The values returned from form', values , font = ("Helvetica", 15)) + +This is a somewhat complex form with quite a bit of custom sizing to make things line up well. This is code you only have to write once. When looking at the code, remember that what you're seeing is a list of lists. Each row contains a list of Graphical Elements that are used to create the form. + +![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) + +Clicking the Submit button caused the form call to return. The call to MsgBox resulted in this dialog box. +![results](https://user-images.githubusercontent.com/13696193/42604952-502f64e6-8543-11e8-8045-bc10d38c5fd4.jpg) + + + (button, (values)) = form.LayoutAndShow(layout) +**`Note, button value can be None`**. The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. + +You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. + +--- +# Building Custom Forms +You will find it much easier to write code using PySimpleGUI if you use an IDE such as PyCharm. The features that show you documentation about the API call you are making will help you determine which settings you want to change, if any. In PyCharm, two commands are particularly helpful. + + Control-Q (when cursor is on function name) brings up a box with the function definition + Control-P (when cursor inside function call "()") shows a list of parameters and their default values + +## Synchronous Forms +The most common use of PySimpleGUI is to display and collect information from the user. The most straightforward way to do this is using a "blocking" GUI call. Execution is "blocked" while waiting for the user to close the GUI form/dialog box. +You've already seen a number of examples above that use blocking forms. Anytime you see a context manager used (see the `with` statement) it's most likely a blocking form. You can examine the show calls to be sure. If the form is a non-blocking form, it must indicate that in the call to `form.show`. + +NON-BLOCKING form call: + + form.Show(non_blocking=True) + +### Beginning a Form +The first step is to create the form object using the desired form customization. + + with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: + +This is the definition of the FlexForm object: + + def FlexForm(title, + default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), + auto_size_text=DEFAULT_AUTOSIZE_TEXT, + scale=(None, None), + location=(None, None), + button_color=None,Font=None, + progress_bar_color=(None,None), + is_tabbed_form=False, + border_depth=None, + auto_close=False, + auto_close_duration=DEFAULT_AUTOCLOSE_TIME, + icon=DEFAULT_WINDOW_ICON): + +Parameter Descriptions. You will find these same parameters specified for each `Element` and some of them in `Row` specifications. The `Element` specified value will take precedence over the `Row` and `Form` values. + + default_element_size - Size of elements in form in characters (width, height) + auto_size_text - Bool. True is elements should size themselves according to contents + scale - Set size of element to be a multiple of the Element size + location - Location to place window in pixels + button_color - Default color for buttons (foreground, background). Can be text or hex + progress_bar_color - Foreground and background colors for progress bars + is_tabbed_form - Bool. If True then form is a tabbed form + border_depth - Amount of 'bezel' to put on input boxes, buttons, etc. + auto_close - Bool. If True form will autoclose + auto_close_duration - Duration in seconds before form closes + icon - .ICO file that will appear on the Task Bar and end of Title Bar + + +#### Sizes +Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. + +The default Element size for PySimpleGUI is `(45,1)`. + +Sizes can be set at the element level, or in this case, the size variables apply to all elements in the form. Setting `size=(20,1)` in the form creation call will set all elements in the form to that size. + +In addition to `size` there is a `scale` option. `scale` will take the Element's size and scale it up or down depending on the scale value. `scale=(1,1)` doesn't change the Element's size. `scale=(2,1)` will set the Element's size to be twice as wide as the size setting. + + +#### FlexForm - form-level variables overview +A summary of the variables that can be changed when a FlexForm is created + + default_element_size - set default size for all elements in the form + auto_size_text- true/false autosizing turned on / off + scale - set scale value for all elements + button_color- default button color (foreground, background) + font - font name and size for all text items + progress_bar_color - progress bar colors + is_tabbed_form - true/false indicates form is a tabbed or normal form + border_depth - style setting for buttons, input fields + auto_close - true/false indicates if form will automatically close + auto_close_duration - how long in seconds before closing form + icon - filename for icon that's displayed on the window on taskbar + + +## Elements +"Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. + + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Checkboxes + Radio Buttons + Multi-line Text Input + Scroll-able Output + Progress Bar + Async/Non-Blocking Windows + Tabbed forms + Persistent Windows + Redirect Python Output/Errors to scrolling Window + "Higher level" APIs (e.g. MessageBox, YesNobox, ...) + + +### Output Elements +Building a form is simply making lists of Elements. Each list is a row in the overall GUI dialog box. The definition looks something like this: + + layout = [ [row 1 element, row 1 element], + [row 2 element, row 2 element, row 2 element] ] +The code is a crude representation of the GUI, laid out in text. +#### Text Element + + layout = [[SG.Text('This is what a Text Element looks like')]] + + + ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) + + +The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. + + Text(Text, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None, + text_color=None) + +Some commonly used elements have 'shorthand' versions of the functions to make the code more compact. The functions `T` and `Txt` are the same as calling `Text`. + +**Fonts** in PySimpleGUI are always in this format: + + (font_name, point_size) + +The default font setting is + + ("Helvetica", 10) + +**Color** in PySimpleGUI are always in this format: + + (foreground, background) + +The values foreground and background can be the color names or the hex value formatted as a string: + + "#RRGGBB" + +**auto_size_text** +A `True` value for `auto_size_text`, when placed on any Element, indicates that the width of the Element should be shrunk do the width of the text. This is particularly useful with `Buttons` as fixed-width buttons are somewhat crude looking. The default value is `False`. You will often see this setting on FlexForm definitions. + +**Shorthand functions** +The shorthand functions for `Text` are `Txt` and `T` + + +#### Multiline Text Element + + layout = [[SG.Multiline('This is what a Multi-line Text Element looks like', size=(45,5))]] +![multiline text](https://user-images.githubusercontent.com/13696193/42670464-0824c754-8629-11e8-9741-6ed08f924618.jpg) +This Element doubles as both an input and output Element. The `DefaultText` optional parameter is used to indicate what to output to the window. + + Multiline(default_text='', + enter_submits = False, + scale=(None, None), + size=(None, None), + auto_size_text=None) +. + + default_text - Text to display in the text box + enter_submits - Bool. If True, pressing Enter key submits form + scale - Element's scale + size - Element's size + auto_size_text - Bool. Change width to match size of text + +#### Output Element +Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. More on this later. + + form.AddRow(gg.Output(size=(100,20))) + +![output element](https://user-images.githubusercontent.com/13696193/42704820-5446959c-869f-11e8-849e-047ea280387a.jpg) + + Output(scale=(None, None), + size=(None, None)) +. + + scale - How much to scale size of element + size - Size of element (width, height) in characters + +### Input Elements + These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. + +#### Text Input Element + + layout = [[SG.InputText('Default text')]] +![inputtext](https://user-images.githubusercontent.com/13696193/42693515-610a716c-867d-11e8-9a00-7e7fcf771230.jpg) + + def InputText(default_text = '', + scale=(None, None), + size=(None, None), + auto_size_text=None, + password_char='') +. + + default_text - Text initially shown in the input box + scale - Amount size is scaled by + size - (width, height) of element in characters + auto_size_text- Bool. True is element should be sized to fit text + password_char - Character that will be used to replace each entered character. Setting to a value indicates this field is a password entry field + +Shorthand functions that are equivalent to `InputText` are `Input` and `In` + + +#### Combo Element +Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. + + layout = [[SG.InputCombo(['choice 1', 'choice 2'])]] + +![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) + + InputCombo(values, + scale=(None, None), + size=(None, None), + auto_size_text=None) +. + + values - Choices to be displayed. List of strings + scale - Amount to scale size by + size - (width, height) of element in characters + auto_size_text - Bool. True if size should fit the text length + +#### Radio Button Element +Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. + + layout = [[SG.Radio('My first Radio!', "RADIO1", default=True), SG.Radio('My second radio!', "RADIO1")]] + +![radio element](https://user-images.githubusercontent.com/13696193/42705705-327b4b6c-86a2-11e8-81a7-740e57646ba8.jpg) + + Radio(text, + group_id, + default=False, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None) + +. + + text - Text to display next to button + group_id - Groups together multiple Radio Buttons. Can be any value + default - Bool. Initial state + scale - Amount to scale size of element + size- (width, height) size of element in characters + auto_size_text - Bool. True if should size width to fit text + font - Font type and size for text display + + +#### Checkbox Element +Checkbox elements are like Radio Button elements. They return a bool indicating whether or not they are checked. + + layout = [[SG.Checkbox('My first Checkbox!', default=True), SG.Checkbox('My second Checkbox!')]] + +![checkbox element](https://user-images.githubusercontent.com/13696193/42717015-655d73d2-86cc-11e8-9c69-3c810f48e578.jpg) + + + Checkbox(text, + default=False, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None): +. + + text - Text to display next to checkbox + default- Bool. Initial state + scale - Amount to scale size of element + size - (width, height) size of element in characters + auto_size_text- Bool. True if should size width to fit text + font- Font type and size for text display + + +#### Spin Element +An up/down spinner control. The valid values are passed in as a list. + + layout = [[SG.Spin([i for i in range(1,11)], initial_value=1), SG.Text('Volume level')]] + +![spin element](https://user-images.githubusercontent.com/13696193/42717231-8ddb51d4-86cd-11e8-827a-75f2237477fa.jpg) + + Spin(values, + intiial_value=None, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None) +. + + values - List of valid values + initial_value - String with initial value + scale - Amount to scale size of element + size - (width, height) size of element in characters + auto_size_text - Bool. True if should size width to fit text + font - Font type and size for text display + +#### Button Element +Buttons are the most important element of all! They cause the majority of the action to happen. After all, it's a button press that will get you out of a form, whether it but Submit or Cancel, one way or another a button is involved in all forms. The only exception is to this is when the user closes the window using the "X" in the upper corner which means no button was involved. + +The Types of buttons include: +* Folder Browse +* File Browse +* Close Form +* Read Form + + + Close Form - Normal buttons like Submit, Cancel, Yes, No, etc, are "Close Form" buttons. They cause the input values to be read and then the form is closed, returning the values to the caller. + +Folder Browse - When clicked a folder browse dialog box is opened. The results of the Folder Browse dialog box are written into one of the input fields of the form. + +File Browse - Same as the Folder Browse except rather than choosing a folder, a single file is chosen. + +Read Form - This is an async form button that will read a snapshot of all of the input fields, but does not close the form after it's clicked. + +While it's possible to build forms using the Button Element directly, you should never need to do that. There are pre-made buttons and shortcuts that will make life much easier. The most basic Button element call to use is `SimpleButton` + + SimpleButton(text, + scale=(None, None), + size=(None, None), + auto_size_text=None, + button_color=None, + font=None) + +Pre-made buttons include: + + OK + Ok + Submit + Cancel + Yes + No + FileBrowse + FolderBrowse +. + layout = [[SG.OK(), SG.Cancel()]] + +![ok cancel](https://user-images.githubusercontent.com/13696193/42717733-1803f584-86d1-11e8-9223-36b782971b9f.jpg) + +The FileBrowse and FolderBrowse buttons both fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. + +The default value for `Target` is `(ThisRow, -1)`. ThisRow is a special value that tells the GUI to use the same row as the button. The Y-value of -1 means the field one value to the left of the button. For a File or Folder Browse button, the field that it fills are generally to the left of the button is most cases. + +Let's examine this form as an example: + +![button target example](https://user-images.githubusercontent.com/13696193/42718075-b4dcb61e-86d3-11e8-904c-d709dd364108.jpg) + +The `InputText` element is located at (1,0)... row 1, column 0. The `Browse` button is located at position (2,0). The Target for the button could be any of these values: + + Target = (1,0) + Target = (-1,0) +The code for the entire form could be: + + layout = [[SG.T('Source Folder')], + [SG.In()], + [SG.FolderBrowse(Target=(-1,0)), SG.OK()]] + +**Custom Buttons** +If you want to define your own button, you will generally do this with the Button Element `SimpleButton`. + +layout = [[SG.SimpleButton('My Button')]] + +![singlebutton](https://user-images.githubusercontent.com/13696193/42718281-9453deca-86d5-11e8-83c7-4b6d33720858.jpg) + +All buttons can have their text changed by changing the `button_text` variable. + +**File Types** +The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is + + FileTypes=(("ALL Files", "*.*"),) + +This code produces a form where the Browse button only shows files of type .TXT + + layout = [[SG.In() ,SG.FileBrowse(file_types=(("Text Files", "*.txt"),))]] + + ***The ENTER key*** + The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. + + +--- +#### ProgressBar +The `ProgressBar` element is used to build custom Progress Bar forms. It is HIGHLY recommended that you use the functions that provide a complete progress meter solution for you. Progress Meters are not easy to work with because the forms have to be non-blocking and they are tricky to debug. + +The **easiest** way to get progress meters into your code is to use the `EasyProgessMeter` API. This consists of a pair of functions, `EasyProgessMeter` and `EasyProgressMeterCancel`. You can easily cancel any progress meter by calling it with the current value = max value. This will mark the meter as expired and close the window. +You've already seen EasyProgressMeter calls presented earlier in this readme. + + SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') + +The return value for `EasyProgressMeter` is: +`True` if meter updated correctly +`False` if user clicked the Cancel button, closed the form, or vale reached the max value. +**Customized Progress Bar** +If you want a bit more customization of your meter, then you can go up 1 level and use the calls to `ProgressMeter` and `ProgressMeterUpdate`. These APIs behave like an object we're all used to. First you create the `ProgressMeter` object, then you call the `Update` method to update it. + +You setup the progress meter by calling + + my_meter = ProgressMeter(title, + max_value, + *args, + d orientantion=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) +Then to update the bar within your loop + + return_code = ProgressMeterUpdate(my_meter, + value, + *args): +Putting it all together you get this design pattern + + my_meter = SG.ProgressMeter('Meter Title', 100000, orentation='Vert') + + for i in range(0, 100000): + SG.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') + + +The final way of using a Progress Meter with PySimpleGUI is to build a custom form with a `ProgressBar` Element in the form. You will need to run your form as a non-blocking form. When you are ready to update your progress bar, you call the `UpdateBar` method for the `ProgressBar` element itself. + + +#### Output +The Output Element is a re-direction of Stdout. Anything "printed" will be displayed in this element. + + Output(scale=(None, None), + size=(None, None)) + +Here's a complete solution for a chat-window using an Async form with an Output Element + + import PySimpleGUI as g + + with g.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + form.AddRow(g.Text('This is where standard out is being routed', size=[40,1])) + form.AddRow(g.Output(size=(80, 20))) + form.AddRow(g.Multiline(size=(70, 5), enter_submits=True), g.ReadFormButton('SEND', button_color=(g.YELLOWS[0], g.BLUES[0])), g.SimpleButton('EXIT', button_color=(g.YELLOWS[0], g.GREENS[0]))) + + # ---===--- Loop taking in user input and printing it --- # + while True: + (button, value) = form.Read() + if button == 'SEND': + print(value) + else: + print('Exiting the form now') + break + + +## Tabbed Forms +Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format + + results = ShowTabbedForm('Title for the form', + (form,layout,'Tab 1 label'), + (form2,layout2, 'Tab 2 label')) + +Each of the tabs of the form is in fact a form. The same steps are taken to create the form as before. A `FlexForm` is created, then rows are filled with Elements, and finally the form is shown. When calling `ShowTabbedForm`, each form is passed in as a tuple. The tuple has the format: `(the form, the rows, a label shown on the tab)` + +## Global Settings +**Global Settings** +You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. + + SetOptions(icon=None, + button_color=(None,None), + element_size=(None,None), + margins=(None,None), + element_padding=(None,None), + auto_size_text=None, + font=None, border_width=None, + autoclose_time=None, + message_box_line_width=None, + progress_meter_border_depth=None): + +Explanation of parameters + + icon - filename of icon used for taskbar and title bar + button_color - button color (foreground, background) + element_size - element size (width, height) in characters + margins - tkinter margins around outsize + element_padding - tkinter padding around each element + auto_size_text - autosize the elements to fit their text + font - font used for elements + border_width - amount of bezel or border around sunken or raised elements + autoclose_time - time in seconds for autoclose boxes + message_box_line_width - number of characers in a line of text in message boxes + progress_meter_border_depth - amount of border around raised or lowered progress meters + + +These settings apply to all forms `SetOptions`. The Row options and Element options will take precedence over these settings. Settings can be thought of as levels of settings with the Form-level being the highest and the Element-level the lowest. Thus the levels are: + + - Form level + - Row level + - Element level + +Each lower level overrides the settings of the higher level + +## Asynchronous (Non-Blocking) Forms +While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. + + +## Sample Applications +Use the example programs as a starting basis for your GUI. Copy, paste, modify and run! The demo files are: +`Demo DisplayHash1and256.py` - Demonstrates using High Level API calls to get a filename +`Demo DupliucateFileFinder.py` - Demonstrates High Level API to get a folder & Easy Progress Meter to show progress of the file scanning +`Demo Recipes.py` - Three sample forms including an asynchronous form +`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. + +## Fun Stuff +Here are some things to try if you're bored or want to further customize + +**Random colors** +To set a button or text to a random color, use the string `'random'` as the color value. You can also call `PySimpleGUI.GetRandomColor`. +To get a random color pair call `PySimpleGUI.GetRandomColorPair`. This returns a tuple containing a random color and +that color's compliment. +sprint + +**sprint** +Call `sprint` with as many parameters as you want and it'll print them all out in a `ScrolledTextBox`. This is simply a function pointing to `PySimpleGUI.ScrolledTextBox`. + +--- +## Known Issues +While not an "issue" this is a ***stern warning*** + +## **Do not attempt** to call `PySimpleGUI` from multiple threads! It's `tkinter` based and `tkinter` has issues with multiple threads + +**Progress Meters** - the visual graphic portion of the meter may be off. May return to the native tkinter progress meter solution in the future. Right now a "custom" progress meter is used. On the bright side, the statistics shown are extremely accurate and can tell you something about the performance of your code. + +## Contributing + +A MikeTheWatchGuy production... entirely responsible for this code.... unless it causes you trouble in which case I'm not at all responsible. + +## Versioning +|Version | Description | +|--|--| +| 1.0.9 | July 10, 2018 - Initial Release | +| 1.0.21 | July 13, 2018 - Readme updates | +| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case + +## Code Condition + + Make it run + Make it right + Make it fast + +It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor for PEP 8 compliance. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. + +While the internals to PySimpleGUI are a tad sketchy, the public interfaces into the SDK are more strictly defined and comply with PEP 8 for the most part. + +## Authors +MikeTheWatchGuy + +## License + +This project is limited to non-commercial applications. If you wish to use it commercially, please contact one of the authors. +For non-commercial individual, the GNU Lesser General Public License (LGPL 3) applies. + +## Acknowledgments + +* Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence + + + + + From 5d1f3ab71b6f22722f1c79d2d5b60e4aa6c60de7 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 18 Jul 2018 15:28:52 -0400 Subject: [PATCH 042/209] Rename readme.rst to README.rst --- readme.rst => README.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename readme.rst => README.rst (100%) diff --git a/readme.rst b/README.rst similarity index 100% rename from readme.rst rename to README.rst From 1e5a86f56dc106bae86eac5cf94e0e93a95c470e Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 18 Jul 2018 15:35:02 -0400 Subject: [PATCH 043/209] Delete README.rst --- README.rst | 920 ----------------------------------------------------- 1 file changed, 920 deletions(-) delete mode 100644 README.rst diff --git a/README.rst b/README.rst deleted file mode 100644 index 218343e0d..000000000 --- a/README.rst +++ /dev/null @@ -1,920 +0,0 @@ - -# PySimpleGUI - -This really is a simple GUI, but also powerfully customizable. - - import PySimpleGUI as SG - - SG.MsgBox('My Message Box', 'This is the shortest GUI program ever!') - -![snap0102](https://user-images.githubusercontent.com/13696193/42781058-1d28d9fa-8913-11e8-847e-5c2afc16ca4c.jpg) - -I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? - -There are a number of 'easy to use' Python GUIs, but they're quite limiting. PySimpleGUI tried to take the best of packages like `EasyGUI`(no longer maintained) and `WxSimpleGUI` (a great package, but was too limited for my application). `PySimpleGUI` provides similar single-call-message-box solutions as you'll see. - -GUI Packages with more functionality, like QT and WxPython, require configuring and can take a ***week*** to get *reasonably familiar* with the interfaces. - -With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. - -The `PySimpleGUI` solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? - -You can add a GUI to your command line with a single line of code. With 3 or 4 lines of code you can add a fully customized GUI. And for you Machine Learning folks out there, a **single line** progress meter call that you can drop into any loop to get a graphic like this one: - - -![progress meter 2](https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg) - - - - - Features of PySimpleGUI include: - Text - Single Line Input - Buttons including these types: - File Browse - Folder Browse - Non-closing return - Close form - Checkboxes - Radio Buttons - Icons - Multi-line Text Input - Scroll-able Output - Progress Bar - Async/Non-Blocking Windows - Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling Window - 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) - - -An example of many widgets used on a single form. A little further down you'll find the FIFTEEN lines of code required to create this complex form. - -![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) - - ----- -## Getting Started with PySimpleGUI - -### Installing - - pip install PySimpleGUI - or -Simply download the file - PySimpleGUI.py and import it into your code - - -### Prerequisites - -Python 3 -tkinter - -Should run on all Python platforms that have tkinter running on them. Has been thoroughly tested on Windows. While not tested elsewhere, should work on Linux, Mac, Pi, etc. - -### Using - -To use in your code, simply import.... - `import PySimpleGUI as SG` - -Then use either "high level" API calls or build your own forms. - - SG.MsgBox('This is my first message box') -![snap0103](https://user-images.githubusercontent.com/13696193/42844641-a04bb798-89e1-11e8-8a37-50ddd9905772.jpg) - -Yes, it's just that easy to have a window appear on the screen using Python. With PySimpleGUI, making a custom form appear isn't much more difficult. The goal is to get you running on your GUI within ***minutes***, not hours nor days. - ---- -## APIs - -PySimpleGUI can be broken down into 2 types of API's: - * High Level single call functions - * Custom form functions - - -### Python Language Features - - There are a couple of Python language features that PySimpleGUI utilizes heavily that should be understood first... - * Variable number of arguments to a function call - * Optional parameters to a function call - -#### Variable Number of Arguments - - The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. - - SG.MsgBox('Variable number of parameters example', var1, var2, "etc") - -Each new item begins on a new line in the Message Box - - ![snap0104](https://user-images.githubusercontent.com/13696193/42844739-ebea22ac-89e1-11e8-8dd1-e61441325701.jpg) - - -#### Optional Parameters to a Function Call - -This feature of the Python language is utilized ***heavily*** as a method of customizing forms and form Elements. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. - -Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't *have* to be specified on each and every call. - - def MsgBox(*args, - button_color=None, - button_type=MSG_BOX_OK, - auto_close=False, - auto_close_duration=None, - icon=DEFAULT_WINDOW_ICON, - line_width=MESSAGE_BOX_LINE_WIDTH, - font=None): - -If the caller wanted to change the button color to be black on yellow, the call would look something like this: - - SG.MsgBox('This box has a custom button color', - button_color=('black', 'yellow')) - - -![snap0105](https://user-images.githubusercontent.com/13696193/42844830-2d7e8b9a-89e2-11e8-8ef4-5af9e36f30f3.jpg) - - ---- - -### High Level API Calls - -The classic "input a value, print result" example. -Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. -This code prompts user to input a line of text and then displays that text in a messages box: - - import PySimpleGUI_local as SG - - rc = SG.GetTextBox('Title', 'Please input something') - SG.MsgBox('Results', 'The value returned from GetTextBox', rc) - -![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) - -![MsgBox](https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg) - -#### Message Boxes -In addition to MsgBox, you'll find a several API calls that are shortcuts to common messages boxes. You can achieve similar results by calling MsgBox with the correct parameters. - -The differences tend to be the number and types of buttons. Here are the calls and the windows that are created. - - import PySimpleGUI as SG - - `SG.MsgBoxOK('This is an OK MsgBox')` - - ![msgboxok](https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg) - - SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') - -![msgboxokcancel](https://user-images.githubusercontent.com/13696193/42599858-8e8eff22-852e-11e8-8d5c-3fe99237eb7f.jpg) - - SG.MsgBoxCancel('This is a Cancel MsgBox') -![msgboxcancel](https://user-images.githubusercontent.com/13696193/42599857-8e53dc4e-852e-11e8-8e83-6a8cccf8e706.jpg) - - SG.MsgBoxYesNo('This is a Yes No MsgBox') -![msgboxyesno](https://user-images.githubusercontent.com/13696193/42599856-8e304540-852e-11e8-975d-fb2b62e94300.jpg) - - SG.MsgBoxError('This is an error MsgBox') -![msgbox error](https://user-images.githubusercontent.com/13696193/42599853-8df8e078-852e-11e8-90dc-7815d69bff7e.jpg) - - SG.MsgBoxAutoClose('This is an autoclose MsgBox') - -![msgbox autoclose](https://user-images.githubusercontent.com/13696193/42599855-8e147572-852e-11e8-8c23-7ec771909062.jpg) - - SG.ScrolledTextBox(my_text, height=10) - -![scrolledtextbox](https://user-images.githubusercontent.com/13696193/42600800-a44f4562-8531-11e8-8c21-51dd70316879.jpg) - -Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. Your code could contain a line like: - - sprint(f'My variables values include x={x}', f'y={y}') - -This becomes a debug print of sorts that will route to a scrolled window. - -#### High Level User Input - -There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. If you need only 1 value, then perhaps one of these high level functions will work. - - GetTextBox - - GetFileBox - - GetFolderBox - - `submit_clicked, value = SG.GetTextBox('Title', 'Please enter anything')` - -![gettextbox](https://user-images.githubusercontent.com/13696193/42600399-1ef66a5e-8530-11e8-9bc4-78ea839213cd.jpg) - - submit_clicked, value = SG.GetFileBox('Title', 'Choose a file') - -![getfilebox](https://user-images.githubusercontent.com/13696193/42600398-1ed8a122-8530-11e8-9f74-88b101efcea4.jpg) - - submit_clicked, value = SG.GetPathBox('Title', 'Choose a folder') - -![getfolderbox](https://user-images.githubusercontent.com/13696193/42600397-1ea7cef8-8530-11e8-8d43-e1000c0933cd.jpg) - -#### Progress Meter! -We all have loops in our code. 'Isn't it joyful waiting, watching a counter scrolling past in a text window? How about one line of code to get a progress meter, that contains statistics about your code? -![progress meter 3](https://user-images.githubusercontent.com/13696193/42696332-dca3ca6e-8685-11e8-846b-6bee8362ee5f.jpg) - - EasyProgressMeter(title, - current_value, - max_value, - *args, - orientation=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, - button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), - border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): - -Here's the one-line Progress Meter in action! - - for i in range(1,10000): - SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') - -That line of code resulted in this window popping up and updating. - -![progress meter 5](https://user-images.githubusercontent.com/13696193/42696912-a5c958b8-8687-11e8-9a7d-a390a465407a.jpg) - -A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. -With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. - - if not SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message'): - break - -***Be sure and add one to your loop counter*** so that your counter goes from 1 to the max value. If you do not add one, your counter will never hit the max value. Instead it will go from 0 to max-1. - ---- -# Custom Form API Calls - -This is the FUN part of the programming of this GUI. In order to really get the most out of the API, you should be using an IDE that supports auto complete or will show you the definition of the function. This will make customizing go smoother. - -It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. Let's start with a basic Browse for a file and do something with it. -# Copy these design patterns! -## Pattern 1 - With Context Manager - - with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], - [SG.InputText(), SG.FileBrowse()], - [SG.Submit(), SG.Cancel()]] - (button, (source_filename, )) = form.LayoutAndShow(form_rows) - -## Pattern 2 - No Context Manager - - form = SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], - [SG.InputText(), SG.FileBrowse()], - [SG.Submit(), SG.Cancel()]] - (button, (source_filename,)) = form.LayoutAndShow(form_rows) - - -These 2 design patters both produce this custom form: - -![sha hash](https://user-images.githubusercontent.com/13696193/42603149-a56acf3a-853a-11e8-91de-771efd3a65a8.jpg) - -It's important to use the "with" context manager so that resources are freed as quickly as possible, using the currently executing thread. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. - -The second design pattern is not context manager based. There are times when the context manager hides errors. If you are struggling with an unknown error, try modifying the code to run without a context manager. - -You will use these design patterns or code templates for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. This is the most basic / normal of the design patterns. - -### Line by line explanation - -Going through each line of code in the above form will help explain how to use this design patter. Copy, modify and run it! - - with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: -This creates a new form, storing it in the variable `form`. - - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], -The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. - - [SG.InputText(), SG.FileBrowse()], -Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. - - [SG.Submit(), SG.Cancel()]] - -The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its value to the caller. - - (button, (source_filename, )) = form.LayoutAndShow(form_rows) -This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field - ---- -### Design Goals -> Copy, Paste, Run. - -`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the SDK to visually match what's on the screen. - -Forms are represented as Python lists. There are 2 lists in particular. One is a list of rows that form up a GUI screen. The other is a list of Elements (or Widgets) on each row. Each Elements is specified by names such as Text, Button, Checkbox, etc. - -Some elements are shortcuts, meant to make it easy on the programmer who will write less code using them. Rather than writing a `Button`, with `button_name = "Submit"`, etc, the caller can simply writes `Submit`. Some examples include: `Text` has a short-cut function named `T`. `TextInput` has `In`. See each API call for the shortcuts. - - ---- - -## Return values - - Return information from FlexForm, SG's primary form builder interface, is in this format: - - (button, (value1, value2, ...)) - -Each of the Elements that are Input Elements will have a value in the list of return values. You can unpack your GUI directly into the variables you want to use. - - (button, (filename, folder1, folder2, should_overwrite) = form.LayoutAndShow(form_rows) - - -If you have a SINGLE value being returned, it is written this way: - - (button, (value1,)) = form.LayoutAndShow(form_rows) - Another way of parsing the return values is to store the list of values into a variable representing the list of values. - - (button, (value_list)) = form.LayoutAndShow(form_rows) - value1 = value_list[0] - value2 = value_list[1] - ... - ---- -## All Widgets / Elements -This code utilizes as many of the elements in one form as possible. - - with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: - layout = [[Text('Here they all are!', size=(30,1), font=("Helvetica", 25), text_color='red')], - [Text('Here is some text with font sizing', font=("Helvetica", 15))], - [InputText()], - [Checkbox('My first checkbox!'), Checkbox('My second checkbox!', default=True)], - [Radio('My first Radio!', "RADIO1", default=True), Radio('My second checkbox!', "RADIO1")], - [Multiline(DefaultText='This is the DEFAULT text should you decide not to type anything', scale=(2, 10))], - [InputCombo(['choice 1', 'choice 2'], size=(20, 3))], - [Text('_' * 90, size=(60, 1))], - [Text('Choose Source and Destination Folders', size=(35,1))], - [Text('Source Folder', size=(15, 1), auto_size_text=False), InputText('Source'), FolderBrowse()], - [Text('Destination Folder', size=(15, 1), auto_size_text=False), InputText('Dest'), FolderBrowse()], - [SimpleButton('Your Button with any text you want')], - [SimpleButton('Big Text', size=(12,1), font=("Helvetica", 20))], - [Submit(), Cancel()]] - - (button, (values)) = form.LayoutAndShow(layout) - - MsgBox('Results', 'You clicked {}'.format(button),'The values returned from form', values , font = ("Helvetica", 15)) - -This is a somewhat complex form with quite a bit of custom sizing to make things line up well. This is code you only have to write once. When looking at the code, remember that what you're seeing is a list of lists. Each row contains a list of Graphical Elements that are used to create the form. - -![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) - -Clicking the Submit button caused the form call to return. The call to MsgBox resulted in this dialog box. -![results](https://user-images.githubusercontent.com/13696193/42604952-502f64e6-8543-11e8-8045-bc10d38c5fd4.jpg) - - - (button, (values)) = form.LayoutAndShow(layout) -**`Note, button value can be None`**. The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. - -You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. - ---- -# Building Custom Forms -You will find it much easier to write code using PySimpleGUI if you use an IDE such as PyCharm. The features that show you documentation about the API call you are making will help you determine which settings you want to change, if any. In PyCharm, two commands are particularly helpful. - - Control-Q (when cursor is on function name) brings up a box with the function definition - Control-P (when cursor inside function call "()") shows a list of parameters and their default values - -## Synchronous Forms -The most common use of PySimpleGUI is to display and collect information from the user. The most straightforward way to do this is using a "blocking" GUI call. Execution is "blocked" while waiting for the user to close the GUI form/dialog box. -You've already seen a number of examples above that use blocking forms. Anytime you see a context manager used (see the `with` statement) it's most likely a blocking form. You can examine the show calls to be sure. If the form is a non-blocking form, it must indicate that in the call to `form.show`. - -NON-BLOCKING form call: - - form.Show(non_blocking=True) - -### Beginning a Form -The first step is to create the form object using the desired form customization. - - with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: - -This is the definition of the FlexForm object: - - def FlexForm(title, - default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), - auto_size_text=DEFAULT_AUTOSIZE_TEXT, - scale=(None, None), - location=(None, None), - button_color=None,Font=None, - progress_bar_color=(None,None), - is_tabbed_form=False, - border_depth=None, - auto_close=False, - auto_close_duration=DEFAULT_AUTOCLOSE_TIME, - icon=DEFAULT_WINDOW_ICON): - -Parameter Descriptions. You will find these same parameters specified for each `Element` and some of them in `Row` specifications. The `Element` specified value will take precedence over the `Row` and `Form` values. - - default_element_size - Size of elements in form in characters (width, height) - auto_size_text - Bool. True is elements should size themselves according to contents - scale - Set size of element to be a multiple of the Element size - location - Location to place window in pixels - button_color - Default color for buttons (foreground, background). Can be text or hex - progress_bar_color - Foreground and background colors for progress bars - is_tabbed_form - Bool. If True then form is a tabbed form - border_depth - Amount of 'bezel' to put on input boxes, buttons, etc. - auto_close - Bool. If True form will autoclose - auto_close_duration - Duration in seconds before form closes - icon - .ICO file that will appear on the Task Bar and end of Title Bar - - -#### Sizes -Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. - -The default Element size for PySimpleGUI is `(45,1)`. - -Sizes can be set at the element level, or in this case, the size variables apply to all elements in the form. Setting `size=(20,1)` in the form creation call will set all elements in the form to that size. - -In addition to `size` there is a `scale` option. `scale` will take the Element's size and scale it up or down depending on the scale value. `scale=(1,1)` doesn't change the Element's size. `scale=(2,1)` will set the Element's size to be twice as wide as the size setting. - - -#### FlexForm - form-level variables overview -A summary of the variables that can be changed when a FlexForm is created - - default_element_size - set default size for all elements in the form - auto_size_text- true/false autosizing turned on / off - scale - set scale value for all elements - button_color- default button color (foreground, background) - font - font name and size for all text items - progress_bar_color - progress bar colors - is_tabbed_form - true/false indicates form is a tabbed or normal form - border_depth - style setting for buttons, input fields - auto_close - true/false indicates if form will automatically close - auto_close_duration - how long in seconds before closing form - icon - filename for icon that's displayed on the window on taskbar - - -## Elements -"Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. - - Text - Single Line Input - Buttons including these types: - File Browse - Folder Browse - Non-closing return - Close form - Checkboxes - Radio Buttons - Multi-line Text Input - Scroll-able Output - Progress Bar - Async/Non-Blocking Windows - Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling Window - "Higher level" APIs (e.g. MessageBox, YesNobox, ...) - - -### Output Elements -Building a form is simply making lists of Elements. Each list is a row in the overall GUI dialog box. The definition looks something like this: - - layout = [ [row 1 element, row 1 element], - [row 2 element, row 2 element, row 2 element] ] -The code is a crude representation of the GUI, laid out in text. -#### Text Element - - layout = [[SG.Text('This is what a Text Element looks like')]] - - - ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) - - -The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. - - Text(Text, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None, - text_color=None) - -Some commonly used elements have 'shorthand' versions of the functions to make the code more compact. The functions `T` and `Txt` are the same as calling `Text`. - -**Fonts** in PySimpleGUI are always in this format: - - (font_name, point_size) - -The default font setting is - - ("Helvetica", 10) - -**Color** in PySimpleGUI are always in this format: - - (foreground, background) - -The values foreground and background can be the color names or the hex value formatted as a string: - - "#RRGGBB" - -**auto_size_text** -A `True` value for `auto_size_text`, when placed on any Element, indicates that the width of the Element should be shrunk do the width of the text. This is particularly useful with `Buttons` as fixed-width buttons are somewhat crude looking. The default value is `False`. You will often see this setting on FlexForm definitions. - -**Shorthand functions** -The shorthand functions for `Text` are `Txt` and `T` - - -#### Multiline Text Element - - layout = [[SG.Multiline('This is what a Multi-line Text Element looks like', size=(45,5))]] -![multiline text](https://user-images.githubusercontent.com/13696193/42670464-0824c754-8629-11e8-9741-6ed08f924618.jpg) -This Element doubles as both an input and output Element. The `DefaultText` optional parameter is used to indicate what to output to the window. - - Multiline(default_text='', - enter_submits = False, - scale=(None, None), - size=(None, None), - auto_size_text=None) -. - - default_text - Text to display in the text box - enter_submits - Bool. If True, pressing Enter key submits form - scale - Element's scale - size - Element's size - auto_size_text - Bool. Change width to match size of text - -#### Output Element -Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. More on this later. - - form.AddRow(gg.Output(size=(100,20))) - -![output element](https://user-images.githubusercontent.com/13696193/42704820-5446959c-869f-11e8-849e-047ea280387a.jpg) - - Output(scale=(None, None), - size=(None, None)) -. - - scale - How much to scale size of element - size - Size of element (width, height) in characters - -### Input Elements - These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. - -#### Text Input Element - - layout = [[SG.InputText('Default text')]] -![inputtext](https://user-images.githubusercontent.com/13696193/42693515-610a716c-867d-11e8-9a00-7e7fcf771230.jpg) - - def InputText(default_text = '', - scale=(None, None), - size=(None, None), - auto_size_text=None, - password_char='') -. - - default_text - Text initially shown in the input box - scale - Amount size is scaled by - size - (width, height) of element in characters - auto_size_text- Bool. True is element should be sized to fit text - password_char - Character that will be used to replace each entered character. Setting to a value indicates this field is a password entry field - -Shorthand functions that are equivalent to `InputText` are `Input` and `In` - - -#### Combo Element -Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. - - layout = [[SG.InputCombo(['choice 1', 'choice 2'])]] - -![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) - - InputCombo(values, - scale=(None, None), - size=(None, None), - auto_size_text=None) -. - - values - Choices to be displayed. List of strings - scale - Amount to scale size by - size - (width, height) of element in characters - auto_size_text - Bool. True if size should fit the text length - -#### Radio Button Element -Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. - - layout = [[SG.Radio('My first Radio!', "RADIO1", default=True), SG.Radio('My second radio!', "RADIO1")]] - -![radio element](https://user-images.githubusercontent.com/13696193/42705705-327b4b6c-86a2-11e8-81a7-740e57646ba8.jpg) - - Radio(text, - group_id, - default=False, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None) - -. - - text - Text to display next to button - group_id - Groups together multiple Radio Buttons. Can be any value - default - Bool. Initial state - scale - Amount to scale size of element - size- (width, height) size of element in characters - auto_size_text - Bool. True if should size width to fit text - font - Font type and size for text display - - -#### Checkbox Element -Checkbox elements are like Radio Button elements. They return a bool indicating whether or not they are checked. - - layout = [[SG.Checkbox('My first Checkbox!', default=True), SG.Checkbox('My second Checkbox!')]] - -![checkbox element](https://user-images.githubusercontent.com/13696193/42717015-655d73d2-86cc-11e8-9c69-3c810f48e578.jpg) - - - Checkbox(text, - default=False, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None): -. - - text - Text to display next to checkbox - default- Bool. Initial state - scale - Amount to scale size of element - size - (width, height) size of element in characters - auto_size_text- Bool. True if should size width to fit text - font- Font type and size for text display - - -#### Spin Element -An up/down spinner control. The valid values are passed in as a list. - - layout = [[SG.Spin([i for i in range(1,11)], initial_value=1), SG.Text('Volume level')]] - -![spin element](https://user-images.githubusercontent.com/13696193/42717231-8ddb51d4-86cd-11e8-827a-75f2237477fa.jpg) - - Spin(values, - intiial_value=None, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None) -. - - values - List of valid values - initial_value - String with initial value - scale - Amount to scale size of element - size - (width, height) size of element in characters - auto_size_text - Bool. True if should size width to fit text - font - Font type and size for text display - -#### Button Element -Buttons are the most important element of all! They cause the majority of the action to happen. After all, it's a button press that will get you out of a form, whether it but Submit or Cancel, one way or another a button is involved in all forms. The only exception is to this is when the user closes the window using the "X" in the upper corner which means no button was involved. - -The Types of buttons include: -* Folder Browse -* File Browse -* Close Form -* Read Form - - - Close Form - Normal buttons like Submit, Cancel, Yes, No, etc, are "Close Form" buttons. They cause the input values to be read and then the form is closed, returning the values to the caller. - -Folder Browse - When clicked a folder browse dialog box is opened. The results of the Folder Browse dialog box are written into one of the input fields of the form. - -File Browse - Same as the Folder Browse except rather than choosing a folder, a single file is chosen. - -Read Form - This is an async form button that will read a snapshot of all of the input fields, but does not close the form after it's clicked. - -While it's possible to build forms using the Button Element directly, you should never need to do that. There are pre-made buttons and shortcuts that will make life much easier. The most basic Button element call to use is `SimpleButton` - - SimpleButton(text, - scale=(None, None), - size=(None, None), - auto_size_text=None, - button_color=None, - font=None) - -Pre-made buttons include: - - OK - Ok - Submit - Cancel - Yes - No - FileBrowse - FolderBrowse -. - layout = [[SG.OK(), SG.Cancel()]] - -![ok cancel](https://user-images.githubusercontent.com/13696193/42717733-1803f584-86d1-11e8-9223-36b782971b9f.jpg) - -The FileBrowse and FolderBrowse buttons both fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. - -The default value for `Target` is `(ThisRow, -1)`. ThisRow is a special value that tells the GUI to use the same row as the button. The Y-value of -1 means the field one value to the left of the button. For a File or Folder Browse button, the field that it fills are generally to the left of the button is most cases. - -Let's examine this form as an example: - -![button target example](https://user-images.githubusercontent.com/13696193/42718075-b4dcb61e-86d3-11e8-904c-d709dd364108.jpg) - -The `InputText` element is located at (1,0)... row 1, column 0. The `Browse` button is located at position (2,0). The Target for the button could be any of these values: - - Target = (1,0) - Target = (-1,0) -The code for the entire form could be: - - layout = [[SG.T('Source Folder')], - [SG.In()], - [SG.FolderBrowse(Target=(-1,0)), SG.OK()]] - -**Custom Buttons** -If you want to define your own button, you will generally do this with the Button Element `SimpleButton`. - -layout = [[SG.SimpleButton('My Button')]] - -![singlebutton](https://user-images.githubusercontent.com/13696193/42718281-9453deca-86d5-11e8-83c7-4b6d33720858.jpg) - -All buttons can have their text changed by changing the `button_text` variable. - -**File Types** -The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is - - FileTypes=(("ALL Files", "*.*"),) - -This code produces a form where the Browse button only shows files of type .TXT - - layout = [[SG.In() ,SG.FileBrowse(file_types=(("Text Files", "*.txt"),))]] - - ***The ENTER key*** - The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. - - ---- -#### ProgressBar -The `ProgressBar` element is used to build custom Progress Bar forms. It is HIGHLY recommended that you use the functions that provide a complete progress meter solution for you. Progress Meters are not easy to work with because the forms have to be non-blocking and they are tricky to debug. - -The **easiest** way to get progress meters into your code is to use the `EasyProgessMeter` API. This consists of a pair of functions, `EasyProgessMeter` and `EasyProgressMeterCancel`. You can easily cancel any progress meter by calling it with the current value = max value. This will mark the meter as expired and close the window. -You've already seen EasyProgressMeter calls presented earlier in this readme. - - SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') - -The return value for `EasyProgressMeter` is: -`True` if meter updated correctly -`False` if user clicked the Cancel button, closed the form, or vale reached the max value. -**Customized Progress Bar** -If you want a bit more customization of your meter, then you can go up 1 level and use the calls to `ProgressMeter` and `ProgressMeterUpdate`. These APIs behave like an object we're all used to. First you create the `ProgressMeter` object, then you call the `Update` method to update it. - -You setup the progress meter by calling - - my_meter = ProgressMeter(title, - max_value, - *args, - d orientantion=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, - button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), - border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) -Then to update the bar within your loop - - return_code = ProgressMeterUpdate(my_meter, - value, - *args): -Putting it all together you get this design pattern - - my_meter = SG.ProgressMeter('Meter Title', 100000, orentation='Vert') - - for i in range(0, 100000): - SG.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') - - -The final way of using a Progress Meter with PySimpleGUI is to build a custom form with a `ProgressBar` Element in the form. You will need to run your form as a non-blocking form. When you are ready to update your progress bar, you call the `UpdateBar` method for the `ProgressBar` element itself. - - -#### Output -The Output Element is a re-direction of Stdout. Anything "printed" will be displayed in this element. - - Output(scale=(None, None), - size=(None, None)) - -Here's a complete solution for a chat-window using an Async form with an Output Element - - import PySimpleGUI as g - - with g.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: - form.AddRow(g.Text('This is where standard out is being routed', size=[40,1])) - form.AddRow(g.Output(size=(80, 20))) - form.AddRow(g.Multiline(size=(70, 5), enter_submits=True), g.ReadFormButton('SEND', button_color=(g.YELLOWS[0], g.BLUES[0])), g.SimpleButton('EXIT', button_color=(g.YELLOWS[0], g.GREENS[0]))) - - # ---===--- Loop taking in user input and printing it --- # - while True: - (button, value) = form.Read() - if button == 'SEND': - print(value) - else: - print('Exiting the form now') - break - - -## Tabbed Forms -Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format - - results = ShowTabbedForm('Title for the form', - (form,layout,'Tab 1 label'), - (form2,layout2, 'Tab 2 label')) - -Each of the tabs of the form is in fact a form. The same steps are taken to create the form as before. A `FlexForm` is created, then rows are filled with Elements, and finally the form is shown. When calling `ShowTabbedForm`, each form is passed in as a tuple. The tuple has the format: `(the form, the rows, a label shown on the tab)` - -## Global Settings -**Global Settings** -You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. - - SetOptions(icon=None, - button_color=(None,None), - element_size=(None,None), - margins=(None,None), - element_padding=(None,None), - auto_size_text=None, - font=None, border_width=None, - autoclose_time=None, - message_box_line_width=None, - progress_meter_border_depth=None): - -Explanation of parameters - - icon - filename of icon used for taskbar and title bar - button_color - button color (foreground, background) - element_size - element size (width, height) in characters - margins - tkinter margins around outsize - element_padding - tkinter padding around each element - auto_size_text - autosize the elements to fit their text - font - font used for elements - border_width - amount of bezel or border around sunken or raised elements - autoclose_time - time in seconds for autoclose boxes - message_box_line_width - number of characers in a line of text in message boxes - progress_meter_border_depth - amount of border around raised or lowered progress meters - - -These settings apply to all forms `SetOptions`. The Row options and Element options will take precedence over these settings. Settings can be thought of as levels of settings with the Form-level being the highest and the Element-level the lowest. Thus the levels are: - - - Form level - - Row level - - Element level - -Each lower level overrides the settings of the higher level - -## Asynchronous (Non-Blocking) Forms -While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. - - -## Sample Applications -Use the example programs as a starting basis for your GUI. Copy, paste, modify and run! The demo files are: -`Demo DisplayHash1and256.py` - Demonstrates using High Level API calls to get a filename -`Demo DupliucateFileFinder.py` - Demonstrates High Level API to get a folder & Easy Progress Meter to show progress of the file scanning -`Demo Recipes.py` - Three sample forms including an asynchronous form -`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. - -## Fun Stuff -Here are some things to try if you're bored or want to further customize - -**Random colors** -To set a button or text to a random color, use the string `'random'` as the color value. You can also call `PySimpleGUI.GetRandomColor`. -To get a random color pair call `PySimpleGUI.GetRandomColorPair`. This returns a tuple containing a random color and -that color's compliment. -sprint - -**sprint** -Call `sprint` with as many parameters as you want and it'll print them all out in a `ScrolledTextBox`. This is simply a function pointing to `PySimpleGUI.ScrolledTextBox`. - ---- -## Known Issues -While not an "issue" this is a ***stern warning*** - -## **Do not attempt** to call `PySimpleGUI` from multiple threads! It's `tkinter` based and `tkinter` has issues with multiple threads - -**Progress Meters** - the visual graphic portion of the meter may be off. May return to the native tkinter progress meter solution in the future. Right now a "custom" progress meter is used. On the bright side, the statistics shown are extremely accurate and can tell you something about the performance of your code. - -## Contributing - -A MikeTheWatchGuy production... entirely responsible for this code.... unless it causes you trouble in which case I'm not at all responsible. - -## Versioning -|Version | Description | -|--|--| -| 1.0.9 | July 10, 2018 - Initial Release | -| 1.0.21 | July 13, 2018 - Readme updates | -| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case - -## Code Condition - - Make it run - Make it right - Make it fast - -It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor for PEP 8 compliance. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. - -While the internals to PySimpleGUI are a tad sketchy, the public interfaces into the SDK are more strictly defined and comply with PEP 8 for the most part. - -## Authors -MikeTheWatchGuy - -## License - -This project is limited to non-commercial applications. If you wish to use it commercially, please contact one of the authors. -For non-commercial individual, the GNU Lesser General Public License (LGPL 3) applies. - -## Acknowledgments - -* Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence - - - - - From 4f67953d6d562134640979fc4ce3aef030397305 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 18 Jul 2018 16:51:29 -0400 Subject: [PATCH 044/209] RELEASE 2.1.1 --- Demo Recipes.py | 175 +++++++-- readme.md | 3 +- readme.rst | 920 ------------------------------------------------ 3 files changed, 143 insertions(+), 955 deletions(-) delete mode 100644 readme.rst diff --git a/Demo Recipes.py b/Demo Recipes.py index 170eea731..b5877fcbd 100644 --- a/Demo Recipes.py +++ b/Demo Recipes.py @@ -1,61 +1,168 @@ -import PySimpleGUI as g +import time +import PySimpleGUI as SG + def SourceDestFolders(): - with g.FlexForm('Demo Source / Destination Folders', auto_size_text=True) as form: - form_rows = [[g.Text('Enter the Source and Destination folders')], - [g.Text('Choose Source and Destination Folders')], - [g.Text('Source Folder', size=(15, 1), auto_size_text=False), g.InputText('Source'), - g.FolderBrowse()], - [g.Text('Destination Folder', size=(15, 1), auto_size_text=False), g.InputText('Dest'), - g.FolderBrowse()], - [g.Submit(), g.Cancel()]] + with SG.FlexForm('Demo Source / Destination Folders', auto_size_text=True) as form: + form_rows = [[SG.Text('Enter the Source and Destination folders')], + [SG.Text('Choose Source and Destination Folders')], + [SG.Text('Source Folder', size=(15, 1), auto_size_text=False), SG.InputText('Source'), SG.FolderBrowse()], + [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False), SG.InputText('Dest'), SG.FolderBrowse()], + [SG.Submit(), SG.Cancel()]] (button, (source, dest)) = form.LayoutAndShow(form_rows) if button == 'Submit': # do something useful with the inputs - g.MsgBox('Submitted', 'The user entered source folder', source, 'And destination folder', dest) + SG.MsgBox('Submitted', 'The user entered source:', source, 'Destination folder:', dest) else: - g.MsgBoxError('Cancelled', 'User Cancelled') + SG.MsgBoxError('Cancelled', 'User Cancelled') + +def Everything_NoContextManager(): + form = SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) + layout = [[SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [SG.Text('Here is some text.... and a place to enter text')], + [SG.InputText()], + [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], + [SG.Radio('My first Radio!', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], + [SG.Multiline(default_text='This is the default Text should you decide not to type anything', scale=(2, 10))], + [SG.InputCombo(['choice 1', 'choice 2'], size=(20, 3))], + [SG.Text('_' * 100, size=(70, 1))], + [SG.Text('Choose Source and Destination Folders', size=(35, 1))], + [SG.Text('Source Folder', size=(15, 1), auto_size_text=False), SG.InputText('Source'), SG.FolderBrowse()], + [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False), SG.InputText('Dest'), SG.FolderBrowse()], + [SG.SimpleButton('Your very own button', button_color=('white', 'green'))], + [SG.Submit(), SG.Cancel()]] + + (button, (values)) = form.LayoutAndShow(layout) + + SG.MsgBox('Title', 'Typical message box', 'The results of the form are a lot of data! Get ready... ', 'The button clicked was "{}"'.format(button), 'The values are', values) + def Everything(): - with g.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40,1)) as form: - layout = [[g.Text('All graphic widgets in one form!', size=(30,1), font=("Helvetica", 25), text_color='blue')], - [g.Text('Here is some text.... and a place to enter text')], - [g.InputText()], - [g.Checkbox('My first checkbox!'), g.Checkbox('My second checkbox!', default=True)], - [g.Radio('My first Radio!', "RADIO1", default=True), g.Radio('My second Radio!', "RADIO1")], - [g.Multiline(default_text='This is the default Text should you decide not to type anything', scale=(2,10))], - [g.InputCombo(['choice 1', 'choice 2'], size=(20,3))], - [g.Text('_' * 100, size=(70,1))], - [g.Text('Choose Source and Destination Folders', size=(35,1))], - [g.Text('Source Folder', size=(15,1), auto_size_text=False), g.InputText('Source'), g.FolderBrowse()], - [g.Text('Destination Folder', size=(15,1), auto_size_text=False), g.InputText('Dest'), g.FolderBrowse()], - [g.SimpleButton('Your very own button', button_color=('white', 'green'))], - [g.Submit(), g.Cancel()]] + with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [[SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [SG.Text('Here is some text.... and a place to enter text')], + [SG.InputText()], + [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], + [SG.Radio('My first Radio!', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], + [SG.Multiline(default_text='This is the default Text should you decide not to type anything', scale=(2, 10))], + [SG.InputCombo(['choice 1', 'choice 2'], size=(20, 3))], + [SG.Text('_' * 100, size=(70, 1))], + [SG.Text('Choose Source and Destination Folders', size=(35, 1))], + [SG.Text('Source Folder', size=(15, 1), auto_size_text=False), SG.InputText('Source'), SG.FolderBrowse()], + [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False), SG.InputText('Dest'), SG.FolderBrowse()], + [SG.SimpleButton('Your very own button', button_color=('white', 'green'))], + [SG.Submit(), SG.Cancel()]] (button, (values)) = form.LayoutAndShow(layout) - g.MsgBox('Title', 'Typical message box', 'The results of the form are a lot of data! Get ready... ', 'The button clicked was "{}"'.format(button), 'The values are', values, auto_close=True) + SG.MsgBox('Title', 'Typical message box', 'The results of the form are a lot of data! Get ready... ', 'The button clicked was "{}"'.format(button), 'The values are', values) + +def ProgressMeter(): + for i in range(1,10000): + if not SG.EasyProgressMeter('My Meter', i+1, 10000): break + -# example of an Asynchronous form +# Persistant form. Does not close when Send button is clicked. +# Normally all Simple Buttons cause forms to close def ChatBot(): - with g.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: - form.AddRow(g.Text('This is where standard out is being routed', size=[40,1])) - form.AddRow(g.Output(size=(80, 20))) - form.AddRow(g.Multiline(size=(70, 5), enter_submits=True), g.ReadFormButton('SEND', button_color=(g.YELLOWS[0], g.BLUES[0])), g.SimpleButton('EXIT', button_color=(g.YELLOWS[0], g.GREENS[0]))) + with SG.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + form.AddRow(SG.Text('This is where standard out is being routed', size=[40, 1])) + form.AddRow(SG.Output(size=(80, 20))) + form.AddRow(SG.Multiline(size=(70, 5), enter_submits=True), SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))) + (button, value) = form.Read() # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # while True: - (button, value) = form.Read() if button == 'SEND': - print(value, end="") + print(value) else: break + (button, value) = form.Read() + + +def NonBlockingPeriodicUpdateForm_ContextManager(): + # Show a form that's a running counter + with SG.FlexForm('Running Timer', auto_size_text=True) as form: + output_element = SG.Text('',size=(8,2), font=('Helvetica', 20), text_color='red') + form_rows = [[SG.Text('None blocking GUI with updates')], + [output_element], + [SG.Quit()]] + form.AddRows(form_rows) + form.Show(non_blocking=True) + + for i in range(1,500): + output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i/100), 60), i%100)) + rc = form.OutputFlush() + if rc is None: # if user closed the window using X + break + button, values = rc + if button == 'Quit': + break + time.sleep(.01) + else: + # if the loop finished then need to close the form for the user + form.CloseNonBlockingForm() + + +def NonBlockingPeriodicUpdateForm(): + # Show a form that's a running counter + form = SG.FlexForm('Running Timer', auto_size_text=True) + output_element = SG.Text('',size=(8,2), font=('Helvetica', 20)) + form_rows = [[SG.Text('Non blocking GUI with updates')], + [output_element], + [SG.Quit()]] + form.AddRows(form_rows) + form.Show(non_blocking=True) + + for i in range(1,50000): + output_element.Update(f'{(i/100)/60:02d}:{(i/100)%60:02d}.{i%100:02d}') + rc = form.OutputFlush() + if rc is None: # if user closed the window using X + break + button, values = rc + if button == 'Quit': + break + time.sleep(.01) + else: + # if the loop finished then need to close the form for the user + form.CloseNonBlockingForm() + + +def NonBlockingScrolledPrintForm(): + # Show a form that's a running counter + form = SG.FlexForm('Scrolled Print', auto_size_text=True, font=('Courier New', 12)) + output_element = SG.Output(size=(42,10)) + form_rows = [[SG.Text('Scrolled print output')], + [output_element], + [SG.Quit()]] + form.AddRows(form_rows) + form.Show(non_blocking=True) # Show a ;non-blocking form, returns immediately + + for i in range(1,50000): + print(f'{i} ', end="") # all print output will go to the scrolled text box + # must call OutputFlush on a periodic basis to keep GUI alive + rc = form.OutputFlush() + if rc is None: # if user closed the window using X + break + button, values = rc + if button == 'Quit': # if user cliced Quit button + break + else: # if the loop finished then need to close the form for the user + form.CloseNonBlockingForm() + + def main(): + SG.SetOptions(border_width=4, element_padding=(4,6), font=("Helvetica", 10), button_color=('white', SG.BLUES[0]), + progress_meter_border_depth=4) SourceDestFolders() - Everything() + ProgressMeter() ChatBot() + NonBlockingScrolledPrintForm() + NonBlockingPeriodicUpdateForm_ContextManager() + Everything_NoContextManager() + Everything() if __name__ == '__main__': main() diff --git a/readme.md b/readme.md index 218343e0d..d389d8f86 100644 --- a/readme.md +++ b/readme.md @@ -891,6 +891,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 1.0.9 | July 10, 2018 - Initial Release | | 1.0.21 | July 13, 2018 - Readme updates | | 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case +| 2.1.1 | July 18, 2018 - Global settings exposed, fixes ## Code Condition @@ -906,7 +907,7 @@ While the internals to PySimpleGUI are a tad sketchy, the public interfaces into MikeTheWatchGuy ## License - + This project is limited to non-commercial applications. If you wish to use it commercially, please contact one of the authors. For non-commercial individual, the GNU Lesser General Public License (LGPL 3) applies. diff --git a/readme.rst b/readme.rst deleted file mode 100644 index 218343e0d..000000000 --- a/readme.rst +++ /dev/null @@ -1,920 +0,0 @@ - -# PySimpleGUI - -This really is a simple GUI, but also powerfully customizable. - - import PySimpleGUI as SG - - SG.MsgBox('My Message Box', 'This is the shortest GUI program ever!') - -![snap0102](https://user-images.githubusercontent.com/13696193/42781058-1d28d9fa-8913-11e8-847e-5c2afc16ca4c.jpg) - -I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? - -There are a number of 'easy to use' Python GUIs, but they're quite limiting. PySimpleGUI tried to take the best of packages like `EasyGUI`(no longer maintained) and `WxSimpleGUI` (a great package, but was too limited for my application). `PySimpleGUI` provides similar single-call-message-box solutions as you'll see. - -GUI Packages with more functionality, like QT and WxPython, require configuring and can take a ***week*** to get *reasonably familiar* with the interfaces. - -With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. - -The `PySimpleGUI` solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? - -You can add a GUI to your command line with a single line of code. With 3 or 4 lines of code you can add a fully customized GUI. And for you Machine Learning folks out there, a **single line** progress meter call that you can drop into any loop to get a graphic like this one: - - -![progress meter 2](https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg) - - - - - Features of PySimpleGUI include: - Text - Single Line Input - Buttons including these types: - File Browse - Folder Browse - Non-closing return - Close form - Checkboxes - Radio Buttons - Icons - Multi-line Text Input - Scroll-able Output - Progress Bar - Async/Non-Blocking Windows - Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling Window - 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) - - -An example of many widgets used on a single form. A little further down you'll find the FIFTEEN lines of code required to create this complex form. - -![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) - - ----- -## Getting Started with PySimpleGUI - -### Installing - - pip install PySimpleGUI - or -Simply download the file - PySimpleGUI.py and import it into your code - - -### Prerequisites - -Python 3 -tkinter - -Should run on all Python platforms that have tkinter running on them. Has been thoroughly tested on Windows. While not tested elsewhere, should work on Linux, Mac, Pi, etc. - -### Using - -To use in your code, simply import.... - `import PySimpleGUI as SG` - -Then use either "high level" API calls or build your own forms. - - SG.MsgBox('This is my first message box') -![snap0103](https://user-images.githubusercontent.com/13696193/42844641-a04bb798-89e1-11e8-8a37-50ddd9905772.jpg) - -Yes, it's just that easy to have a window appear on the screen using Python. With PySimpleGUI, making a custom form appear isn't much more difficult. The goal is to get you running on your GUI within ***minutes***, not hours nor days. - ---- -## APIs - -PySimpleGUI can be broken down into 2 types of API's: - * High Level single call functions - * Custom form functions - - -### Python Language Features - - There are a couple of Python language features that PySimpleGUI utilizes heavily that should be understood first... - * Variable number of arguments to a function call - * Optional parameters to a function call - -#### Variable Number of Arguments - - The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. - - SG.MsgBox('Variable number of parameters example', var1, var2, "etc") - -Each new item begins on a new line in the Message Box - - ![snap0104](https://user-images.githubusercontent.com/13696193/42844739-ebea22ac-89e1-11e8-8dd1-e61441325701.jpg) - - -#### Optional Parameters to a Function Call - -This feature of the Python language is utilized ***heavily*** as a method of customizing forms and form Elements. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. - -Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't *have* to be specified on each and every call. - - def MsgBox(*args, - button_color=None, - button_type=MSG_BOX_OK, - auto_close=False, - auto_close_duration=None, - icon=DEFAULT_WINDOW_ICON, - line_width=MESSAGE_BOX_LINE_WIDTH, - font=None): - -If the caller wanted to change the button color to be black on yellow, the call would look something like this: - - SG.MsgBox('This box has a custom button color', - button_color=('black', 'yellow')) - - -![snap0105](https://user-images.githubusercontent.com/13696193/42844830-2d7e8b9a-89e2-11e8-8ef4-5af9e36f30f3.jpg) - - ---- - -### High Level API Calls - -The classic "input a value, print result" example. -Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. -This code prompts user to input a line of text and then displays that text in a messages box: - - import PySimpleGUI_local as SG - - rc = SG.GetTextBox('Title', 'Please input something') - SG.MsgBox('Results', 'The value returned from GetTextBox', rc) - -![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) - -![MsgBox](https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg) - -#### Message Boxes -In addition to MsgBox, you'll find a several API calls that are shortcuts to common messages boxes. You can achieve similar results by calling MsgBox with the correct parameters. - -The differences tend to be the number and types of buttons. Here are the calls and the windows that are created. - - import PySimpleGUI as SG - - `SG.MsgBoxOK('This is an OK MsgBox')` - - ![msgboxok](https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg) - - SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') - -![msgboxokcancel](https://user-images.githubusercontent.com/13696193/42599858-8e8eff22-852e-11e8-8d5c-3fe99237eb7f.jpg) - - SG.MsgBoxCancel('This is a Cancel MsgBox') -![msgboxcancel](https://user-images.githubusercontent.com/13696193/42599857-8e53dc4e-852e-11e8-8e83-6a8cccf8e706.jpg) - - SG.MsgBoxYesNo('This is a Yes No MsgBox') -![msgboxyesno](https://user-images.githubusercontent.com/13696193/42599856-8e304540-852e-11e8-975d-fb2b62e94300.jpg) - - SG.MsgBoxError('This is an error MsgBox') -![msgbox error](https://user-images.githubusercontent.com/13696193/42599853-8df8e078-852e-11e8-90dc-7815d69bff7e.jpg) - - SG.MsgBoxAutoClose('This is an autoclose MsgBox') - -![msgbox autoclose](https://user-images.githubusercontent.com/13696193/42599855-8e147572-852e-11e8-8c23-7ec771909062.jpg) - - SG.ScrolledTextBox(my_text, height=10) - -![scrolledtextbox](https://user-images.githubusercontent.com/13696193/42600800-a44f4562-8531-11e8-8c21-51dd70316879.jpg) - -Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. Your code could contain a line like: - - sprint(f'My variables values include x={x}', f'y={y}') - -This becomes a debug print of sorts that will route to a scrolled window. - -#### High Level User Input - -There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. If you need only 1 value, then perhaps one of these high level functions will work. - - GetTextBox - - GetFileBox - - GetFolderBox - - `submit_clicked, value = SG.GetTextBox('Title', 'Please enter anything')` - -![gettextbox](https://user-images.githubusercontent.com/13696193/42600399-1ef66a5e-8530-11e8-9bc4-78ea839213cd.jpg) - - submit_clicked, value = SG.GetFileBox('Title', 'Choose a file') - -![getfilebox](https://user-images.githubusercontent.com/13696193/42600398-1ed8a122-8530-11e8-9f74-88b101efcea4.jpg) - - submit_clicked, value = SG.GetPathBox('Title', 'Choose a folder') - -![getfolderbox](https://user-images.githubusercontent.com/13696193/42600397-1ea7cef8-8530-11e8-8d43-e1000c0933cd.jpg) - -#### Progress Meter! -We all have loops in our code. 'Isn't it joyful waiting, watching a counter scrolling past in a text window? How about one line of code to get a progress meter, that contains statistics about your code? -![progress meter 3](https://user-images.githubusercontent.com/13696193/42696332-dca3ca6e-8685-11e8-846b-6bee8362ee5f.jpg) - - EasyProgressMeter(title, - current_value, - max_value, - *args, - orientation=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, - button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), - border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): - -Here's the one-line Progress Meter in action! - - for i in range(1,10000): - SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') - -That line of code resulted in this window popping up and updating. - -![progress meter 5](https://user-images.githubusercontent.com/13696193/42696912-a5c958b8-8687-11e8-9a7d-a390a465407a.jpg) - -A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. -With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. - - if not SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message'): - break - -***Be sure and add one to your loop counter*** so that your counter goes from 1 to the max value. If you do not add one, your counter will never hit the max value. Instead it will go from 0 to max-1. - ---- -# Custom Form API Calls - -This is the FUN part of the programming of this GUI. In order to really get the most out of the API, you should be using an IDE that supports auto complete or will show you the definition of the function. This will make customizing go smoother. - -It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. Let's start with a basic Browse for a file and do something with it. -# Copy these design patterns! -## Pattern 1 - With Context Manager - - with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], - [SG.InputText(), SG.FileBrowse()], - [SG.Submit(), SG.Cancel()]] - (button, (source_filename, )) = form.LayoutAndShow(form_rows) - -## Pattern 2 - No Context Manager - - form = SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], - [SG.InputText(), SG.FileBrowse()], - [SG.Submit(), SG.Cancel()]] - (button, (source_filename,)) = form.LayoutAndShow(form_rows) - - -These 2 design patters both produce this custom form: - -![sha hash](https://user-images.githubusercontent.com/13696193/42603149-a56acf3a-853a-11e8-91de-771efd3a65a8.jpg) - -It's important to use the "with" context manager so that resources are freed as quickly as possible, using the currently executing thread. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. - -The second design pattern is not context manager based. There are times when the context manager hides errors. If you are struggling with an unknown error, try modifying the code to run without a context manager. - -You will use these design patterns or code templates for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. This is the most basic / normal of the design patterns. - -### Line by line explanation - -Going through each line of code in the above form will help explain how to use this design patter. Copy, modify and run it! - - with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: -This creates a new form, storing it in the variable `form`. - - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], -The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. - - [SG.InputText(), SG.FileBrowse()], -Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. - - [SG.Submit(), SG.Cancel()]] - -The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its value to the caller. - - (button, (source_filename, )) = form.LayoutAndShow(form_rows) -This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field - ---- -### Design Goals -> Copy, Paste, Run. - -`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the SDK to visually match what's on the screen. - -Forms are represented as Python lists. There are 2 lists in particular. One is a list of rows that form up a GUI screen. The other is a list of Elements (or Widgets) on each row. Each Elements is specified by names such as Text, Button, Checkbox, etc. - -Some elements are shortcuts, meant to make it easy on the programmer who will write less code using them. Rather than writing a `Button`, with `button_name = "Submit"`, etc, the caller can simply writes `Submit`. Some examples include: `Text` has a short-cut function named `T`. `TextInput` has `In`. See each API call for the shortcuts. - - ---- - -## Return values - - Return information from FlexForm, SG's primary form builder interface, is in this format: - - (button, (value1, value2, ...)) - -Each of the Elements that are Input Elements will have a value in the list of return values. You can unpack your GUI directly into the variables you want to use. - - (button, (filename, folder1, folder2, should_overwrite) = form.LayoutAndShow(form_rows) - - -If you have a SINGLE value being returned, it is written this way: - - (button, (value1,)) = form.LayoutAndShow(form_rows) - Another way of parsing the return values is to store the list of values into a variable representing the list of values. - - (button, (value_list)) = form.LayoutAndShow(form_rows) - value1 = value_list[0] - value2 = value_list[1] - ... - ---- -## All Widgets / Elements -This code utilizes as many of the elements in one form as possible. - - with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: - layout = [[Text('Here they all are!', size=(30,1), font=("Helvetica", 25), text_color='red')], - [Text('Here is some text with font sizing', font=("Helvetica", 15))], - [InputText()], - [Checkbox('My first checkbox!'), Checkbox('My second checkbox!', default=True)], - [Radio('My first Radio!', "RADIO1", default=True), Radio('My second checkbox!', "RADIO1")], - [Multiline(DefaultText='This is the DEFAULT text should you decide not to type anything', scale=(2, 10))], - [InputCombo(['choice 1', 'choice 2'], size=(20, 3))], - [Text('_' * 90, size=(60, 1))], - [Text('Choose Source and Destination Folders', size=(35,1))], - [Text('Source Folder', size=(15, 1), auto_size_text=False), InputText('Source'), FolderBrowse()], - [Text('Destination Folder', size=(15, 1), auto_size_text=False), InputText('Dest'), FolderBrowse()], - [SimpleButton('Your Button with any text you want')], - [SimpleButton('Big Text', size=(12,1), font=("Helvetica", 20))], - [Submit(), Cancel()]] - - (button, (values)) = form.LayoutAndShow(layout) - - MsgBox('Results', 'You clicked {}'.format(button),'The values returned from form', values , font = ("Helvetica", 15)) - -This is a somewhat complex form with quite a bit of custom sizing to make things line up well. This is code you only have to write once. When looking at the code, remember that what you're seeing is a list of lists. Each row contains a list of Graphical Elements that are used to create the form. - -![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) - -Clicking the Submit button caused the form call to return. The call to MsgBox resulted in this dialog box. -![results](https://user-images.githubusercontent.com/13696193/42604952-502f64e6-8543-11e8-8045-bc10d38c5fd4.jpg) - - - (button, (values)) = form.LayoutAndShow(layout) -**`Note, button value can be None`**. The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. - -You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. - ---- -# Building Custom Forms -You will find it much easier to write code using PySimpleGUI if you use an IDE such as PyCharm. The features that show you documentation about the API call you are making will help you determine which settings you want to change, if any. In PyCharm, two commands are particularly helpful. - - Control-Q (when cursor is on function name) brings up a box with the function definition - Control-P (when cursor inside function call "()") shows a list of parameters and their default values - -## Synchronous Forms -The most common use of PySimpleGUI is to display and collect information from the user. The most straightforward way to do this is using a "blocking" GUI call. Execution is "blocked" while waiting for the user to close the GUI form/dialog box. -You've already seen a number of examples above that use blocking forms. Anytime you see a context manager used (see the `with` statement) it's most likely a blocking form. You can examine the show calls to be sure. If the form is a non-blocking form, it must indicate that in the call to `form.show`. - -NON-BLOCKING form call: - - form.Show(non_blocking=True) - -### Beginning a Form -The first step is to create the form object using the desired form customization. - - with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: - -This is the definition of the FlexForm object: - - def FlexForm(title, - default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), - auto_size_text=DEFAULT_AUTOSIZE_TEXT, - scale=(None, None), - location=(None, None), - button_color=None,Font=None, - progress_bar_color=(None,None), - is_tabbed_form=False, - border_depth=None, - auto_close=False, - auto_close_duration=DEFAULT_AUTOCLOSE_TIME, - icon=DEFAULT_WINDOW_ICON): - -Parameter Descriptions. You will find these same parameters specified for each `Element` and some of them in `Row` specifications. The `Element` specified value will take precedence over the `Row` and `Form` values. - - default_element_size - Size of elements in form in characters (width, height) - auto_size_text - Bool. True is elements should size themselves according to contents - scale - Set size of element to be a multiple of the Element size - location - Location to place window in pixels - button_color - Default color for buttons (foreground, background). Can be text or hex - progress_bar_color - Foreground and background colors for progress bars - is_tabbed_form - Bool. If True then form is a tabbed form - border_depth - Amount of 'bezel' to put on input boxes, buttons, etc. - auto_close - Bool. If True form will autoclose - auto_close_duration - Duration in seconds before form closes - icon - .ICO file that will appear on the Task Bar and end of Title Bar - - -#### Sizes -Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. - -The default Element size for PySimpleGUI is `(45,1)`. - -Sizes can be set at the element level, or in this case, the size variables apply to all elements in the form. Setting `size=(20,1)` in the form creation call will set all elements in the form to that size. - -In addition to `size` there is a `scale` option. `scale` will take the Element's size and scale it up or down depending on the scale value. `scale=(1,1)` doesn't change the Element's size. `scale=(2,1)` will set the Element's size to be twice as wide as the size setting. - - -#### FlexForm - form-level variables overview -A summary of the variables that can be changed when a FlexForm is created - - default_element_size - set default size for all elements in the form - auto_size_text- true/false autosizing turned on / off - scale - set scale value for all elements - button_color- default button color (foreground, background) - font - font name and size for all text items - progress_bar_color - progress bar colors - is_tabbed_form - true/false indicates form is a tabbed or normal form - border_depth - style setting for buttons, input fields - auto_close - true/false indicates if form will automatically close - auto_close_duration - how long in seconds before closing form - icon - filename for icon that's displayed on the window on taskbar - - -## Elements -"Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. - - Text - Single Line Input - Buttons including these types: - File Browse - Folder Browse - Non-closing return - Close form - Checkboxes - Radio Buttons - Multi-line Text Input - Scroll-able Output - Progress Bar - Async/Non-Blocking Windows - Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling Window - "Higher level" APIs (e.g. MessageBox, YesNobox, ...) - - -### Output Elements -Building a form is simply making lists of Elements. Each list is a row in the overall GUI dialog box. The definition looks something like this: - - layout = [ [row 1 element, row 1 element], - [row 2 element, row 2 element, row 2 element] ] -The code is a crude representation of the GUI, laid out in text. -#### Text Element - - layout = [[SG.Text('This is what a Text Element looks like')]] - - - ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) - - -The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. - - Text(Text, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None, - text_color=None) - -Some commonly used elements have 'shorthand' versions of the functions to make the code more compact. The functions `T` and `Txt` are the same as calling `Text`. - -**Fonts** in PySimpleGUI are always in this format: - - (font_name, point_size) - -The default font setting is - - ("Helvetica", 10) - -**Color** in PySimpleGUI are always in this format: - - (foreground, background) - -The values foreground and background can be the color names or the hex value formatted as a string: - - "#RRGGBB" - -**auto_size_text** -A `True` value for `auto_size_text`, when placed on any Element, indicates that the width of the Element should be shrunk do the width of the text. This is particularly useful with `Buttons` as fixed-width buttons are somewhat crude looking. The default value is `False`. You will often see this setting on FlexForm definitions. - -**Shorthand functions** -The shorthand functions for `Text` are `Txt` and `T` - - -#### Multiline Text Element - - layout = [[SG.Multiline('This is what a Multi-line Text Element looks like', size=(45,5))]] -![multiline text](https://user-images.githubusercontent.com/13696193/42670464-0824c754-8629-11e8-9741-6ed08f924618.jpg) -This Element doubles as both an input and output Element. The `DefaultText` optional parameter is used to indicate what to output to the window. - - Multiline(default_text='', - enter_submits = False, - scale=(None, None), - size=(None, None), - auto_size_text=None) -. - - default_text - Text to display in the text box - enter_submits - Bool. If True, pressing Enter key submits form - scale - Element's scale - size - Element's size - auto_size_text - Bool. Change width to match size of text - -#### Output Element -Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. More on this later. - - form.AddRow(gg.Output(size=(100,20))) - -![output element](https://user-images.githubusercontent.com/13696193/42704820-5446959c-869f-11e8-849e-047ea280387a.jpg) - - Output(scale=(None, None), - size=(None, None)) -. - - scale - How much to scale size of element - size - Size of element (width, height) in characters - -### Input Elements - These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. - -#### Text Input Element - - layout = [[SG.InputText('Default text')]] -![inputtext](https://user-images.githubusercontent.com/13696193/42693515-610a716c-867d-11e8-9a00-7e7fcf771230.jpg) - - def InputText(default_text = '', - scale=(None, None), - size=(None, None), - auto_size_text=None, - password_char='') -. - - default_text - Text initially shown in the input box - scale - Amount size is scaled by - size - (width, height) of element in characters - auto_size_text- Bool. True is element should be sized to fit text - password_char - Character that will be used to replace each entered character. Setting to a value indicates this field is a password entry field - -Shorthand functions that are equivalent to `InputText` are `Input` and `In` - - -#### Combo Element -Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. - - layout = [[SG.InputCombo(['choice 1', 'choice 2'])]] - -![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) - - InputCombo(values, - scale=(None, None), - size=(None, None), - auto_size_text=None) -. - - values - Choices to be displayed. List of strings - scale - Amount to scale size by - size - (width, height) of element in characters - auto_size_text - Bool. True if size should fit the text length - -#### Radio Button Element -Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. - - layout = [[SG.Radio('My first Radio!', "RADIO1", default=True), SG.Radio('My second radio!', "RADIO1")]] - -![radio element](https://user-images.githubusercontent.com/13696193/42705705-327b4b6c-86a2-11e8-81a7-740e57646ba8.jpg) - - Radio(text, - group_id, - default=False, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None) - -. - - text - Text to display next to button - group_id - Groups together multiple Radio Buttons. Can be any value - default - Bool. Initial state - scale - Amount to scale size of element - size- (width, height) size of element in characters - auto_size_text - Bool. True if should size width to fit text - font - Font type and size for text display - - -#### Checkbox Element -Checkbox elements are like Radio Button elements. They return a bool indicating whether or not they are checked. - - layout = [[SG.Checkbox('My first Checkbox!', default=True), SG.Checkbox('My second Checkbox!')]] - -![checkbox element](https://user-images.githubusercontent.com/13696193/42717015-655d73d2-86cc-11e8-9c69-3c810f48e578.jpg) - - - Checkbox(text, - default=False, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None): -. - - text - Text to display next to checkbox - default- Bool. Initial state - scale - Amount to scale size of element - size - (width, height) size of element in characters - auto_size_text- Bool. True if should size width to fit text - font- Font type and size for text display - - -#### Spin Element -An up/down spinner control. The valid values are passed in as a list. - - layout = [[SG.Spin([i for i in range(1,11)], initial_value=1), SG.Text('Volume level')]] - -![spin element](https://user-images.githubusercontent.com/13696193/42717231-8ddb51d4-86cd-11e8-827a-75f2237477fa.jpg) - - Spin(values, - intiial_value=None, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None) -. - - values - List of valid values - initial_value - String with initial value - scale - Amount to scale size of element - size - (width, height) size of element in characters - auto_size_text - Bool. True if should size width to fit text - font - Font type and size for text display - -#### Button Element -Buttons are the most important element of all! They cause the majority of the action to happen. After all, it's a button press that will get you out of a form, whether it but Submit or Cancel, one way or another a button is involved in all forms. The only exception is to this is when the user closes the window using the "X" in the upper corner which means no button was involved. - -The Types of buttons include: -* Folder Browse -* File Browse -* Close Form -* Read Form - - - Close Form - Normal buttons like Submit, Cancel, Yes, No, etc, are "Close Form" buttons. They cause the input values to be read and then the form is closed, returning the values to the caller. - -Folder Browse - When clicked a folder browse dialog box is opened. The results of the Folder Browse dialog box are written into one of the input fields of the form. - -File Browse - Same as the Folder Browse except rather than choosing a folder, a single file is chosen. - -Read Form - This is an async form button that will read a snapshot of all of the input fields, but does not close the form after it's clicked. - -While it's possible to build forms using the Button Element directly, you should never need to do that. There are pre-made buttons and shortcuts that will make life much easier. The most basic Button element call to use is `SimpleButton` - - SimpleButton(text, - scale=(None, None), - size=(None, None), - auto_size_text=None, - button_color=None, - font=None) - -Pre-made buttons include: - - OK - Ok - Submit - Cancel - Yes - No - FileBrowse - FolderBrowse -. - layout = [[SG.OK(), SG.Cancel()]] - -![ok cancel](https://user-images.githubusercontent.com/13696193/42717733-1803f584-86d1-11e8-9223-36b782971b9f.jpg) - -The FileBrowse and FolderBrowse buttons both fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. - -The default value for `Target` is `(ThisRow, -1)`. ThisRow is a special value that tells the GUI to use the same row as the button. The Y-value of -1 means the field one value to the left of the button. For a File or Folder Browse button, the field that it fills are generally to the left of the button is most cases. - -Let's examine this form as an example: - -![button target example](https://user-images.githubusercontent.com/13696193/42718075-b4dcb61e-86d3-11e8-904c-d709dd364108.jpg) - -The `InputText` element is located at (1,0)... row 1, column 0. The `Browse` button is located at position (2,0). The Target for the button could be any of these values: - - Target = (1,0) - Target = (-1,0) -The code for the entire form could be: - - layout = [[SG.T('Source Folder')], - [SG.In()], - [SG.FolderBrowse(Target=(-1,0)), SG.OK()]] - -**Custom Buttons** -If you want to define your own button, you will generally do this with the Button Element `SimpleButton`. - -layout = [[SG.SimpleButton('My Button')]] - -![singlebutton](https://user-images.githubusercontent.com/13696193/42718281-9453deca-86d5-11e8-83c7-4b6d33720858.jpg) - -All buttons can have their text changed by changing the `button_text` variable. - -**File Types** -The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is - - FileTypes=(("ALL Files", "*.*"),) - -This code produces a form where the Browse button only shows files of type .TXT - - layout = [[SG.In() ,SG.FileBrowse(file_types=(("Text Files", "*.txt"),))]] - - ***The ENTER key*** - The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. - - ---- -#### ProgressBar -The `ProgressBar` element is used to build custom Progress Bar forms. It is HIGHLY recommended that you use the functions that provide a complete progress meter solution for you. Progress Meters are not easy to work with because the forms have to be non-blocking and they are tricky to debug. - -The **easiest** way to get progress meters into your code is to use the `EasyProgessMeter` API. This consists of a pair of functions, `EasyProgessMeter` and `EasyProgressMeterCancel`. You can easily cancel any progress meter by calling it with the current value = max value. This will mark the meter as expired and close the window. -You've already seen EasyProgressMeter calls presented earlier in this readme. - - SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') - -The return value for `EasyProgressMeter` is: -`True` if meter updated correctly -`False` if user clicked the Cancel button, closed the form, or vale reached the max value. -**Customized Progress Bar** -If you want a bit more customization of your meter, then you can go up 1 level and use the calls to `ProgressMeter` and `ProgressMeterUpdate`. These APIs behave like an object we're all used to. First you create the `ProgressMeter` object, then you call the `Update` method to update it. - -You setup the progress meter by calling - - my_meter = ProgressMeter(title, - max_value, - *args, - d orientantion=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, - button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), - border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) -Then to update the bar within your loop - - return_code = ProgressMeterUpdate(my_meter, - value, - *args): -Putting it all together you get this design pattern - - my_meter = SG.ProgressMeter('Meter Title', 100000, orentation='Vert') - - for i in range(0, 100000): - SG.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') - - -The final way of using a Progress Meter with PySimpleGUI is to build a custom form with a `ProgressBar` Element in the form. You will need to run your form as a non-blocking form. When you are ready to update your progress bar, you call the `UpdateBar` method for the `ProgressBar` element itself. - - -#### Output -The Output Element is a re-direction of Stdout. Anything "printed" will be displayed in this element. - - Output(scale=(None, None), - size=(None, None)) - -Here's a complete solution for a chat-window using an Async form with an Output Element - - import PySimpleGUI as g - - with g.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: - form.AddRow(g.Text('This is where standard out is being routed', size=[40,1])) - form.AddRow(g.Output(size=(80, 20))) - form.AddRow(g.Multiline(size=(70, 5), enter_submits=True), g.ReadFormButton('SEND', button_color=(g.YELLOWS[0], g.BLUES[0])), g.SimpleButton('EXIT', button_color=(g.YELLOWS[0], g.GREENS[0]))) - - # ---===--- Loop taking in user input and printing it --- # - while True: - (button, value) = form.Read() - if button == 'SEND': - print(value) - else: - print('Exiting the form now') - break - - -## Tabbed Forms -Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format - - results = ShowTabbedForm('Title for the form', - (form,layout,'Tab 1 label'), - (form2,layout2, 'Tab 2 label')) - -Each of the tabs of the form is in fact a form. The same steps are taken to create the form as before. A `FlexForm` is created, then rows are filled with Elements, and finally the form is shown. When calling `ShowTabbedForm`, each form is passed in as a tuple. The tuple has the format: `(the form, the rows, a label shown on the tab)` - -## Global Settings -**Global Settings** -You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. - - SetOptions(icon=None, - button_color=(None,None), - element_size=(None,None), - margins=(None,None), - element_padding=(None,None), - auto_size_text=None, - font=None, border_width=None, - autoclose_time=None, - message_box_line_width=None, - progress_meter_border_depth=None): - -Explanation of parameters - - icon - filename of icon used for taskbar and title bar - button_color - button color (foreground, background) - element_size - element size (width, height) in characters - margins - tkinter margins around outsize - element_padding - tkinter padding around each element - auto_size_text - autosize the elements to fit their text - font - font used for elements - border_width - amount of bezel or border around sunken or raised elements - autoclose_time - time in seconds for autoclose boxes - message_box_line_width - number of characers in a line of text in message boxes - progress_meter_border_depth - amount of border around raised or lowered progress meters - - -These settings apply to all forms `SetOptions`. The Row options and Element options will take precedence over these settings. Settings can be thought of as levels of settings with the Form-level being the highest and the Element-level the lowest. Thus the levels are: - - - Form level - - Row level - - Element level - -Each lower level overrides the settings of the higher level - -## Asynchronous (Non-Blocking) Forms -While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. - - -## Sample Applications -Use the example programs as a starting basis for your GUI. Copy, paste, modify and run! The demo files are: -`Demo DisplayHash1and256.py` - Demonstrates using High Level API calls to get a filename -`Demo DupliucateFileFinder.py` - Demonstrates High Level API to get a folder & Easy Progress Meter to show progress of the file scanning -`Demo Recipes.py` - Three sample forms including an asynchronous form -`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. - -## Fun Stuff -Here are some things to try if you're bored or want to further customize - -**Random colors** -To set a button or text to a random color, use the string `'random'` as the color value. You can also call `PySimpleGUI.GetRandomColor`. -To get a random color pair call `PySimpleGUI.GetRandomColorPair`. This returns a tuple containing a random color and -that color's compliment. -sprint - -**sprint** -Call `sprint` with as many parameters as you want and it'll print them all out in a `ScrolledTextBox`. This is simply a function pointing to `PySimpleGUI.ScrolledTextBox`. - ---- -## Known Issues -While not an "issue" this is a ***stern warning*** - -## **Do not attempt** to call `PySimpleGUI` from multiple threads! It's `tkinter` based and `tkinter` has issues with multiple threads - -**Progress Meters** - the visual graphic portion of the meter may be off. May return to the native tkinter progress meter solution in the future. Right now a "custom" progress meter is used. On the bright side, the statistics shown are extremely accurate and can tell you something about the performance of your code. - -## Contributing - -A MikeTheWatchGuy production... entirely responsible for this code.... unless it causes you trouble in which case I'm not at all responsible. - -## Versioning -|Version | Description | -|--|--| -| 1.0.9 | July 10, 2018 - Initial Release | -| 1.0.21 | July 13, 2018 - Readme updates | -| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case - -## Code Condition - - Make it run - Make it right - Make it fast - -It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor for PEP 8 compliance. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. - -While the internals to PySimpleGUI are a tad sketchy, the public interfaces into the SDK are more strictly defined and comply with PEP 8 for the most part. - -## Authors -MikeTheWatchGuy - -## License - -This project is limited to non-commercial applications. If you wish to use it commercially, please contact one of the authors. -For non-commercial individual, the GNU Lesser General Public License (LGPL 3) applies. - -## Acknowledgments - -* Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence - - - - - From 8a2456ce20ba52b531c5fa77ea3e7f4b804fe225 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 18 Jul 2018 18:02:27 -0400 Subject: [PATCH 045/209] Demo updated --- Demo GoodColors.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Demo GoodColors.py diff --git a/Demo GoodColors.py b/Demo GoodColors.py new file mode 100644 index 000000000..7d0402f8d --- /dev/null +++ b/Demo GoodColors.py @@ -0,0 +1,50 @@ +import PySimpleGUI as gg +import time + +def main(): + # ------- Make a new FlexForm ------- # + form = gg.FlexForm('GoodColors', auto_size_text=True, default_element_size=(30,2)) + form.AddRow(gg.Text('Having trouble picking good colors? Try one of the colors defined by PySimpleGUI')) + form.AddRow(gg.Text('Here come the good colors as defined by PySimpleGUI')) + + #===== Show some nice BLUE colors with yellow text ===== ===== ===== ===== ===== ===== =====# + text_color = gg.YELLOWS[0] + buttons = (gg.SimpleButton(f'BLUES[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.BLUES)) + form.AddRow(gg.T('Button Colors Using PySimpleGUI.BLUES')) + form.AddRow(*buttons) + form.AddRow(gg.Text('_' * 100, size=(65, 1))) + + #===== Show some nice PURPLE colors with yellow text ===== ===== ===== ===== ===== ===== =====# + buttons = (gg.SimpleButton(f'PURPLES[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.PURPLES)) + form.AddRow(gg.T('Button Colors Using PySimpleGUI.PURPLES')) + form.AddRow(*buttons) + form.AddRow(gg.Text('_' * 100, size=(65, 1))) + + #===== Show some nice GREEN colors with yellow text ===== ===== ===== ===== ===== ===== =====# + buttons = (gg.SimpleButton(f'GREENS[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.GREENS)) + form.AddRow(gg.T('Button Colors Using PySimpleGUI.GREENS')) + form.AddRow(*buttons) + form.AddRow(gg.Text('_' * 100, size=(65, 1))) + + #===== Show some nice TAN colors with yellow text ===== ===== ===== ===== ===== ===== =====# + text_color = gg.GREENS[0] # let's use GREEN text on the tan + buttons = (gg.SimpleButton(f'TANS[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.TANS)) + form.AddRow(gg.T('Button Colors Using PySimpleGUI.TANS')) + form.AddRow(*buttons) + form.AddRow(gg.Text('_' * 100, size=(65, 1))) + + #===== Show some nice YELLOWS colors with black text ===== ===== ===== ===== ===== ===== =====# + text_color = 'black' # let's use black text on the tan + buttons = (gg.SimpleButton(f'YELLOWS[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.YELLOWS)) + form.AddRow(gg.T('Button Colors Using PySimpleGUI.YELLOWS')) + form.AddRow(*buttons) + form.AddRow(gg.Text('_' * 100, size=(65, 1))) + + + #===== Add a click me button for fun and SHOW the form ===== ===== ===== ===== ===== ===== =====# + form.AddRow(gg.SimpleButton('Click ME!')) + (button, value) = form.Show() # show it! + + +if __name__ == '__main__': + main() From fb2fe90d373e13cac061b46e47ea2465a23016c2 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 18 Jul 2018 21:32:28 -0400 Subject: [PATCH 046/209] Command line change Changed how the script is launched. No longer using hard coded paths. Also uses the pip installed version. --- Demo HowDoI.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Demo HowDoI.py b/Demo HowDoI.py index 3565b1a67..26858ed3f 100644 --- a/Demo HowDoI.py +++ b/Demo HowDoI.py @@ -1,8 +1,10 @@ import PySimpleGUI 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' -# CHANGE THIS LINE OF CODE! Point it to the howdoi.py file that is in the howdoi code you download from github -HOW_DO_I_COMMAND = 'python C:\\Python\\PycharmProjects\\GitHub\\howdoi\\howdoi\\howdoi.py' # 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' @@ -18,7 +20,7 @@ def HowDoI(): form = SG.FlexForm('How Do I ??', auto_size_text=True, default_element_size=(30, 2), icon=DEFAULT_ICON) form.AddRow(SG.Text('Ask and your answer will appear here....', size=(40, 1))) form.AddRow(SG.Output(size=(90, 20))) - form.AddRow(SG.Multiline(size=(90, 5), enter_submits=True), + form.AddRow(SG.Multiline(size=(85, 5), enter_submits=True), SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))) From f331661a3a38bf82a7cb46e513839e98a86b9382 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 20 Jul 2018 20:07:04 -0400 Subject: [PATCH 047/209] LOTS of changes and new additions Text justification for Text Elems NEW Image Element OutputFlush renamed to Refresh More shorthand functions - Combo, Dropdown, Drop, EasyPrint - output of stdout, stderr to a window --- Demo Recipes.py | 99 +++++++++--------- PySimpleGUI.py | 261 ++++++++++++++++++++++++++++++++++-------------- readme.md | 135 ++++++++++++++++++++----- 3 files changed, 350 insertions(+), 145 deletions(-) diff --git a/Demo Recipes.py b/Demo Recipes.py index b5877fcbd..f9e957e7d 100644 --- a/Demo Recipes.py +++ b/Demo Recipes.py @@ -1,19 +1,21 @@ import time +from random import randint +import random +import string import PySimpleGUI as SG def SourceDestFolders(): with SG.FlexForm('Demo Source / Destination Folders', auto_size_text=True) as form: form_rows = [[SG.Text('Enter the Source and Destination folders')], - [SG.Text('Choose Source and Destination Folders')], - [SG.Text('Source Folder', size=(15, 1), auto_size_text=False), SG.InputText('Source'), SG.FolderBrowse()], - [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False), SG.InputText('Dest'), SG.FolderBrowse()], + [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source')], + [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), SG.FolderBrowse()], [SG.Submit(), SG.Cancel()]] - (button, (source, dest)) = form.LayoutAndShow(form_rows) + button, (source, dest) = form.LayoutAndShow(form_rows) if button == 'Submit': # do something useful with the inputs - SG.MsgBox('Submitted', 'The user entered source:', source, 'Destination folder:', dest) + SG.MsgBox('Submitted', 'The user entered source:', source, 'Destination folder:', dest, 'Using button', button) else: SG.MsgBoxError('Cancelled', 'User Cancelled') @@ -33,9 +35,9 @@ def Everything_NoContextManager(): [SG.SimpleButton('Your very own button', button_color=('white', 'green'))], [SG.Submit(), SG.Cancel()]] - (button, (values)) = form.LayoutAndShow(layout) + button, (values) = form.LayoutAndShow(layout) - SG.MsgBox('Title', 'Typical message box', 'The results of the form are a lot of data! Get ready... ', 'The button clicked was "{}"'.format(button), 'The values are', values) + SG.MsgBox('Title', 'Typical message box', 'Here are the restults! There is one entry per input field ', 'The button clicked was "{}"'.format(button), 'The values are', values) def Everything(): @@ -45,16 +47,18 @@ def Everything(): [SG.InputText()], [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], [SG.Radio('My first Radio!', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], + [SG.Spin(values=(1,2,3), initial_value=1, size=(2,1)), SG.T('Spinner 1', size=(20,1)), + SG.Spin(values=(1,2,3), initial_value=1, size=(2,1)),SG.T('Spinner 2')], [SG.Multiline(default_text='This is the default Text should you decide not to type anything', scale=(2, 10))], [SG.InputCombo(['choice 1', 'choice 2'], size=(20, 3))], [SG.Text('_' * 100, size=(70, 1))], [SG.Text('Choose Source and Destination Folders', size=(35, 1))], [SG.Text('Source Folder', size=(15, 1), auto_size_text=False), SG.InputText('Source'), SG.FolderBrowse()], [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False), SG.InputText('Dest'), SG.FolderBrowse()], - [SG.SimpleButton('Your very own button', button_color=('white', 'green'))], + [SG.SimpleButton('Custom Button', button_color=('white', 'green'))], [SG.Submit(), SG.Cancel()]] - (button, (values)) = form.LayoutAndShow(layout) + button, (values) = form.LayoutAndShow(layout) SG.MsgBox('Title', 'Typical message box', 'The results of the form are a lot of data! Get ready... ', 'The button clicked was "{}"'.format(button), 'The values are', values) @@ -62,6 +66,26 @@ def ProgressMeter(): for i in range(1,10000): if not SG.EasyProgressMeter('My Meter', i+1, 10000): break +def RunningTimer(): + with SG.FlexForm('Running Timer', auto_size_text=True) as form: + output_element = SG.Text('', size=(8, 2), font=('Helvetica', 20)) + form_rows = [[SG.Text('Non-blocking GUI with updates')], + [output_element], + [SG.SimpleButton('Quit')]] + + form.AddRows(form_rows) + form.Show(non_blocking=True) + for i in range(1, 100): + output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i/100), 60), i%100)) + rc = form.Refresh() + if rc is None or rc[0] == 'Quit': + break + time.sleep(.01) + else: + form.CloseNonBlockingForm() + + + # Persistant form. Does not close when Send button is clicked. # Normally all Simple Buttons cause forms to close @@ -70,7 +94,7 @@ def ChatBot(): form.AddRow(SG.Text('This is where standard out is being routed', size=[40, 1])) form.AddRow(SG.Output(size=(80, 20))) form.AddRow(SG.Multiline(size=(70, 5), enter_submits=True), SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))) - (button, value) = form.Read() + button, value = form.Read() # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # while True: @@ -78,22 +102,22 @@ def ChatBot(): print(value) else: break - (button, value) = form.Read() + button, value = form.Read() def NonBlockingPeriodicUpdateForm_ContextManager(): # Show a form that's a running counter with SG.FlexForm('Running Timer', auto_size_text=True) as form: - output_element = SG.Text('',size=(8,2), font=('Helvetica', 20), text_color='red') - form_rows = [[SG.Text('None blocking GUI with updates')], + output_element = SG.Text('',size=(10,2), font=('Helvetica', 20), text_color='red', justification='center') + form_rows = [[SG.Text('Non blocking GUI with updates', justification='center')], [output_element], - [SG.Quit()]] + [SG.T(' '*15), SG.Quit()]] form.AddRows(form_rows) form.Show(non_blocking=True) for i in range(1,500): output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i/100), 60), i%100)) - rc = form.OutputFlush() + rc = form.Refresh() if rc is None: # if user closed the window using X break button, values = rc @@ -117,11 +141,8 @@ def NonBlockingPeriodicUpdateForm(): for i in range(1,50000): output_element.Update(f'{(i/100)/60:02d}:{(i/100)%60:02d}.{i%100:02d}') - rc = form.OutputFlush() - if rc is None: # if user closed the window using X - break - button, values = rc - if button == 'Quit': + rc = form.Refresh() + if rc is None or rc[0] == 'Quit': # if user closed the window using X or clicked Quit button break time.sleep(.01) else: @@ -129,40 +150,24 @@ def NonBlockingPeriodicUpdateForm(): form.CloseNonBlockingForm() -def NonBlockingScrolledPrintForm(): - # Show a form that's a running counter - form = SG.FlexForm('Scrolled Print', auto_size_text=True, font=('Courier New', 12)) - output_element = SG.Output(size=(42,10)) - form_rows = [[SG.Text('Scrolled print output')], - [output_element], - [SG.Quit()]] - form.AddRows(form_rows) - form.Show(non_blocking=True) # Show a ;non-blocking form, returns immediately - - for i in range(1,50000): - print(f'{i} ', end="") # all print output will go to the scrolled text box - # must call OutputFlush on a periodic basis to keep GUI alive - rc = form.OutputFlush() - if rc is None: # if user closed the window using X - break - button, values = rc - if button == 'Quit': # if user cliced Quit button - break - else: # if the loop finished then need to close the form for the user - form.CloseNonBlockingForm() +def DebugTest(): + # SG.Print('How about we print a bunch of random numbers?', , size=(90,40)) + for i in range (1,300): + SG.Print(i, randint(1, 1000), end='', sep='-') + # SG.PrintClose() def main(): - SG.SetOptions(border_width=4, element_padding=(4,6), font=("Helvetica", 10), button_color=('white', SG.BLUES[0]), - progress_meter_border_depth=4) + SG.SetOptions(border_width=1, element_padding=(4,6), font=("Helvetica", 10), button_color=('white', SG.BLUES[0]), + progress_meter_border_depth=0) SourceDestFolders() + Everything() + NonBlockingPeriodicUpdateForm_ContextManager() ProgressMeter() ChatBot() - NonBlockingScrolledPrintForm() - NonBlockingPeriodicUpdateForm_ContextManager() - Everything_NoContextManager() - Everything() + DebugTest() if __name__ == '__main__': main() + exit(69) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 99252d115..bcc082fbd 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -16,9 +16,10 @@ DEFAULT_ELEMENT_PADDING = (5,3) # Padding between elements (row, col) in pixels DEFAULT_AUTOSIZE_TEXT = False DEFAULT_FONT = ("Helvetica", 10) - +DEFAULT_TEXT_JUSTIFICATION = 'left' DEFAULT_BORDER_WIDTH = 4 DEFAULT_AUTOCLOSE_TIME = 3 # time in seconds to show an autoclose form +DEFAULT_DEBUG_WINDOW_SIZE = (80,20) MAX_SCROLLED_TEXT_BOX_HEIGHT = 50 #################### COLOR STUFF #################### BLUES = ("#082567","#0A37A3","#00345B") @@ -89,17 +90,18 @@ def RGB(red,green,blue): return '#%02x%02x%02x' % (red,green,blue) # ------------------------- Element types ------------------------- # # class ElementType(Enum): -TEXT = 1 -INPUT_TEXT = 20 -INPUT_COMBO = 21 -INPUT_RADIO = 5 -INPUT_MULTILINE = 7 -INPUT_CHECKBOX = 8 -INPUT_SPIN = 9 -BUTTON = 3 -OUTPUT = 300 -PROGRESS_BAR = 200 -BLANK = 100 +ELEM_TYPE_TEXT = 1 +ELEM_TYPE_INPUT_TEXT = 20 +ELEM_TYPE_INPUT_COMBO = 21 +ELEM_TYPE_INPUT_RADIO = 5 +ELEM_TYPE_INPUT_MULTILINE = 7 +ELEM_TYPE_INPUT_CHECKBOX = 8 +ELEM_TYPE_INPUT_SPIN = 9 +ELEM_TYPE_BUTTON = 3 +ELEM_TYPE_IMAGE = 30 +ELEM_TYPE_OUTPUT = 300 +ELEM_TYPE_PROGRESS_BAR = 200 +ELEM_TYPE_BLANK = 100 # ------------------------- MsgBox Buttons Types ------------------------- # MSG_BOX_YES_NO = 1 @@ -131,6 +133,7 @@ def __init__(self, type, scale=(None, None), size=(None, None), auto_size_text=N self.TKIntVar = None self.TKText = None self.TKEntry = None + self.TKImage = None self.ParentForm=None self.TextInputDefault = None @@ -163,7 +166,7 @@ class InputText(Element): def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char=''): self.DefaultText = default_text self.PasswordCharacter = password_char - super().__init__(INPUT_TEXT, scale, size, auto_size_text) + super().__init__(ELEM_TYPE_INPUT_TEXT, scale, size, auto_size_text) return def ReturnKeyHandler(self, event): @@ -171,7 +174,7 @@ def ReturnKeyHandler(self, event): # search through this form and find the first button that will exit the form for row in MyForm.Rows: for element in row.Elements: - if element.Type == BUTTON: + if element.Type == ELEM_TYPE_BUTTON: if element.BType == CLOSES_WIN or element.BType == READ_FORM: element.ButtonCallBack() return @@ -187,7 +190,7 @@ class InputCombo(Element): def __init__(self, values, scale=(None, None), size=(None, None), auto_size_text=None): self.Values = values self.TKComboBox = None - super().__init__(INPUT_COMBO, scale, size, auto_size_text) + super().__init__(ELEM_TYPE_INPUT_COMBO, scale, size, auto_size_text) return def __del__(self): @@ -207,7 +210,7 @@ def __init__(self, text, group_id, default=False, scale=(None, None), size=(None self.TKRadio = None self.GroupID = group_id self.Value = None - super().__init__(INPUT_RADIO, scale, size, auto_size_text, font) + super().__init__(ELEM_TYPE_INPUT_RADIO, scale, size, auto_size_text, font) return def __del__(self): @@ -227,7 +230,7 @@ def __init__(self, text, default=False, scale=(None, None), size=(None, None), a self.Value = None self.TKCheckbox = None - super().__init__(INPUT_CHECKBOX, scale, size, auto_size_text, font) + super().__init__(ELEM_TYPE_INPUT_CHECKBOX, scale, size, auto_size_text, font) return def __del__(self): @@ -248,7 +251,7 @@ def __init__(self, values, initial_value=None, scale=(None, None), size=(None, N self.Values = values self.DefaultValue = initial_value self.TKSpinBox = None - super().__init__(INPUT_SPIN, scale, size, auto_size_text, font=font) + super().__init__(ELEM_TYPE_INPUT_SPIN, scale, size, auto_size_text, font=font) return def __del__(self): @@ -265,7 +268,7 @@ class Multiline(Element): def __init__(self, default_text='', enter_submits = False, scale=(None, None), size=(None, None), auto_size_text=None): self.DefaultText = default_text self.EnterSubmits = enter_submits - super().__init__(INPUT_MULTILINE, scale, size, auto_size_text) + super().__init__(ELEM_TYPE_INPUT_MULTILINE, scale, size, auto_size_text) return def ReturnKeyHandler(self, event): @@ -273,7 +276,7 @@ def ReturnKeyHandler(self, event): # search through this form and find the first button that will exit the form for row in MyForm.Rows: for element in row.Elements: - if element.Type == BUTTON: + if element.Type == ELEM_TYPE_BUTTON: if element.BType == CLOSES_WIN or element.BType == READ_FORM: element.ButtonCallBack() return @@ -285,12 +288,13 @@ def __del__(self): # Text # # ---------------------------------------------------------------------- # class Text(Element): - def __init__(self, text, scale=(None, None), size=(None, None), auto_size_text=None, font=None, text_color=None): + def __init__(self, text, scale=(None, None), size=(None, None), auto_size_text=None, font=None, text_color=None, justification=None): self.DisplayText = text self.TextColor = text_color if text_color else 'black' + self.Justification = justification if justification else DEFAULT_TEXT_JUSTIFICATION # self.Font = Font if Font else DEFAULT_FONT # i=1/0 - super().__init__(TEXT, scale, size, auto_size_text, font=font if font else DEFAULT_FONT) + super().__init__(ELEM_TYPE_TEXT, scale, size, auto_size_text, font=font if font else DEFAULT_FONT) return def Update(self, NewValue): @@ -394,11 +398,12 @@ def flush(self): def __del__(self): sys.stdout = self.previous_stdout + sys.stderr = self.previous_stderr class Output(Element): def __init__(self, scale=(None, None), size=(None, None)): self.TKOut = None - super().__init__(OUTPUT, scale, size) + super().__init__(ELEM_TYPE_OUTPUT, scale, size) def __del__(self): try: @@ -419,7 +424,7 @@ def __init__(self, button_type=CLOSES_WIN, target=(None, None), button_text='', self.ButtonText = button_text self.ButtonColor = button_color if button_color else DEFAULT_BUTTON_COLOR self.UserData = None - super().__init__(BUTTON, scale, size, auto_size_text, font=font) + super().__init__(ELEM_TYPE_BUTTON, scale, size, auto_size_text, font=font) return # ------- Button Callback ------- # @@ -478,7 +483,7 @@ def ReturnKeyHandler(self, event): # search through this form and find the first button that will exit the form for row in MyForm.Rows: for element in row.Elements: - if element.Type == BUTTON: + if element.Type == ELEM_TYPE_BUTTON: if element.BType == CLOSES_WIN or element.BType == READ_FORM: element.ButtonCallBack() return @@ -506,7 +511,7 @@ def __init__(self, max_value, orientation=None, target=(None, None), scale=(None self.BorderWidth = border_width if border_width else DEFAULT_PROGRESS_BAR_BORDER_WIDTH self.Relief = relief if relief else DEFAULT_PROGRESS_BAR_RELIEF self.BarExpired = False - super().__init__(PROGRESS_BAR, scale, size, auto_size_text) + super().__init__(ELEM_TYPE_PROGRESS_BAR, scale, size, auto_size_text) return def UpdateBar(self, current_count): @@ -524,7 +529,7 @@ def UpdateBar(self, current_count): try: self.ParentForm.TKroot.update() except: - _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 + # _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 return False return True @@ -535,6 +540,20 @@ def __del__(self): pass super().__del__() +# ---------------------------------------------------------------------- # +# Image # +# ---------------------------------------------------------------------- # +class Image(Element): + def __init__(self, filename, scale=(None, None), size=(None, None), auto_size_text=None): + self.Filename = filename + super().__init__(ELEM_TYPE_IMAGE, scale=scale, size=size, auto_size_text=auto_size_text) + return + + def __del__(self): + super().__del__() + + + # ------------------------------------------------------------------------- # # Row CLASS # # ------------------------------------------------------------------------- # @@ -589,6 +608,7 @@ def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT self.RootNeedsDestroying = False self.Shown = False self.ReturnValues = None + self.ResultsBuilt = False # ------------------------- Add ONE Row to Form ------------------------- # def AddRow(self, *args, auto_size_text=None): @@ -663,31 +683,37 @@ def Read(self): self.TKroot.mainloop() if self.RootNeedsDestroying: self.TKroot.destroy() + _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 return(BuildResults(self)) - def OutputFlush(self, Message=''): - if self.TKrootDestroyed: return None + def Refresh(self, Message=''): + if self.TKrootDestroyed: + return None if Message: print(Message) try: self.TKroot.update() except: self.TKrootDestroyed = True + _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 return(BuildResults(self)) def Close(self): try: self.TKroot.update() except: pass - results = BuildResults(self) + if not self.NonBlocking: + results = BuildResults(self) if self.TKrootDestroyed: - return results + return None self.TKrootDestroyed = True self.RootNeedsDestroying = True - return results + return None def CloseNonBlockingForm(self): - self.TKroot.destroy() + try: + self.TKroot.destroy() + except: pass _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 def OnClosingCallback(self): @@ -735,6 +761,7 @@ def Close(self): if not self.TKrootDestroyed: self.TKrootDestroyed = True self.TKroot.destroy() + _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 def __del__(self): return @@ -750,12 +777,21 @@ def In(default_text ='', scale=(None, None), size=(None, None), auto_size_text=N def Input(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None): return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text) +# ------------------------- INPUT COMBO Element lazy functions ------------------------- # +def Combo(values, scale=(None, None), size=(None, None), auto_size_text=None): + return InputCombo(values=values, scale=scale, size=size, auto_size_text=auto_size_text) + +def DropDown(values, scale=(None, None), size=(None, None), auto_size_text=None): + return InputCombo(values=values, scale=scale, size=size, auto_size_text=auto_size_text) + +def Drop(values, scale=(None, None), size=(None, None), auto_size_text=None): + return InputCombo(values=values, scale=scale, size=size, auto_size_text=auto_size_text) # ------------------------- TEXT Element lazy functions ------------------------- # -def Txt(display_text, scale=(None, None), size=(None, None), auto_size_text=None, font=None, text_color=None): - return Text(display_text, scale=scale, size=size, auto_size_text=auto_size_text, font=font, text_color=text_color) +def Txt(display_text, scale=(None, None), size=(None, None), auto_size_text=None, font=None, text_color=None, justification=None): + return Text(display_text, scale=scale, size=size, auto_size_text=auto_size_text, font=font, text_color=text_color, justification=justification) -def T(display_text, scale=(None, None), size=(None, None), auto_size_text=None, font=None, text_color=None): - return Text(display_text, scale=scale, size=size, auto_size_text=auto_size_text, font=font, text_color=text_color) +def T(display_text, scale=(None, None), size=(None, None), auto_size_text=None, font=None, text_color=None, justification=None): + return Text(display_text, scale=scale, size=size, auto_size_text=auto_size_text, font=font, text_color=text_color, justification=justification) # ------------------------- FOLDER BROWSE Element lazy function ------------------------- # def FolderBrowse(target=(ThisRow, -1), button_text='Browse', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None): @@ -815,28 +851,30 @@ def InitializeResults(form): for row_num,row in enumerate(form.Rows): r = [] for element in row.Elements: - if element.Type == TEXT: + if element.Type == ELEM_TYPE_TEXT: r.append(None) - elif element.Type == INPUT_TEXT: + if element.Type == ELEM_TYPE_IMAGE: + r.append(None) + elif element.Type == ELEM_TYPE_INPUT_TEXT: r.append(element.TextInputDefault) return_vals.append(None) - elif element.Type == INPUT_MULTILINE: + elif element.Type == ELEM_TYPE_INPUT_MULTILINE: r.append(element.TextInputDefault) return_vals.append(None) - elif element.Type == BUTTON: + elif element.Type == ELEM_TYPE_BUTTON: r.append(False) - elif element.Type == PROGRESS_BAR: + elif element.Type == ELEM_TYPE_PROGRESS_BAR: r.append(None) - elif element.Type == INPUT_CHECKBOX: + elif element.Type == ELEM_TYPE_INPUT_CHECKBOX: r.append(element.InitialState) return_vals.append(element.InitialState) - elif element.Type == INPUT_RADIO: + elif element.Type == ELEM_TYPE_INPUT_RADIO: r.append(element.InitialState) return_vals.append(element.InitialState) - elif element.Type == INPUT_COMBO: + elif element.Type == ELEM_TYPE_INPUT_COMBO: r.append(element.TextInputDefault) return_vals.append(None) - elif element.Type == INPUT_SPIN: + elif element.Type == ELEM_TYPE_INPUT_SPIN: r.append(element.TextInputDefault) return_vals.append(None) results.append(r) @@ -870,39 +908,40 @@ def BuildResults(form): input_values = [] for row_num,row in enumerate(form.Rows): for col_num, element in enumerate(row.Elements): - if element.Type == INPUT_TEXT: + if element.Type == ELEM_TYPE_INPUT_TEXT: value=element.TKStringVar.get() results[row_num][col_num] = value input_values.append(value) - elif element.Type == INPUT_CHECKBOX: + elif element.Type == ELEM_TYPE_INPUT_CHECKBOX: value=element.TKIntVar.get() results[row_num][col_num] = value input_values.append(value != 0) - elif element.Type == INPUT_RADIO: + elif element.Type == ELEM_TYPE_INPUT_RADIO: RadVar=element.TKIntVar.get() this_rowcol = EncodeRadioRowCol(row_num,col_num) value = RadVar == this_rowcol results[row_num][col_num] = value input_values.append(value) - elif element.Type == BUTTON: + elif element.Type == ELEM_TYPE_BUTTON: if results[row_num][col_num] is True: button_pressed_text = element.ButtonText results[row_num][col_num] = False - elif element.Type == INPUT_COMBO: + elif element.Type == ELEM_TYPE_INPUT_COMBO: value=element.TKStringVar.get() results[row_num][col_num] = value input_values.append(value) - elif element.Type == INPUT_SPIN: + elif element.Type == ELEM_TYPE_INPUT_SPIN: try: value=element.TKStringVar.get() except: value = 0 results[row_num][col_num] = value input_values.append(value) - elif element.Type == INPUT_MULTILINE: + elif element.Type == ELEM_TYPE_INPUT_MULTILINE: try: value=element.TKText.get(1.0, tk.END) - element.TKText.delete('1.0', tk.END) + if not form.NonBlocking: + element.TKText.delete('1.0', tk.END) except: value = None results[row_num][col_num] = value @@ -964,7 +1003,7 @@ def ConvertFlexToTK(MyFlexForm): element_size = (int(element_size[0] * MyFlexForm.Scale[0]), int(element_size[1] * MyFlexForm.Scale[1])) # ------------------------- TEXT element ------------------------- # element_type = element.Type - if element_type == TEXT: + if element_type == ELEM_TYPE_TEXT: display_text = element.DisplayText # text to display if auto_size_text is False: width, height=element_size @@ -983,14 +1022,16 @@ def ConvertFlexToTK(MyFlexForm): stringvar.set(display_text) if auto_size_text: width = 0 - tktext_label = tk.Label(tk_row_frame,anchor=tk.NW, textvariable=stringvar, width=width, height=height, justify=tk.LEFT, bd=border_depth, fg=element.TextColor) + justify = tk.LEFT if element.Justification == 'left' else tk.CENTER if element.Justification == 'center' else tk.RIGHT + anchor = tk.NW if element.Justification == 'left' else tk.N if element.Justification == 'center' else tk.NE + tktext_label = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height, justify=justify, bd=border_depth, fg=element.TextColor) # tktext_label = tk.Label(tk_row_frame,anchor=tk.NW, text=display_text, width=width, height=height, justify=tk.LEFT, bd=border_depth) # Set wrap-length for text (in PIXELS) == PAIN IN THE ASS wraplen = tktext_label.winfo_reqwidth() # width of widget in Pixels - tktext_label.configure(anchor=tk.NW, font=font, wraplen=wraplen*2 ) # set wrap to width of widget + tktext_label.configure(anchor=anchor, font=font, wraplen=wraplen*2 ) # set wrap to width of widget tktext_label.pack(side=tk.LEFT) # ------------------------- BUTTON element ------------------------- # - elif element_type == BUTTON: + elif element_type == ELEM_TYPE_BUTTON: element.Location = (row_num, col_num) btext = element.ButtonText btype = element.BType @@ -1019,7 +1060,7 @@ def ConvertFlexToTK(MyFlexForm): element.TKButton.focus_set() MyFlexForm.TKroot.focus_force() # ------------------------- INPUT (Single Line) element ------------------------- # - elif element_type == INPUT_TEXT: + elif element_type == ELEM_TYPE_INPUT_TEXT: default_text = element.DefaultText element.TKStringVar = tk.StringVar() element.TKStringVar.set(default_text) @@ -1031,7 +1072,7 @@ def ConvertFlexToTK(MyFlexForm): focus_set = True element.TKEntry.focus_set() # ------------------------- COMBO BOX (Drop Down) element ------------------------- # - elif element_type == INPUT_COMBO: + elif element_type == ELEM_TYPE_INPUT_COMBO: max_line_len = max([len(str(l)) for l in element.Values]) if auto_size_text is False: width=element_size[0] else: width = max_line_len @@ -1041,7 +1082,7 @@ def ConvertFlexToTK(MyFlexForm): element.TKCombo.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) element.TKCombo.current(0) # ------------------------- INPUT MULTI LINE element ------------------------- # - elif element_type == INPUT_MULTILINE: + elif element_type == ELEM_TYPE_INPUT_MULTILINE: default_text = element.DefaultText width, height = element_size element.TKText = tk.scrolledtext.ScrolledText(tk_row_frame, width=width, height=height, wrap='word', bd=border_depth,font=font) @@ -1053,7 +1094,7 @@ def ConvertFlexToTK(MyFlexForm): focus_set = True element.TKText.focus_set() # ------------------------- INPUT CHECKBOX element ------------------------- # - elif element_type == INPUT_CHECKBOX: + elif element_type == ELEM_TYPE_INPUT_CHECKBOX: width = 0 if auto_size_text else element_size[0] default_value = element.InitialState element.TKIntVar = tk.IntVar() @@ -1061,7 +1102,7 @@ def ConvertFlexToTK(MyFlexForm): element.TKCheckbutton = tk.Checkbutton(tk_row_frame, anchor=tk.NW, text=element.Text, width=width, variable=element.TKIntVar, bd=border_depth, font=font) element.TKCheckbutton.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) # ------------------------- PROGRESS BAR element ------------------------- # - elif element_type == PROGRESS_BAR: + elif element_type == ELEM_TYPE_PROGRESS_BAR: # save this form because it must be 'updated' (refreshed) solely for the purpose of updating bar width = element_size[0] fnt = tkinter.font.Font() @@ -1079,7 +1120,7 @@ def ConvertFlexToTK(MyFlexForm): s = ttk.Style() element.TKProgressBar.TKCanvas.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) # ------------------------- INPUT RADIO BUTTON element ------------------------- # - elif element_type == INPUT_RADIO: + elif element_type == ELEM_TYPE_INPUT_RADIO: width = 0 if auto_size_text else element_size[0] default_value = element.InitialState ID = element.GroupID @@ -1097,7 +1138,7 @@ def ConvertFlexToTK(MyFlexForm): variable=element.TKIntVar, value=value, bd=border_depth, font=font) element.TKRadio.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) # ------------------------- INPUT SPIN Box element ------------------------- # - elif element_type == INPUT_SPIN: + elif element_type == ELEM_TYPE_INPUT_SPIN: width, height = element_size width = 0 if auto_size_text else element_size[0] element.TKStringVar = tk.StringVar() @@ -1106,9 +1147,21 @@ def ConvertFlexToTK(MyFlexForm): element.TKSpinBox.configure(font=font) # set wrap to width of widget element.TKSpinBox.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) # ------------------------- OUTPUT element ------------------------- # - elif element_type == OUTPUT: + elif element_type == ELEM_TYPE_OUTPUT: width, height = element_size element.TKOut = TKOutput(tk_row_frame, width=width, height=height, bd=border_depth) + element.TKOut.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) + # ------------------------- IMAGE Box element ------------------------- # + elif element_type == ELEM_TYPE_IMAGE: + photo = tk.PhotoImage(file=element.Filename) + if element_size == (None, None) or element_size == None or element_size == MyFlexForm.DefaultElementSize: + width, height = photo.width(), photo.height() + else: + width, height = element_size + tktext_label = tk.Label(tk_row_frame, image=photo, width=width, height=height, bd=border_depth) + tktext_label.image = photo + # tktext_label.configure(anchor=tk.NW, image=photo) + tktext_label.pack(side=tk.LEFT) #............................DONE WITH ROW pack the row of widgets ..........................# # done with row, pack the row of widgets tk_row_frame.grid(row=row_num+2, sticky=tk.W, padx=DEFAULT_MARGINS[0]) @@ -1619,9 +1672,66 @@ def GetComplimentaryHex(color): comp_color = 0xFFFFFF ^ color # convert the color back to hex by prefixing a # comp_color = "#%06X" % comp_color - # return the result return comp_color + + +# ======================== EasyPrint =====# +# ===================================================# +_easy_print_data = None # global variable... I'm cheating + +class DebugWin(): + def __init__(self, size=(None, None)): + # Show a form that's a running counter + win_size = size if size !=(None, None) else DEFAULT_DEBUG_WINDOW_SIZE + self.form = FlexForm('Debug Window', auto_size_text=True, font=('Courier New', 12)) + self.output_element = Output(size=win_size) + self.form_rows = [[Text('EasyPrint Output')], + [self.output_element], + [Quit()]] + self.form.AddRows(self.form_rows) + self.form.Show(non_blocking=True) # Show a ;non-blocking form, returns immediately + return + + def Print(self, *args, end=None, sep=None): + sepchar = sep if sep is not None else ' ' + endchar = end if end is not None else '\n' + print(*args, sep=sepchar, end=endchar) + # for a in args: + # msg = str(a) + # print(msg, end="", sep=sepchar) + # print(1, 2, 3, sep='-') + # if end is None: + # print("") + self.form.Refresh() + + def Close(self): + self.form.CloseNonBlockingForm() + self.form.__del__() + +def Print(*args, size=(None,None), end=None, sep=None): + EasyPrint(*args, size=size, end=end, sep=sep) + +def PrintClose(): + EasyPrintClose() + +def eprint(*args, size=(None,None), end=None, sep=None): + EasyPrint(*args, size=size, end=end, sep=sep) + +def EasyPrint(*args, size=(None,None), end=None, sep=None): + if 'easy_print_data' not in EasyPrint.__dict__: # use a function property to save DebugWin object (static variable) + EasyPrint.easy_print_data = DebugWin(size=size) + if EasyPrint.easy_print_data is None: + EasyPrint.easy_print_data = DebugWin(size=size) + EasyPrint.easy_print_data.Print(*args, end=end, sep=sep) + +def EasyPrintClose(): + if 'easy_print_data' in EasyPrint.__dict__: + if EasyPrint.easy_print_data is not None: + EasyPrint.easy_print_data.Close() + EasyPrint.easy_print_data = None + # del EasyPrint.easy_print_data + # ======================== Scrolled Text Box =====# # ===================================================# def ScrolledTextBox(*args, button_color=None, yes_no=False, auto_close=False, auto_close_duration=None, height=None): @@ -1733,7 +1843,7 @@ def SetGlobalIcon(icon): # ===================================================# def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), margins=(None,None), element_padding=(None,None), auto_size_text=None, font=None, border_width=None, autoclose_time=None, message_box_line_width=None, - progress_meter_border_depth=None): + progress_meter_border_depth=None, text_justification=None, debug_win_size=(None,None)): global DEFAULT_ELEMENT_SIZE global DEFAULT_MARGINS # Margins for each LEFT/RIGHT margin is first term global DEFAULT_ELEMENT_PADDING # Padding between elements (row, col) in pixels @@ -1744,6 +1854,8 @@ def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), ma global DEFAULT_BUTTON_COLOR global MESSAGE_BOX_LINE_WIDTH global DEFAULT_PROGRESS_BAR_BORDER_WIDTH + global DEFAULT_TEXT_JUSTIFICATION + global DEFAULT_DEBUG_WINDOW_SIZE global _my_windows if icon: @@ -1784,16 +1896,15 @@ def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), ma if progress_meter_border_depth != None: DEFAULT_PROGRESS_BAR_BORDER_WIDTH = progress_meter_border_depth - return True + if text_justification != None: + DEFAULT_TEXT_JUSTIFICATION = text_justification + if debug_win_size != (None,None): + DEFAULT_DEBUG_WINDOW_SIZE = debug_win_size + + return True -# ============================== SetButtonColor =====# -# Sets the defaul button color # -# ===================================================# -def SetButtonColor(foreground, background): - global DEFAULT_BUTTON_COLOR - DEFAULT_BUTTON_COLOR = (foreground, background) # ============================== sprint ======# diff --git a/readme.md b/readme.md index d389d8f86..d277d6db5 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ - +[![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) # PySimpleGUI This really is a simple GUI, but also powerfully customizable. @@ -9,23 +9,23 @@ This really is a simple GUI, but also powerfully customizable. ![snap0102](https://user-images.githubusercontent.com/13696193/42781058-1d28d9fa-8913-11e8-847e-5c2afc16ca4c.jpg) -I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? - -There are a number of 'easy to use' Python GUIs, but they're quite limiting. PySimpleGUI tried to take the best of packages like `EasyGUI`(no longer maintained) and `WxSimpleGUI` (a great package, but was too limited for my application). `PySimpleGUI` provides similar single-call-message-box solutions as you'll see. - -GUI Packages with more functionality, like QT and WxPython, require configuring and can take a ***week*** to get *reasonably familiar* with the interfaces. +Add a Progress Meter to your code with ONE LINE of code -With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. + EasyProgressMeter('My meter title', current_value, max value) -The `PySimpleGUI` solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? +![progress meter 2](https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg) -You can add a GUI to your command line with a single line of code. With 3 or 4 lines of code you can add a fully customized GUI. And for you Machine Learning folks out there, a **single line** progress meter call that you can drop into any loop to get a graphic like this one: +I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? +There are a number of 'easy to use' Python GUIs, but they're **very** limiting. PySimpleGUI takes the best of packages like `EasyGUI`(no longer maintained) and `WxSimpleGUI` (a great package, but limited). The difference between these and PySimpleGUI is that in addition to getting those simple Message Boxes you also get the ability to make your own forms that are highly customizeable. -![progress meter 2](https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg) +Every call has optional parameters so that you can change the look and feel. Don't like the button color? It's easy to change by adding a button_color parameter to your widget. +GUI Packages with more functionality, like QT and WxPython, require configuring and can take a ***week*** to get *reasonably familiar* with the interfaces. +With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. +The `PySimpleGUI` solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? Features of PySimpleGUI include: Text @@ -241,6 +241,12 @@ With a little trickery you can provide a way to break out of your loop using the This is the FUN part of the programming of this GUI. In order to really get the most out of the API, you should be using an IDE that supports auto complete or will show you the definition of the function. This will make customizing go smoother. +This first section on custom forms is for your typical, blocking, non-persistant form. By this I mean, when you "show" the form, the function will not return until the user has clicked a button or closed the window. When this happens, the form's window will be automatically closed. + +Two other types of forms exist. +1. Persistent form - rather than closing on button clicks, the show form function returns and the form continues to be visible. This is good for applications like a chat window. +2. Asynchronous form - the trickiest of the lot. Great care must be exercised. Examples are an MP3 player or status dashboard. Async forms are updated (refreshed) on a periodic basis. + It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. Let's start with a basic Browse for a file and do something with it. # Copy these design patterns! ## Pattern 1 - With Context Manager @@ -249,7 +255,7 @@ It's both not enjoyable nor helpful to immediately jump into tweaking each and e form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], [SG.InputText(), SG.FileBrowse()], [SG.Submit(), SG.Cancel()]] - (button, (source_filename, )) = form.LayoutAndShow(form_rows) + button, (source_filename, ) = form.LayoutAndShow(form_rows) ## Pattern 2 - No Context Manager @@ -257,7 +263,7 @@ It's both not enjoyable nor helpful to immediately jump into tweaking each and e form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], [SG.InputText(), SG.FileBrowse()], [SG.Submit(), SG.Cancel()]] - (button, (source_filename,)) = form.LayoutAndShow(form_rows) + button, (source_filename,) = form.LayoutAndShow(form_rows) These 2 design patters both produce this custom form: @@ -266,7 +272,7 @@ These 2 design patters both produce this custom form: It's important to use the "with" context manager so that resources are freed as quickly as possible, using the currently executing thread. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. -The second design pattern is not context manager based. There are times when the context manager hides errors. If you are struggling with an unknown error, try modifying the code to run without a context manager. +The second design pattern is not context manager based. If you are struggling with an unknown error, try modifying the code to run without a context manager. To do so, you simple remove the with, stick the form on the front of that statement, and un-indent the with-block code. You will use these design patterns or code templates for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. This is the most basic / normal of the design patterns. @@ -277,17 +283,17 @@ Going through each line of code in the above form will help explain how to use t with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: This creates a new form, storing it in the variable `form`. - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. - [SG.InputText(), SG.FileBrowse()], + [SG.InputText(), SG.FileBrowse()], Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. - [SG.Submit(), SG.Cancel()]] + [SG.Submit(), SG.Cancel()]] The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its value to the caller. - (button, (source_filename, )) = form.LayoutAndShow(form_rows) + (button, (source_filename, )) = form.LayoutAndShow(form_rows) This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field --- @@ -480,7 +486,16 @@ The most basic element is the Text element. It simply displays text. Many of t size=(None, None), auto_size_text=None, font=None, - text_color=None) + text_color=None, + justification=None) +. + + Text - The text that's displayed + size - Element's size + auto_size_text - Bool. Change width to match size of text + font - Font name and size to use + text_color - text color + justification - Justification for the text. String - 'left', 'right', 'center' Some commonly used elements have 'shorthand' versions of the functions to make the code more compact. The functions `T` and `Txt` are the same as calling `Text`. @@ -814,7 +829,7 @@ Each of the tabs of the form is in fact a form. The same steps are taken to cre ## Global Settings **Global Settings** -You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. +Let's have some fun customizing! Make PySimpleGUI look the way you want it to look. You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. SetOptions(icon=None, button_color=(None,None), @@ -825,7 +840,8 @@ You can set the global settings using the function `PySimpleGUI.SetOptions`. Ea font=None, border_width=None, autoclose_time=None, message_box_line_width=None, - progress_meter_border_depth=None): + progress_meter_border_depth=None, + text_justification=None): Explanation of parameters @@ -840,6 +856,7 @@ Explanation of parameters autoclose_time - time in seconds for autoclose boxes message_box_line_width - number of characers in a line of text in message boxes progress_meter_border_depth - amount of border around raised or lowered progress meters + text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' These settings apply to all forms `SetOptions`. The Row options and Element options will take precedence over these settings. Settings can be thought of as levels of settings with the Form-level being the highest and the Element-level the lowest. Thus the levels are: @@ -851,7 +868,55 @@ These settings apply to all forms `SetOptions`. The Row options and Element opt Each lower level overrides the settings of the higher level ## Asynchronous (Non-Blocking) Forms -While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. +So you want to be a wizard do ya? Well go boldly! While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. With asynchronous forms the form is shown, user input is read, but your code keeps right on chugging. YOUR responsibility is to call `PySimpleGUI.refresh` on a periodic basis. Once a second or more will produce a reasonably snappy GUI. +When do you use a non-blocking form? A couple of examples are +* A media file player like an MP3 player +* A status dashboard that's periodically updated +* Progress Meters - when you want to make your own progress meters +* Output using print to a scrolled text element. Good for debugging. + +We're going to build an app that does the latter. It's going to update our form with a running clock. + +The basic flow and functions you will be calling are: +Setup + + form = FlexForm() + form.AddRows(form_rows) + form.Show(non_blocking = True) + +Periodic refresh + + form.Refresh() +If you need to close the form + + form.CloseNonBlockingForm() + +Rather than the usual `form.LayoutAndShow()` call, we're manually adding the rows (doing the layout) and then showing the form. After the form is shown, you simply call `form.Refresh()` every now and then. + +When you are ready to close the form (assuming the form wasn't closed by the user or a button click) you simply call `form.CloseNonBlockingForm()` + +**Example - Running timer that updates** +We're going to make a form and update one of the elements of that form every .01 seconds. Here's the entire code to do that. + + with SG.FlexForm('Running Timer', auto_size_text=True) as form: + output_element = SG.Text('', size=(8, 2), font=('Helvetica', 20)) + form_rows = [[SG.Text('Non-blocking GUI with updates')], + [output_element], + [SG.SimpleButton('Quit')]] + + form.AddRows(form_rows) + form.Show(non_blocking=True) + for i in range(1, 100): + output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i/100), 60), i%100)) + rc = form.Refresh() + if rc is None or rc[0] == 'Quit': + break + time.sleep(.01) + else: + form.CloseNonBlockingForm() +What we have here is the same sequence of function calls as in the description. Get a form, add rows to it, show the form, and then refresh it every now and then. +The new thing in this example is the call use of the Update method for the Text Element. The first thing we do inside the loop is "update" the text element that we made earlier. This changes the value of the text field on the form. The new value will be displayed when `form.Refreshu()` is called. That's it... this example follows the async design pattern well. + ## Sample Applications @@ -874,12 +939,14 @@ sprint Call `sprint` with as many parameters as you want and it'll print them all out in a `ScrolledTextBox`. This is simply a function pointing to `PySimpleGUI.ScrolledTextBox`. --- -## Known Issues +# Known Issues While not an "issue" this is a ***stern warning*** ## **Do not attempt** to call `PySimpleGUI` from multiple threads! It's `tkinter` based and `tkinter` has issues with multiple threads **Progress Meters** - the visual graphic portion of the meter may be off. May return to the native tkinter progress meter solution in the future. Right now a "custom" progress meter is used. On the bright side, the statistics shown are extremely accurate and can tell you something about the performance of your code. +**Async Forms** - these include the 'easy' forms (EasyProgressMeter and EasyPrint/Print). If you start overlapping having Async forms open with normal forms then things get a littler squirrelly. Still tracking down the issues and am making it more solid every day possible. You'll know there's an issue when you see blank form. +**EasyPrint** - EasyPrint is a new feature that's pretty awesome. You print and the output goes to a window, with a scroll bar, that you can copy and paste from. Being a new feature, it's got some potential problems. There are known interaction problems with other GUI windows. For example, closing a Print window can also close other windows you have open. For now, don't close your debug print window until other windows are closed too. ## Contributing @@ -892,6 +959,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 1.0.21 | July 13, 2018 - Readme updates | | 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case | 2.1.1 | July 18, 2018 - Global settings exposed, fixes +| 2.2.0| July 20, 2018 - Image Elements, Print output ## Code Condition @@ -907,7 +975,7 @@ While the internals to PySimpleGUI are a tad sketchy, the public interfaces into MikeTheWatchGuy ## License - + This project is limited to non-commercial applications. If you wish to use it commercially, please contact one of the authors. For non-commercial individual, the GNU Lesser General Public License (LGPL 3) applies. @@ -915,7 +983,28 @@ For non-commercial individual, the GNU Lesser General Public License (LGPL 3) a * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence +## How Do I +Finally, I must thank the fine folks at How Do I. +https://github.com/gleitz/howdoi +Their utility has forever changed the way and pace in which I can program. I urge you to try the HowDoI.py application here on GitHub. Trust me, **it's going to be worth the effort!** +Here are the steps to run that application + + Install howdoi: + pip install howdoi + Test your install: + python -m howdoi howdoi.py + To run it: + Python HowDoI.py + +The pip command is all there is to the setup. + +The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. +For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. +![snap0109](https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg) + +In the hands of a competent programmer, this tool is **amazing**. It's a must-try kind of program that has completely changed my programming process. I'm not afraid of asking for help! You just have to be smart about using what you find. +The PySimpleGUI window that the results are shown in is an 'input' field which means you can copy and paste the results right into your code. From 42440da04887e37b87dc0d95e85034967a493ff8 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 20 Jul 2018 20:56:37 -0400 Subject: [PATCH 048/209] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index d277d6db5..2f8b6066c 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -[![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) +[![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 # PySimpleGUI This really is a simple GUI, but also powerfully customizable. From 8270fde1edf45001fb4bfb1589f3feca4675f248 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 23 Jul 2018 10:13:26 -0400 Subject: [PATCH 049/209] Logo Logo, --- readme.md | 74 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 19 deletions(-) diff --git a/readme.md b/readme.md index 2f8b6066c..05d9bc22f 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,6 @@ -[![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 +![logo01 2](https://user-images.githubusercontent.com/13696193/43081788-6b373d42-8e60-11e8-8f86-3ef0f01e54b5.png) + +](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 # PySimpleGUI This really is a simple GUI, but also powerfully customizable. @@ -17,7 +19,7 @@ Add a Progress Meter to your code with ONE LINE of code I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? -There are a number of 'easy to use' Python GUIs, but they're **very** limiting. PySimpleGUI takes the best of packages like `EasyGUI`(no longer maintained) and `WxSimpleGUI` (a great package, but limited). The difference between these and PySimpleGUI is that in addition to getting those simple Message Boxes you also get the ability to make your own forms that are highly customizeable. +There are a number of 'easy to use' Python GUIs, but they're **very** limiting. PySimpleGUI takes the best of packages like `EasyGUI`(no longer maintained) and `WxSimpleGUI` (a great package, but limited). The primary difference between these and PySimpleGUI is that in addition to getting those simple Message Boxes you also get the ability to make your own forms that are highly customizeable. Don't like the standard Message Box? Then make your own! Every call has optional parameters so that you can change the look and feel. Don't like the button color? It's easy to change by adding a button_color parameter to your widget. @@ -40,18 +42,36 @@ The `PySimpleGUI` solution is focused on the ***developer***. How can the desir Icons Multi-line Text Input Scroll-able Output + Images Progress Bar Async/Non-Blocking Windows Tabbed forms Persistent Windows - Redirect Python Output/Errors to scrolling Window + Redirect Python Output/Errors to scrolling window 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + Single-Line-Of-Coide Proress Bar & Debug Print An example of many widgets used on a single form. A little further down you'll find the FIFTEEN lines of code required to create this complex form. ![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) +--- +### Design Goals +> Copy, Paste, Run. + +`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the SDK to visually match what's on the screen. + + Be Pythonic... Python's lists in particular worked out really well: + - Forms are represented as Python lists. + - A form is a list of rows + - A row is a list of elements +- Return values are a list + + Each Elements is specified by names such as Text, Button, Checkbox, etc. + +Some elements have shortcuts, meant to make it easy on the programmer who will write less code using them. Rather than writing calling `Button`, with `button_name = "Submit"` will create a button with the text 'Submit' on it, Other examples include shortening the name of the function. `Text` is shorted to `Txt` or `T`. See each API call for the shortcuts. + ----- ## Getting Started with PySimpleGUI @@ -296,15 +316,6 @@ The last line of the `form_rows` variable assignment contains a Submit and a Can (button, (source_filename, )) = form.LayoutAndShow(form_rows) This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field ---- -### Design Goals -> Copy, Paste, Run. - -`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the SDK to visually match what's on the screen. - -Forms are represented as Python lists. There are 2 lists in particular. One is a list of rows that form up a GUI screen. The other is a list of Elements (or Widgets) on each row. Each Elements is specified by names such as Text, Button, Checkbox, etc. - -Some elements are shortcuts, meant to make it easy on the programmer who will write less code using them. Rather than writing a `Button`, with `button_name = "Submit"`, etc, the caller can simply writes `Submit`. Some examples include: `Text` has a short-cut function named `T`. `TextInput` has `In`. See each API call for the shortcuts. --- @@ -347,7 +358,7 @@ This code utilizes as many of the elements in one form as possible. [Text('Source Folder', size=(15, 1), auto_size_text=False), InputText('Source'), FolderBrowse()], [Text('Destination Folder', size=(15, 1), auto_size_text=False), InputText('Dest'), FolderBrowse()], [SimpleButton('Your Button with any text you want')], - [SimpleButton('Big Text', size=(12,1), font=("Helvetica", 20))], + [SimpleButton('Big Text', size=(12,1), font=("Helvetica", 20))], [Submit(), Cancel()]] (button, (values)) = form.LayoutAndShow(layout) @@ -771,7 +782,7 @@ You setup the progress meter by calling my_meter = ProgressMeter(title, max_value, *args, - d orientantion=None, + orientantion=None, bar_color=DEFAULT_PROGRESS_BAR_COLOR, button_color=None, size=DEFAULT_PROGRESS_BAR_SIZE, @@ -869,12 +880,21 @@ Each lower level overrides the settings of the higher level ## Asynchronous (Non-Blocking) Forms So you want to be a wizard do ya? Well go boldly! While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. With asynchronous forms the form is shown, user input is read, but your code keeps right on chugging. YOUR responsibility is to call `PySimpleGUI.refresh` on a periodic basis. Once a second or more will produce a reasonably snappy GUI. + When do you use a non-blocking form? A couple of examples are * A media file player like an MP3 player * A status dashboard that's periodically updated * Progress Meters - when you want to make your own progress meters * Output using print to a scrolled text element. Good for debugging. +Word of warning... version 2.2, the currently released, and upcoming version 2.3 differ in the return code for the `Refresh` call. Previously the function returned 2 values, except when the form is closed using the "X" which returned a single value of `None`. The *new* way is that Refresh always returns 2 values. If the user closed the form with the "X" then the return values will be None, None. You will want to key off the second value to catch this case. +The proper code to check if the user has exited the form will be a polling-loop that looks something like this: + + while True: + button, values = form.Refresh() + if values is None or button == 'Quit': + break + We're going to build an app that does the latter. It's going to update our form with a running clock. The basic flow and functions you will be calling are: @@ -908,22 +928,32 @@ We're going to make a form and update one of the elements of that form every .01 form.Show(non_blocking=True) for i in range(1, 100): output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i/100), 60), i%100)) - rc = form.Refresh() - if rc is None or rc[0] == 'Quit': + button, values = form.Refresh() + if values is None or button == 'Quit': break - time.sleep(.01) + time.sleep(.01) else: form.CloseNonBlockingForm() + What we have here is the same sequence of function calls as in the description. Get a form, add rows to it, show the form, and then refresh it every now and then. -The new thing in this example is the call use of the Update method for the Text Element. The first thing we do inside the loop is "update" the text element that we made earlier. This changes the value of the text field on the form. The new value will be displayed when `form.Refreshu()` is called. That's it... this example follows the async design pattern well. + +The new thing in this example is the call use of the Update method for the Text Element. The first thing we do inside the loop is "update" the text element that we made earlier. This changes the value of the text field on the form. The new value will be displayed when `form.Refresh()` is called. + +Note the `else` statement on the for loop. This is needed because we're about to exit the loop while the form is still open. The user has not closed the form using the X nor a button so it's up to the caller to close the form using `CloseNonBlockingForm`. + +That's it... this example follows the async design pattern well. ## Sample Applications Use the example programs as a starting basis for your GUI. Copy, paste, modify and run! The demo files are: + `Demo DisplayHash1and256.py` - Demonstrates using High Level API calls to get a filename + `Demo DupliucateFileFinder.py` - Demonstrates High Level API to get a folder & Easy Progress Meter to show progress of the file scanning + `Demo Recipes.py` - Three sample forms including an asynchronous form + `Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. ## Fun Stuff @@ -945,7 +975,9 @@ While not an "issue" this is a ***stern warning*** ## **Do not attempt** to call `PySimpleGUI` from multiple threads! It's `tkinter` based and `tkinter` has issues with multiple threads **Progress Meters** - the visual graphic portion of the meter may be off. May return to the native tkinter progress meter solution in the future. Right now a "custom" progress meter is used. On the bright side, the statistics shown are extremely accurate and can tell you something about the performance of your code. + **Async Forms** - these include the 'easy' forms (EasyProgressMeter and EasyPrint/Print). If you start overlapping having Async forms open with normal forms then things get a littler squirrelly. Still tracking down the issues and am making it more solid every day possible. You'll know there's an issue when you see blank form. + **EasyPrint** - EasyPrint is a new feature that's pretty awesome. You print and the output goes to a window, with a scroll bar, that you can copy and paste from. Being a new feature, it's got some potential problems. There are known interaction problems with other GUI windows. For example, closing a Print window can also close other windows you have open. For now, don't close your debug print window until other windows are closed too. ## Contributing @@ -960,6 +992,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case | 2.1.1 | July 18, 2018 - Global settings exposed, fixes | 2.2.0| July 20, 2018 - Image Elements, Print output +| 2.3.0 | July XX, 2018 - Changed form.Read return codes, Slider Elements, Listbox element ## Code Condition @@ -971,13 +1004,15 @@ It's a recipe for success if done right. PySimpleGUI has completed the "Make it While the internals to PySimpleGUI are a tad sketchy, the public interfaces into the SDK are more strictly defined and comply with PEP 8 for the most part. +Please log bugs and suggestions in the GitHub! It will only make the code stronger and better in the end, a good thing for us all, right? + ## Authors MikeTheWatchGuy ## License This project is limited to non-commercial applications. If you wish to use it commercially, please contact one of the authors. -For non-commercial individual, the GNU Lesser General Public License (LGPL 3) applies. +For non-commercial individuals, the GNU Lesser General Public License (LGPL 3) applies. ## Acknowledgments @@ -1008,3 +1043,4 @@ The PySimpleGUI window that the results are shown in is an 'input' field which m + From f52b97772846769775c57994a1bd3260b9509667 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 23 Jul 2018 10:15:45 -0400 Subject: [PATCH 050/209] Update readme.md --- readme.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 05d9bc22f..3c67215fe 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,5 @@ -![logo01 2](https://user-images.githubusercontent.com/13696193/43081788-6b373d42-8e60-11e8-8f86-3ef0f01e54b5.png) +![logo01 2 _1](https://user-images.githubusercontent.com/13696193/43082118-41397cde-8e61-11e8-94e2-cf386de53d88.png) + ](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 # PySimpleGUI From 528a0250ad8dfb3b29a1eb106b0431d1af9d7079 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 23 Jul 2018 10:17:19 -0400 Subject: [PATCH 051/209] Update readme.md --- readme.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 3c67215fe..1d465060c 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,4 @@ -![logo01 2 _1](https://user-images.githubusercontent.com/13696193/43082118-41397cde-8e61-11e8-94e2-cf386de53d88.png) - +![logo01 2 _2](https://user-images.githubusercontent.com/13696193/43082229-8b7343b6-8e61-11e8-90d4-808e1cb694ef.png) ](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 # PySimpleGUI From fce4d45472743d5ced0cd1f9bbe877fd446518f4 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 23 Jul 2018 10:18:59 -0400 Subject: [PATCH 052/209] Update readme.md --- readme.md | 470 +++++++++++++++++++++++++++--------------------------- 1 file changed, 235 insertions(+), 235 deletions(-) diff --git a/readme.md b/readme.md index 1d465060c..4017c0258 100644 --- a/readme.md +++ b/readme.md @@ -1,12 +1,12 @@ -![logo01 2 _2](https://user-images.githubusercontent.com/13696193/43082229-8b7343b6-8e61-11e8-90d4-808e1cb694ef.png) +![logo01 2](https://user-images.githubusercontent.com/13696193/43081788-6b373d42-8e60-11e8-8f86-3ef0f01e54b5.png) -](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 -# PySimpleGUI - -This really is a simple GUI, but also powerfully customizable. - - import PySimpleGUI as SG +[![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 +# PySimpleGUI + +This really is a simple GUI, but also powerfully customizable. + import PySimpleGUI as SG + SG.MsgBox('My Message Box', 'This is the shortest GUI program ever!') ![snap0102](https://user-images.githubusercontent.com/13696193/42781058-1d28d9fa-8913-11e8-847e-5c2afc16ca4c.jpg) @@ -14,10 +14,10 @@ This really is a simple GUI, but also powerfully customizable. Add a Progress Meter to your code with ONE LINE of code EasyProgressMeter('My meter title', current_value, max value) - + ![progress meter 2](https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg) -I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? +I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? There are a number of 'easy to use' Python GUIs, but they're **very** limiting. PySimpleGUI takes the best of packages like `EasyGUI`(no longer maintained) and `WxSimpleGUI` (a great package, but limited). The primary difference between these and PySimpleGUI is that in addition to getting those simple Message Boxes you also get the ability to make your own forms that are highly customizeable. Don't like the standard Message Box? Then make your own! @@ -28,30 +28,30 @@ GUI Packages with more functionality, like QT and WxPython, require configuring With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. The `PySimpleGUI` solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? - - Features of PySimpleGUI include: - Text - Single Line Input - Buttons including these types: + + Features of PySimpleGUI include: + Text + Single Line Input + Buttons including these types: File Browse Folder Browse Non-closing return - Close form - Checkboxes - Radio Buttons - Icons - Multi-line Text Input - Scroll-able Output - Images - Progress Bar - Async/Non-Blocking Windows + Close form + Checkboxes + Radio Buttons + Icons + Multi-line Text Input + Scroll-able Output + Images + Progress Bar + Async/Non-Blocking Windows Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling window + Persistent Windows + Redirect Python Output/Errors to scrolling window 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) Single-Line-Of-Coide Proress Bar & Debug Print - + An example of many widgets used on a single form. A little further down you'll find the FIFTEEN lines of code required to create this complex form. ![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) @@ -60,41 +60,41 @@ An example of many widgets used on a single form. A little further down you'll ### Design Goals > Copy, Paste, Run. -`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the SDK to visually match what's on the screen. +`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the SDK to visually match what's on the screen. Be Pythonic... Python's lists in particular worked out really well: - - Forms are represented as Python lists. + - Forms are represented as Python lists. - A form is a list of rows - A row is a list of elements - Return values are a list - Each Elements is specified by names such as Text, Button, Checkbox, etc. + Each Elements is specified by names such as Text, Button, Checkbox, etc. Some elements have shortcuts, meant to make it easy on the programmer who will write less code using them. Rather than writing calling `Button`, with `button_name = "Submit"` will create a button with the text 'Submit' on it, Other examples include shortening the name of the function. `Text` is shorted to `Txt` or `T`. See each API call for the shortcuts. ----- -## Getting Started with PySimpleGUI - -### Installing - - pip install PySimpleGUI - or -Simply download the file - PySimpleGUI.py and import it into your code - - -### Prerequisites - -Python 3 -tkinter - -Should run on all Python platforms that have tkinter running on them. Has been thoroughly tested on Windows. While not tested elsewhere, should work on Linux, Mac, Pi, etc. - +## Getting Started with PySimpleGUI + +### Installing + + pip install PySimpleGUI + or +Simply download the file - PySimpleGUI.py and import it into your code + + +### Prerequisites + +Python 3 +tkinter + +Should run on all Python platforms that have tkinter running on them. Has been thoroughly tested on Windows. While not tested elsewhere, should work on Linux, Mac, Pi, etc. + ### Using To use in your code, simply import.... - `import PySimpleGUI as SG` + `import PySimpleGUI as SG` -Then use either "high level" API calls or build your own forms. +Then use either "high level" API calls or build your own forms. SG.MsgBox('This is my first message box') ![snap0103](https://user-images.githubusercontent.com/13696193/42844641-a04bb798-89e1-11e8-8a37-50ddd9905772.jpg) @@ -103,70 +103,70 @@ Yes, it's just that easy to have a window appear on the screen using Python. Wi --- ## APIs - -PySimpleGUI can be broken down into 2 types of API's: - * High Level single call functions - * Custom form functions - + +PySimpleGUI can be broken down into 2 types of API's: + * High Level single call functions + * Custom form functions + ### Python Language Features There are a couple of Python language features that PySimpleGUI utilizes heavily that should be understood first... - * Variable number of arguments to a function call + * Variable number of arguments to a function call * Optional parameters to a function call - + #### Variable Number of Arguments The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. - + SG.MsgBox('Variable number of parameters example', var1, var2, "etc") Each new item begins on a new line in the Message Box ![snap0104](https://user-images.githubusercontent.com/13696193/42844739-ebea22ac-89e1-11e8-8dd1-e61441325701.jpg) - + #### Optional Parameters to a Function Call - + This feature of the Python language is utilized ***heavily*** as a method of customizing forms and form Elements. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. -Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't *have* to be specified on each and every call. +Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't *have* to be specified on each and every call. - def MsgBox(*args, - button_color=None, - button_type=MSG_BOX_OK, - auto_close=False, - auto_close_duration=None, - icon=DEFAULT_WINDOW_ICON, + def MsgBox(*args, + button_color=None, + button_type=MSG_BOX_OK, + auto_close=False, + auto_close_duration=None, + icon=DEFAULT_WINDOW_ICON, line_width=MESSAGE_BOX_LINE_WIDTH, font=None): If the caller wanted to change the button color to be black on yellow, the call would look something like this: - SG.MsgBox('This box has a custom button color', + SG.MsgBox('This box has a custom button color', button_color=('black', 'yellow')) - + ![snap0105](https://user-images.githubusercontent.com/13696193/42844830-2d7e8b9a-89e2-11e8-8ef4-5af9e36f30f3.jpg) --- -### High Level API Calls - -The classic "input a value, print result" example. -Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. -This code prompts user to input a line of text and then displays that text in a messages box: - - import PySimpleGUI_local as SG - - rc = SG.GetTextBox('Title', 'Please input something') - SG.MsgBox('Results', 'The value returned from GetTextBox', rc) - -![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) - -![MsgBox](https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg) - +### High Level API Calls + +The classic "input a value, print result" example. +Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. +This code prompts user to input a line of text and then displays that text in a messages box: + + import PySimpleGUI_local as SG + + rc = SG.GetTextBox('Title', 'Please input something') + SG.MsgBox('Results', 'The value returned from GetTextBox', rc) + +![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) + +![MsgBox](https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg) + #### Message Boxes In addition to MsgBox, you'll find a several API calls that are shortcuts to common messages boxes. You can achieve similar results by calling MsgBox with the correct parameters. @@ -175,7 +175,7 @@ The differences tend to be the number and types of buttons. Here are the calls import PySimpleGUI as SG `SG.MsgBoxOK('This is an OK MsgBox')` - + ![msgboxok](https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg) SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') @@ -209,7 +209,7 @@ This becomes a debug print of sorts that will route to a scrolled window. There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. If you need only 1 value, then perhaps one of these high level functions will work. - GetTextBox - - GetFileBox + - GetFileBox - GetFolderBox `submit_clicked, value = SG.GetTextBox('Title', 'Please enter anything')` @@ -241,7 +241,7 @@ We all have loops in our code. 'Isn't it joyful waiting, watching a counter scr Here's the one-line Progress Meter in action! - for i in range(1,10000): + for i in range(1,10000): SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') That line of code resulted in this window popping up and updating. @@ -249,10 +249,10 @@ That line of code resulted in this window popping up and updating. ![progress meter 5](https://user-images.githubusercontent.com/13696193/42696912-a5c958b8-8687-11e8-9a7d-a390a465407a.jpg) A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. -With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. +With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. if not SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message'): - break + break ***Be sure and add one to your loop counter*** so that your counter goes from 1 to the max value. If you do not add one, your counter will never hit the max value. Instead it will go from 0 to max-1. @@ -271,17 +271,17 @@ It's both not enjoyable nor helpful to immediately jump into tweaking each and e # Copy these design patterns! ## Pattern 1 - With Context Manager - with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], - [SG.InputText(), SG.FileBrowse()], - [SG.Submit(), SG.Cancel()]] + with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + [SG.InputText(), SG.FileBrowse()], + [SG.Submit(), SG.Cancel()]] button, (source_filename, ) = form.LayoutAndShow(form_rows) ## Pattern 2 - No Context Manager - form = SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], - [SG.InputText(), SG.FileBrowse()], + form = SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + [SG.InputText(), SG.FileBrowse()], [SG.Submit(), SG.Cancel()]] button, (source_filename,) = form.LayoutAndShow(form_rows) @@ -300,13 +300,13 @@ You will use these design patterns or code templates for all of your "normal" (b Going through each line of code in the above form will help explain how to use this design patter. Copy, modify and run it! - with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: -This creates a new form, storing it in the variable `form`. + with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: +This creates a new form, storing it in the variable `form`. - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. - [SG.InputText(), SG.FileBrowse()], + [SG.InputText(), SG.FileBrowse()], Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. [SG.Submit(), SG.Cancel()]] @@ -322,45 +322,45 @@ This is the code that **displays** the form, collects the information and return ## Return values - Return information from FlexForm, SG's primary form builder interface, is in this format: - - (button, (value1, value2, ...)) - + Return information from FlexForm, SG's primary form builder interface, is in this format: + + (button, (value1, value2, ...)) + Each of the Elements that are Input Elements will have a value in the list of return values. You can unpack your GUI directly into the variables you want to use. (button, (filename, folder1, folder2, should_overwrite) = form.LayoutAndShow(form_rows) - -If you have a SINGLE value being returned, it is written this way: - + +If you have a SINGLE value being returned, it is written this way: + (button, (value1,)) = form.LayoutAndShow(form_rows) Another way of parsing the return values is to store the list of values into a variable representing the list of values. - (button, (value_list)) = form.LayoutAndShow(form_rows) + (button, (value_list)) = form.LayoutAndShow(form_rows) value1 = value_list[0] value2 = value_list[1] ... - + --- ## All Widgets / Elements This code utilizes as many of the elements in one form as possible. - with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: - layout = [[Text('Here they all are!', size=(30,1), font=("Helvetica", 25), text_color='red')], - [Text('Here is some text with font sizing', font=("Helvetica", 15))], - [InputText()], - [Checkbox('My first checkbox!'), Checkbox('My second checkbox!', default=True)], - [Radio('My first Radio!', "RADIO1", default=True), Radio('My second checkbox!', "RADIO1")], - [Multiline(DefaultText='This is the DEFAULT text should you decide not to type anything', scale=(2, 10))], - [InputCombo(['choice 1', 'choice 2'], size=(20, 3))], - [Text('_' * 90, size=(60, 1))], - [Text('Choose Source and Destination Folders', size=(35,1))], - [Text('Source Folder', size=(15, 1), auto_size_text=False), InputText('Source'), FolderBrowse()], - [Text('Destination Folder', size=(15, 1), auto_size_text=False), InputText('Dest'), FolderBrowse()], - [SimpleButton('Your Button with any text you want')], + with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: + layout = [[Text('Here they all are!', size=(30,1), font=("Helvetica", 25), text_color='red')], + [Text('Here is some text with font sizing', font=("Helvetica", 15))], + [InputText()], + [Checkbox('My first checkbox!'), Checkbox('My second checkbox!', default=True)], + [Radio('My first Radio!', "RADIO1", default=True), Radio('My second checkbox!', "RADIO1")], + [Multiline(DefaultText='This is the DEFAULT text should you decide not to type anything', scale=(2, 10))], + [InputCombo(['choice 1', 'choice 2'], size=(20, 3))], + [Text('_' * 90, size=(60, 1))], + [Text('Choose Source and Destination Folders', size=(35,1))], + [Text('Source Folder', size=(15, 1), auto_size_text=False), InputText('Source'), FolderBrowse()], + [Text('Destination Folder', size=(15, 1), auto_size_text=False), InputText('Dest'), FolderBrowse()], + [SimpleButton('Your Button with any text you want')], [SimpleButton('Big Text', size=(12,1), font=("Helvetica", 20))], - [Submit(), Cancel()]] - + [Submit(), Cancel()]] + (button, (values)) = form.LayoutAndShow(layout) MsgBox('Results', 'You clicked {}'.format(button),'The values returned from form', values , font = ("Helvetica", 15)) @@ -376,13 +376,13 @@ Clicking the Submit button caused the form call to return. The call to MsgBox r (button, (values)) = form.LayoutAndShow(layout) **`Note, button value can be None`**. The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. -You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. +You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. --- # Building Custom Forms You will find it much easier to write code using PySimpleGUI if you use an IDE such as PyCharm. The features that show you documentation about the API call you are making will help you determine which settings you want to change, if any. In PyCharm, two commands are particularly helpful. - Control-Q (when cursor is on function name) brings up a box with the function definition + Control-Q (when cursor is on function name) brings up a box with the function definition Control-P (when cursor inside function call "()") shows a list of parameters and their default values ## Synchronous Forms @@ -396,11 +396,11 @@ NON-BLOCKING form call: ### Beginning a Form The first step is to create the form object using the desired form customization. - with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: + with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: This is the definition of the FlexForm object: - def FlexForm(title, + def FlexForm(title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=DEFAULT_AUTOSIZE_TEXT, scale=(None, None), @@ -412,7 +412,7 @@ This is the definition of the FlexForm object: auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON): - + Parameter Descriptions. You will find these same parameters specified for each `Element` and some of them in `Row` specifications. The `Element` specified value will take precedence over the `Row` and `Form` values. default_element_size - Size of elements in form in characters (width, height) @@ -457,22 +457,22 @@ A summary of the variables that can be changed when a FlexForm is created ## Elements "Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. - Text - Single Line Input - Buttons including these types: + Text + Single Line Input + Buttons including these types: File Browse Folder Browse Non-closing return - Close form - Checkboxes - Radio Buttons - Multi-line Text Input - Scroll-able Output - Progress Bar - Async/Non-Blocking Windows + Close form + Checkboxes + Radio Buttons + Multi-line Text Input + Scroll-able Output + Progress Bar + Async/Non-Blocking Windows Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling Window + Persistent Windows + Redirect Python Output/Errors to scrolling Window "Higher level" APIs (e.g. MessageBox, YesNobox, ...) @@ -484,15 +484,15 @@ Building a form is simply making lists of Elements. Each list is a row in the o The code is a crude representation of the GUI, laid out in text. #### Text Element - layout = [[SG.Text('This is what a Text Element looks like')]] - + layout = [[SG.Text('This is what a Text Element looks like')]] + ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. - Text(Text, + Text(Text, scale=(None, None), size=(None, None), auto_size_text=None, @@ -568,7 +568,7 @@ Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. ### Input Elements These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. - + #### Text Input Element layout = [[SG.InputText('Default text')]] @@ -594,10 +594,10 @@ Shorthand functions that are equivalent to `InputText` are `Input` and `In` Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. layout = [[SG.InputCombo(['choice 1', 'choice 2'])]] - + ![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) - InputCombo(values, + InputCombo(values, scale=(None, None), size=(None, None), auto_size_text=None) @@ -635,7 +635,7 @@ Creates one radio button that is assigned to a group of radio buttons. Only 1 o #### Checkbox Element -Checkbox elements are like Radio Button elements. They return a bool indicating whether or not they are checked. +Checkbox elements are like Radio Button elements. They return a bool indicating whether or not they are checked. layout = [[SG.Checkbox('My first Checkbox!', default=True), SG.Checkbox('My second Checkbox!')]] @@ -665,7 +665,7 @@ An up/down spinner control. The valid values are passed in as a list. ![spin element](https://user-images.githubusercontent.com/13696193/42717231-8ddb51d4-86cd-11e8-827a-75f2237477fa.jpg) - Spin(values, + Spin(values, intiial_value=None, scale=(None, None), size=(None, None), @@ -679,7 +679,7 @@ An up/down spinner control. The valid values are passed in as a list. size - (width, height) size of element in characters auto_size_text - Bool. True if should size width to fit text font - Font type and size for text display - + #### Button Element Buttons are the most important element of all! They cause the majority of the action to happen. After all, it's a button press that will get you out of a form, whether it but Submit or Cancel, one way or another a button is involved in all forms. The only exception is to this is when the user closes the window using the "X" in the upper corner which means no button was involved. @@ -691,9 +691,9 @@ The Types of buttons include: Close Form - Normal buttons like Submit, Cancel, Yes, No, etc, are "Close Form" buttons. They cause the input values to be read and then the form is closed, returning the values to the caller. - -Folder Browse - When clicked a folder browse dialog box is opened. The results of the Folder Browse dialog box are written into one of the input fields of the form. - + +Folder Browse - When clicked a folder browse dialog box is opened. The results of the Folder Browse dialog box are written into one of the input fields of the form. + File Browse - Same as the Folder Browse except rather than choosing a folder, a single file is chosen. Read Form - This is an async form button that will read a snapshot of all of the input fields, but does not close the form after it's clicked. @@ -706,7 +706,7 @@ While it's possible to build forms using the Button Element directly, you should auto_size_text=None, button_color=None, font=None) - + Pre-made buttons include: OK @@ -722,7 +722,7 @@ Pre-made buttons include: ![ok cancel](https://user-images.githubusercontent.com/13696193/42717733-1803f584-86d1-11e8-9223-36b782971b9f.jpg) -The FileBrowse and FolderBrowse buttons both fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. +The FileBrowse and FolderBrowse buttons both fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. The default value for `Target` is `(ThisRow, -1)`. ThisRow is a special value that tells the GUI to use the same row as the button. The Y-value of -1 means the field one value to the left of the button. For a File or Folder Browse button, the field that it fills are generally to the left of the button is most cases. @@ -736,30 +736,30 @@ The `InputText` element is located at (1,0)... row 1, column 0. The `Browse` bu Target = (-1,0) The code for the entire form could be: - layout = [[SG.T('Source Folder')], - [SG.In()], + layout = [[SG.T('Source Folder')], + [SG.In()], [SG.FolderBrowse(Target=(-1,0)), SG.OK()]] **Custom Buttons** If you want to define your own button, you will generally do this with the Button Element `SimpleButton`. - + layout = [[SG.SimpleButton('My Button')]] ![singlebutton](https://user-images.githubusercontent.com/13696193/42718281-9453deca-86d5-11e8-83c7-4b6d33720858.jpg) -All buttons can have their text changed by changing the `button_text` variable. +All buttons can have their text changed by changing the `button_text` variable. **File Types** -The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is +The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is FileTypes=(("ALL Files", "*.*"),) - + This code produces a form where the Browse button only shows files of type .TXT layout = [[SG.In() ,SG.FileBrowse(file_types=(("Text Files", "*.txt"),))]] ***The ENTER key*** - The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. + The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. --- @@ -770,7 +770,7 @@ The **easiest** way to get progress meters into your code is to use the `EasyPro You've already seen EasyProgressMeter calls presented earlier in this readme. SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') - + The return value for `EasyProgressMeter` is: `True` if meter updated correctly `False` if user clicked the Cancel button, closed the form, or vale reached the max value. @@ -779,25 +779,25 @@ If you want a bit more customization of your meter, then you can go up 1 level a You setup the progress meter by calling - my_meter = ProgressMeter(title, + my_meter = ProgressMeter(title, max_value, *args, - orientantion=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, + orientantion=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) Then to update the bar within your loop return_code = ProgressMeterUpdate(my_meter, - value, + value, *args): Putting it all together you get this design pattern - my_meter = SG.ProgressMeter('Meter Title', 100000, orentation='Vert') - - for i in range(0, 100000): + my_meter = SG.ProgressMeter('Meter Title', 100000, orentation='Vert') + + for i in range(0, 100000): SG.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') @@ -813,26 +813,26 @@ The Output Element is a re-direction of Stdout. Anything "printed" will be disp Here's a complete solution for a chat-window using an Async form with an Output Element import PySimpleGUI as g - - with g.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: - form.AddRow(g.Text('This is where standard out is being routed', size=[40,1])) - form.AddRow(g.Output(size=(80, 20))) - form.AddRow(g.Multiline(size=(70, 5), enter_submits=True), g.ReadFormButton('SEND', button_color=(g.YELLOWS[0], g.BLUES[0])), g.SimpleButton('EXIT', button_color=(g.YELLOWS[0], g.GREENS[0]))) - - # ---===--- Loop taking in user input and printing it --- # - while True: - (button, value) = form.Read() - if button == 'SEND': - print(value) - else: - print('Exiting the form now') + + with g.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + form.AddRow(g.Text('This is where standard out is being routed', size=[40,1])) + form.AddRow(g.Output(size=(80, 20))) + form.AddRow(g.Multiline(size=(70, 5), enter_submits=True), g.ReadFormButton('SEND', button_color=(g.YELLOWS[0], g.BLUES[0])), g.SimpleButton('EXIT', button_color=(g.YELLOWS[0], g.GREENS[0]))) + + # ---===--- Loop taking in user input and printing it --- # + while True: + (button, value) = form.Read() + if button == 'SEND': + print(value) + else: + print('Exiting the form now') break - + ## Tabbed Forms Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format - results = ShowTabbedForm('Title for the form', + results = ShowTabbedForm('Title for the form', (form,layout,'Tab 1 label'), (form2,layout2, 'Tab 2 label')) @@ -842,21 +842,21 @@ Each of the tabs of the form is in fact a form. The same steps are taken to cre **Global Settings** Let's have some fun customizing! Make PySimpleGUI look the way you want it to look. You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. - SetOptions(icon=None, + SetOptions(icon=None, button_color=(None,None), - element_size=(None,None), - margins=(None,None), - element_padding=(None,None), + element_size=(None,None), + margins=(None,None), + element_padding=(None,None), auto_size_text=None, - font=None, border_width=None, - autoclose_time=None, - message_box_line_width=None, + font=None, border_width=None, + autoclose_time=None, + message_box_line_width=None, progress_meter_border_depth=None, text_justification=None): Explanation of parameters - icon - filename of icon used for taskbar and title bar + icon - filename of icon used for taskbar and title bar button_color - button color (foreground, background) element_size - element size (width, height) in characters margins - tkinter margins around outsize @@ -869,7 +869,7 @@ Explanation of parameters progress_meter_border_depth - amount of border around raised or lowered progress meters text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' - + These settings apply to all forms `SetOptions`. The Row options and Element options will take precedence over these settings. Settings can be thought of as levels of settings with the Form-level being the highest and the Element-level the lowest. Thus the levels are: - Form level @@ -878,7 +878,7 @@ These settings apply to all forms `SetOptions`. The Row options and Element opt Each lower level overrides the settings of the higher level -## Asynchronous (Non-Blocking) Forms +## Asynchronous (Non-Blocking) Forms So you want to be a wizard do ya? Well go boldly! While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. With asynchronous forms the form is shown, user input is read, but your code keeps right on chugging. YOUR responsibility is to call `PySimpleGUI.refresh` on a periodic basis. Once a second or more will produce a reasonably snappy GUI. When do you use a non-blocking form? A couple of examples are @@ -911,30 +911,30 @@ If you need to close the form form.CloseNonBlockingForm() -Rather than the usual `form.LayoutAndShow()` call, we're manually adding the rows (doing the layout) and then showing the form. After the form is shown, you simply call `form.Refresh()` every now and then. +Rather than the usual `form.LayoutAndShow()` call, we're manually adding the rows (doing the layout) and then showing the form. After the form is shown, you simply call `form.Refresh()` every now and then. When you are ready to close the form (assuming the form wasn't closed by the user or a button click) you simply call `form.CloseNonBlockingForm()` **Example - Running timer that updates** We're going to make a form and update one of the elements of that form every .01 seconds. Here's the entire code to do that. - with SG.FlexForm('Running Timer', auto_size_text=True) as form: - output_element = SG.Text('', size=(8, 2), font=('Helvetica', 20)) - form_rows = [[SG.Text('Non-blocking GUI with updates')], - [output_element], - [SG.SimpleButton('Quit')]] - - form.AddRows(form_rows) - form.Show(non_blocking=True) - for i in range(1, 100): - output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i/100), 60), i%100)) - button, values = form.Refresh() - if values is None or button == 'Quit': - break - time.sleep(.01) - else: + with SG.FlexForm('Running Timer', auto_size_text=True) as form: + output_element = SG.Text('', size=(8, 2), font=('Helvetica', 20)) + form_rows = [[SG.Text('Non-blocking GUI with updates')], + [output_element], + [SG.SimpleButton('Quit')]] + + form.AddRows(form_rows) + form.Show(non_blocking=True) + for i in range(1, 100): + output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i/100), 60), i%100)) + button, values = form.Refresh() + if values is None or button == 'Quit': + break + time.sleep(.01) + else: form.CloseNonBlockingForm() - + What we have here is the same sequence of function calls as in the description. Get a form, add rows to it, show the form, and then refresh it every now and then. The new thing in this example is the call use of the Update method for the Text Element. The first thing we do inside the loop is "update" the text element that we made earlier. This changes the value of the text field on the form. The new value will be displayed when `form.Refresh()` is called. @@ -954,19 +954,19 @@ Use the example programs as a starting basis for your GUI. Copy, paste, modify `Demo Recipes.py` - Three sample forms including an asynchronous form -`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. +`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. ## Fun Stuff Here are some things to try if you're bored or want to further customize **Random colors** To set a button or text to a random color, use the string `'random'` as the color value. You can also call `PySimpleGUI.GetRandomColor`. -To get a random color pair call `PySimpleGUI.GetRandomColorPair`. This returns a tuple containing a random color and +To get a random color pair call `PySimpleGUI.GetRandomColorPair`. This returns a tuple containing a random color and that color's compliment. sprint **sprint** -Call `sprint` with as many parameters as you want and it'll print them all out in a `ScrolledTextBox`. This is simply a function pointing to `PySimpleGUI.ScrolledTextBox`. +Call `sprint` with as many parameters as you want and it'll print them all out in a `ScrolledTextBox`. This is simply a function pointing to `PySimpleGUI.ScrolledTextBox`. --- # Known Issues @@ -980,12 +980,12 @@ While not an "issue" this is a ***stern warning*** **EasyPrint** - EasyPrint is a new feature that's pretty awesome. You print and the output goes to a window, with a scroll bar, that you can copy and paste from. Being a new feature, it's got some potential problems. There are known interaction problems with other GUI windows. For example, closing a Print window can also close other windows you have open. For now, don't close your debug print window until other windows are closed too. -## Contributing - +## Contributing + A MikeTheWatchGuy production... entirely responsible for this code.... unless it causes you trouble in which case I'm not at all responsible. - -## Versioning -|Version | Description | + +## Versioning +|Version | Description | |--|--| | 1.0.9 | July 10, 2018 - Initial Release | | 1.0.21 | July 13, 2018 - Readme updates | @@ -993,35 +993,35 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.1.1 | July 18, 2018 - Global settings exposed, fixes | 2.2.0| July 20, 2018 - Image Elements, Print output | 2.3.0 | July XX, 2018 - Changed form.Read return codes, Slider Elements, Listbox element + +## Code Condition -## Code Condition - - Make it run - Make it right + Make it run + Make it right Make it fast -It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor for PEP 8 compliance. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. +It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor for PEP 8 compliance. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. -While the internals to PySimpleGUI are a tad sketchy, the public interfaces into the SDK are more strictly defined and comply with PEP 8 for the most part. +While the internals to PySimpleGUI are a tad sketchy, the public interfaces into the SDK are more strictly defined and comply with PEP 8 for the most part. Please log bugs and suggestions in the GitHub! It will only make the code stronger and better in the end, a good thing for us all, right? - -## Authors + +## Authors MikeTheWatchGuy - -## License - + +## License + This project is limited to non-commercial applications. If you wish to use it commercially, please contact one of the authors. For non-commercial individuals, the GNU Lesser General Public License (LGPL 3) applies. - -## Acknowledgments - + +## Acknowledgments + * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence ## How Do I Finally, I must thank the fine folks at How Do I. https://github.com/gleitz/howdoi -Their utility has forever changed the way and pace in which I can program. I urge you to try the HowDoI.py application here on GitHub. Trust me, **it's going to be worth the effort!** +Their utility has forever changed the way and pace in which I can program. I urge you to try the HowDoI.py application here on GitHub. Trust me, **it's going to be worth the effort!** Here are the steps to run that application Install howdoi: @@ -1031,7 +1031,7 @@ Here are the steps to run that application To run it: Python HowDoI.py -The pip command is all there is to the setup. +The pip command is all there is to the setup. The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. From f6f02b6f2b8f22ea5d1338ab4cfb6735d41a2463 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 23 Jul 2018 10:21:26 -0400 Subject: [PATCH 053/209] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 4017c0258..199845992 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -![logo01 2](https://user-images.githubusercontent.com/13696193/43081788-6b373d42-8e60-11e8-8f86-3ef0f01e54b5.png) +![logo01 2 _2](https://user-images.githubusercontent.com/13696193/43082437-1252511a-8e62-11e8-9150-fc227cc56cfe.png) [![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 # PySimpleGUI From f3bee1687e568c6726d12f31329f2a0d0fd3a4dc Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 23 Jul 2018 15:14:34 -0400 Subject: [PATCH 054/209] 2.3 Release Large change to ReadMe and Recipes. Some functions renamed or a new name was created, leaving legacy name in place... for now. As long as docs steer people in the direction of the new names it'll be ok --- Demo Recipes.py | 181 +++++++-------- PySimpleGUI.py | 218 +++++++++++++++--- readme.md | 600 ++++++++++++++++++++++++++++-------------------- 3 files changed, 627 insertions(+), 372 deletions(-) diff --git a/Demo Recipes.py b/Demo Recipes.py index f9e957e7d..db2168a4e 100644 --- a/Demo Recipes.py +++ b/Demo Recipes.py @@ -4,7 +4,7 @@ import string import PySimpleGUI as SG - +# A simple blocking form. Your best starter-form def SourceDestFolders(): with SG.FlexForm('Demo Source / Destination Folders', auto_size_text=True) as form: form_rows = [[SG.Text('Enter the Source and Destination folders')], @@ -12,161 +12,158 @@ def SourceDestFolders(): [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), SG.FolderBrowse()], [SG.Submit(), SG.Cancel()]] - button, (source, dest) = form.LayoutAndShow(form_rows) + button, (source, dest) = form.LayoutAndRead(form_rows) if button == 'Submit': - # do something useful with the inputs SG.MsgBox('Submitted', 'The user entered source:', source, 'Destination folder:', dest, 'Using button', button) else: SG.MsgBoxError('Cancelled', 'User Cancelled') +# YOUR BEST STARTING POINT +# This is a form showing you all of the basic Elements (widgets) +# Some have a few of the optional parameters set, but there are more to choose from +# You want to use the context manager because it will free up resources when you are finished +# Use this especially if you are runningm multi-threaded +# Where you free up resources is really important to tkinter +def Everything(): + with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [SG.Text('Here is some text.... and a place to enter text')], + [SG.InputText()], + [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], + [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], + [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [SG.Text('_' * 100, size=(70, 1))], + [SG.Text('Choose Source and Destination Folders', size=(35, 1))], + [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], + [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), + SG.FolderBrowse()], + [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + + SG.MsgBox('Title', 'Typical message box', 'The results of the form are a lot of data! Get ready... ', 'The button clicked was "{}"'.format(button), 'The values are', values) + +# Should you decide not to use a context manager, then try this form as your starting point +# Be aware that tkinter, which this is based on, is picky about who frees up resources, especially if +# you are running multithreaded def Everything_NoContextManager(): form = SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) layout = [[SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], [SG.Text('Here is some text.... and a place to enter text')], [SG.InputText()], [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], - [SG.Radio('My first Radio!', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], - [SG.Multiline(default_text='This is the default Text should you decide not to type anything', scale=(2, 10))], - [SG.InputCombo(['choice 1', 'choice 2'], size=(20, 3))], + [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], + [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', scale=(2, 10))], + [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), SG.Slider(range=(1,100), orientation='h', size=(35,20), default_value=85)], + [SG.Listbox(values=['Listbox 1','Listbox 2', 'Listbox 3'], size=(30,6)), + SG.Slider(range=(1,100), orientation='v', size=(10, 20), default_value=25), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], [SG.Text('_' * 100, size=(70, 1))], - [SG.Text('Choose Source and Destination Folders', size=(35, 1))], - [SG.Text('Source Folder', size=(15, 1), auto_size_text=False), SG.InputText('Source'), SG.FolderBrowse()], - [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False), SG.InputText('Dest'), SG.FolderBrowse()], - [SG.SimpleButton('Your very own button', button_color=('white', 'green'))], - [SG.Submit(), SG.Cancel()]] + [SG.Text('Choose Source and Destination Folders', size=(35, 1), text_color='red')], + [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], + [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), SG.FolderBrowse()], + [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))]] - button, (values) = form.LayoutAndShow(layout) + button, values = form.LayoutAndRead(layout) + del(form) SG.MsgBox('Title', 'Typical message box', 'Here are the restults! There is one entry per input field ', 'The button clicked was "{}"'.format(button), 'The values are', values) - -def Everything(): - with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: - layout = [[SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [SG.Text('Here is some text.... and a place to enter text')], - [SG.InputText()], - [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], - [SG.Radio('My first Radio!', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], - [SG.Spin(values=(1,2,3), initial_value=1, size=(2,1)), SG.T('Spinner 1', size=(20,1)), - SG.Spin(values=(1,2,3), initial_value=1, size=(2,1)),SG.T('Spinner 2')], - [SG.Multiline(default_text='This is the default Text should you decide not to type anything', scale=(2, 10))], - [SG.InputCombo(['choice 1', 'choice 2'], size=(20, 3))], - [SG.Text('_' * 100, size=(70, 1))], - [SG.Text('Choose Source and Destination Folders', size=(35, 1))], - [SG.Text('Source Folder', size=(15, 1), auto_size_text=False), SG.InputText('Source'), SG.FolderBrowse()], - [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False), SG.InputText('Dest'), SG.FolderBrowse()], - [SG.SimpleButton('Custom Button', button_color=('white', 'green'))], - [SG.Submit(), SG.Cancel()]] - - button, (values) = form.LayoutAndShow(layout) - - SG.MsgBox('Title', 'Typical message box', 'The results of the form are a lot of data! Get ready... ', 'The button clicked was "{}"'.format(button), 'The values are', values) - def ProgressMeter(): for i in range(1,10000): if not SG.EasyProgressMeter('My Meter', i+1, 10000): break + # SG.Print(i) -def RunningTimer(): - with SG.FlexForm('Running Timer', auto_size_text=True) as form: - output_element = SG.Text('', size=(8, 2), font=('Helvetica', 20)) - form_rows = [[SG.Text('Non-blocking GUI with updates')], - [output_element], - [SG.SimpleButton('Quit')]] - - form.AddRows(form_rows) - form.Show(non_blocking=True) - for i in range(1, 100): - output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i/100), 60), i%100)) - rc = form.Refresh() - if rc is None or rc[0] == 'Quit': - break - time.sleep(.01) - else: - form.CloseNonBlockingForm() - - - - -# Persistant form. Does not close when Send button is clicked. -# Normally all Simple Buttons cause forms to close +# Blocking form that doesn't close def ChatBot(): with SG.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: - form.AddRow(SG.Text('This is where standard out is being routed', size=[40, 1])) - form.AddRow(SG.Output(size=(80, 20))) - form.AddRow(SG.Multiline(size=(70, 5), enter_submits=True), SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))) - button, value = form.Read() - + layout = [[(SG.Text('This is where standard out is being routed', size=[40, 1]))], + [SG.Output(size=(80, 20))], + [SG.Multiline(size=(70, 5), enter_submits=True), SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))]] + # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form + # if you call LayoutAndRead from here, then you will miss the first button click + form.Layout(layout) # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # while True: + button, value = form.Read() if button == 'SEND': print(value) else: break - button, value = form.Read() - +# Shows a form that's a running counter +# this is the basic design pattern if you can keep your reading of the +# form within the 'with' block. If your read occurs far away in your code from the form creation +# then you will want to use the NonBlockingPeriodicUpdateForm example def NonBlockingPeriodicUpdateForm_ContextManager(): - # Show a form that's a running counter with SG.FlexForm('Running Timer', auto_size_text=True) as form: - output_element = SG.Text('',size=(10,2), font=('Helvetica', 20), text_color='red', justification='center') - form_rows = [[SG.Text('Non blocking GUI with updates', justification='center')], - [output_element], + text_element = SG.Text('',size=(10,2), font=('Helvetica', 20), text_color='red', justification='center') + layout = [[SG.Text('Non blocking GUI with updates', justification='center')], + [text_element], [SG.T(' '*15), SG.Quit()]] - form.AddRows(form_rows) - form.Show(non_blocking=True) + form.LayoutAndRead(layout, non_blocking=True) for i in range(1,500): - output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i/100), 60), i%100)) - rc = form.Refresh() - if rc is None: # if user closed the window using X - break - button, values = rc - if button == 'Quit': + text_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i/100), 60), i%100)) + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': # if user closed the window using X break time.sleep(.01) else: # if the loop finished then need to close the form for the user form.CloseNonBlockingForm() - +# Use this context-manager-free version if your read of the form occurs far away in your code +# from the form creation (call to LayoutAndRead) def NonBlockingPeriodicUpdateForm(): # Show a form that's a running counter form = SG.FlexForm('Running Timer', auto_size_text=True) - output_element = SG.Text('',size=(8,2), font=('Helvetica', 20)) + text_element = SG.Text('',size=(10,2), font=('Helvetica', 20), justification='center') form_rows = [[SG.Text('Non blocking GUI with updates')], - [output_element], - [SG.Quit()]] - form.AddRows(form_rows) - form.Show(non_blocking=True) + [text_element], + [SG.T(' ' * 15), SG.Quit()]] + form.LayoutAndRead(form_rows, non_blocking=True) for i in range(1,50000): - output_element.Update(f'{(i/100)/60:02d}:{(i/100)%60:02d}.{i%100:02d}') - rc = form.Refresh() - if rc is None or rc[0] == 'Quit': # if user closed the window using X or clicked Quit button + text_element.Update(f'{(i//100)//60:02d}:{(i//100)%60:02d}.{i%100:02d}') + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': # if user closed the window using X or clicked Quit button break time.sleep(.01) else: # if the loop finished then need to close the form for the user form.CloseNonBlockingForm() - + del(form) def DebugTest(): # SG.Print('How about we print a bunch of random numbers?', , size=(90,40)) for i in range (1,300): SG.Print(i, randint(1, 1000), end='', sep='-') - # SG.PrintClose() - def main(): - SG.SetOptions(border_width=1, element_padding=(4,6), font=("Helvetica", 10), button_color=('white', SG.BLUES[0]), - progress_meter_border_depth=0) - SourceDestFolders() + # SG.SetOptions(border_width=1, font=("Helvetica", 10), button_color=('white', SG.BLUES[0]), slider_border_width=1) + Everything_NoContextManager() Everything() NonBlockingPeriodicUpdateForm_ContextManager() + NonBlockingPeriodicUpdateForm() + ChatBot() + Everything() ProgressMeter() + SourceDestFolders() ChatBot() DebugTest() + SG.MsgBox('Done with all recipes') if __name__ == '__main__': main() diff --git a/PySimpleGUI.py b/PySimpleGUI.py index bcc082fbd..76f53a7b7 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -17,7 +17,7 @@ DEFAULT_AUTOSIZE_TEXT = False DEFAULT_FONT = ("Helvetica", 10) DEFAULT_TEXT_JUSTIFICATION = 'left' -DEFAULT_BORDER_WIDTH = 4 +DEFAULT_BORDER_WIDTH = 1 DEFAULT_AUTOCLOSE_TIME = 3 # time in seconds to show an autoclose form DEFAULT_DEBUG_WINDOW_SIZE = (80,20) MAX_SCROLLED_TEXT_BOX_HEIGHT = 50 @@ -32,7 +32,8 @@ # DEFAULT_BUTTON_COLOR = (YELLOWS[0], PURPLES[0]) # (Text, Background) or (Color "on", Color) as a way to remember # DEFAULT_BUTTON_COLOR = (GREENS[3], TANS[0]) # Foreground, Background (None, None) == System Default # DEFAULT_BUTTON_COLOR = (YELLOWS[0], GREENS[4]) # Foreground, Background (None, None) == System Default -DEFAULT_BUTTON_COLOR = ('white', 'black') # Foreground, Background (None, None) == System Default +DEFAULT_BUTTON_COLOR = ('white', BLUES[0]) # Foreground, Background (None, None) == System Default +# DEFAULT_BUTTON_COLOR = ('white', 'black') # Foreground, Background (None, None) == System Default # DEFAULT_BUTTON_COLOR = (YELLOWS[0], PURPLES[2]) # Foreground, Background (None, None) == System Default DEFAULT_ERROR_BUTTON_COLOR =("#FFFFFF", "#FF0000") DEFAULT_CANCEL_BUTTON_COLOR = (GREENS[3], TANS[0]) @@ -43,21 +44,35 @@ # DEFAULT_PROGRESS_BAR_COLOR = (BLUES[0], BLUES[0]) # a nice green progress bar # DEFAULT_PROGRESS_BAR_COLOR = (PURPLES[1],PURPLES[0]) # a nice purple progress bar DEFAULT_PROGRESS_BAR_SIZE = (35,25) # Size of Progress Bar (characters for length, pixels for width) -DEFAULT_PROGRESS_BAR_BORDER_WIDTH=2 +DEFAULT_PROGRESS_BAR_BORDER_WIDTH=1 DEFAULT_PROGRESS_BAR_RELIEF = tk.SUNKEN DEFAULT_PROGRESS_BAR_STYLE = 'default' DEFAULT_METER_ORIENTATION = 'Horizontal' +DEFAULT_SLIDER_ORIENTATION = 'vertical' +DEFAULT_SLIDER_BORDER_WIDTH=1 +DEFAULT_SLIDER_RELIEF = tk.SUNKEN + +DEFAULT_LISTBOX_SELECT_MODE = tk.SINGLE +SELECT_MODE_MULTIPLE = tk.MULTIPLE +LISTBOX_SELECT_MODE_MULTIPLE = 'multiple' +SELECT_MODE_BROWSE = tk.BROWSE +LISTBOX_SELECT_MODE_BROWSE = 'browse' +SELECT_MODE_EXTENDED = tk.EXTENDED +LISTBOX_SELECT_MODE_EXTENDED = 'extended' +SELECT_MODE_SINGLE = tk.SINGLE +LISTBOX_SELECT_MODE_SINGLE = 'single' + # DEFAULT_METER_ORIENTATION = 'Vertical' # ----====----====----==== Constants the user should NOT f-with ====----====----====----# ThisRow = 555666777 # magic number # Progress Bar Relief Choices # -relief -RAISED='raised' -SUNKEN='sunken' -FLAT='flat' -RIDGE='ridge' -GROOVE='groove' -SOLID = 'solid' +RELIEF_RAISED= 'raised' +RELIEF_SUNKEN= 'sunken' +RELIEF_FLAT= 'flat' +RELIEF_RIDGE= 'ridge' +RELIEF_GROOVE= 'groove' +RELIEF_SOLID = 'solid' PROGRESS_BAR_STYLES = ('default','winnative', 'clam', 'alt', 'classic', 'vista', 'xpnative') # DEFAULT_WINDOW_ICON = '' @@ -99,6 +114,8 @@ def RGB(red,green,blue): return '#%02x%02x%02x' % (red,green,blue) ELEM_TYPE_INPUT_SPIN = 9 ELEM_TYPE_BUTTON = 3 ELEM_TYPE_IMAGE = 30 +ELEM_TYPE_INPUT_SLIDER = 10 +ELEM_TYPE_INPUT_LISTBOX = 11 ELEM_TYPE_OUTPUT = 300 ELEM_TYPE_PROGRESS_BAR = 200 ELEM_TYPE_BLANK = 100 @@ -200,6 +217,37 @@ def __del__(self): pass super().__del__() + +# ---------------------------------------------------------------------- # +# Combo # +# ---------------------------------------------------------------------- # +class Listbox(Element): + + def __init__(self, values, select_mode=None, scale=(None, None), size=(None, None), auto_size_text=None, font=None): + self.Values = values + self.TKListBox = None + if select_mode == LISTBOX_SELECT_MODE_BROWSE: + self.SelectMode = SELECT_MODE_BROWSE + elif select_mode == LISTBOX_SELECT_MODE_EXTENDED: + self.SelectMode = SELECT_MODE_EXTENDED + elif select_mode == LISTBOX_SELECT_MODE_MULTIPLE: + self.SelectMode = SELECT_MODE_MULTIPLE + elif select_mode == LISTBOX_SELECT_MODE_SINGLE: + self.SelectMode = SELECT_MODE_SINGLE + else: + self.SelectMode = DEFAULT_LISTBOX_SELECT_MODE + super().__init__(ELEM_TYPE_INPUT_LISTBOX, scale=scale, size=size, auto_size_text=auto_size_text, font=font) + return + + def __del__(self): + try: + self.TKListBox.__del__() + except: + pass + super().__del__() + + + # ---------------------------------------------------------------------- # # Radio # # ---------------------------------------------------------------------- # @@ -361,11 +409,6 @@ def __del__(self): # New Type of Widget that's a Text Widget in disguise # # ---------------------------------------------------------------------- # class TKOutput(tk.Frame): - ''' Demonstrate python interpreter output in Tkinter Text widget -type python expression in the entry, hit DoIt and see the results -in the text pane.''' - # previous_stderr = None - # previous_stdout = None def __init__(self, parent, width, height, bd): tk.Frame.__init__(self, parent) self.output = tk.Text(parent, width=width, height=height, bd=bd) @@ -552,6 +595,23 @@ def __init__(self, filename, scale=(None, None), size=(None, None), auto_size_te def __del__(self): super().__del__() +# ---------------------------------------------------------------------- # +# Slider # +# ---------------------------------------------------------------------- # +class Slider(Element): + def __init__(self, range=(None,None), default_value=None, orientation=None, border_width=None, relief=None, scale=(None, None), size=(None, None), font=None): + self.TKScale = None + self.Range = (1,10) if range == (None, None) else range + self.DefaultValue = 5 if default_value is None else default_value + self.Orientation = orientation if orientation else DEFAULT_SLIDER_ORIENTATION + self.BorderWidth = border_width if border_width else DEFAULT_SLIDER_BORDER_WIDTH + self.Relief = relief if relief else DEFAULT_SLIDER_RELIEF + super().__init__(ELEM_TYPE_INPUT_SLIDER, scale=scale, size=size, font=font) + return + + def __del__(self): + super().__del__() + # ------------------------------------------------------------------------- # @@ -629,9 +689,17 @@ def AddRows(self,rows): for row in rows: self.AddRow(*row) - def LayoutAndShow(self,rows): + def Layout(self,rows): + self.AddRows(rows) + + def LayoutAndShow(self,rows, non_blocking=False): self.AddRows(rows) - self.Show() + self.Show(non_blocking=non_blocking) + return self.ReturnValues + + def LayoutAndRead(self,rows, non_blocking=False): + self.AddRows(rows) + self.Show(non_blocking=non_blocking) return self.ReturnValues # ------------------------- ShowForm THIS IS IT! ------------------------- # @@ -676,27 +744,41 @@ def AutoCloseAlarmCallback(self): pass def Read(self): - if self.TKrootDestroyed: return None - if not self.TKrootDestroyed and not self.Shown: + if self.TKrootDestroyed: + return None, None + if not self.Shown: self.Show() - elif not self.TKrootDestroyed: + else: self.TKroot.mainloop() if self.RootNeedsDestroying: self.TKroot.destroy() _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 - return(BuildResults(self)) + return BuildResults(self) + + def ReadNonBlocking(self, Message=''): + if self.TKrootDestroyed: + return None, None + if Message: + print(Message) + try: + rc = self.TKroot.update() + except: + self.TKrootDestroyed = True + _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 + return BuildResults(self) + # LEGACY version of ReadNonBlocking def Refresh(self, Message=''): if self.TKrootDestroyed: - return None + return None, None if Message: print(Message) try: - self.TKroot.update() + rc = self.TKroot.update() except: self.TKrootDestroyed = True _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 - return(BuildResults(self)) + return BuildResults(self) def Close(self): try: @@ -874,8 +956,14 @@ def InitializeResults(form): elif element.Type == ELEM_TYPE_INPUT_COMBO: r.append(element.TextInputDefault) return_vals.append(None) + elif element.Type == ELEM_TYPE_INPUT_LISTBOX: + r.append(None) + return_vals.append(None) elif element.Type == ELEM_TYPE_INPUT_SPIN: - r.append(element.TextInputDefault) + r.append(element.DefaultValue) + return_vals.append(None) + elif element.Type == ELEM_TYPE_INPUT_SLIDER: + r.append(element.DefaultValue) return_vals.append(None) results.append(r) form.Results=results @@ -930,6 +1018,11 @@ def BuildResults(form): value=element.TKStringVar.get() results[row_num][col_num] = value input_values.append(value) + elif element.Type == ELEM_TYPE_INPUT_LISTBOX: + items=element.TKListbox.curselection() + value = [element.Values[int(item)] for item in items] + results[row_num][col_num] = value + input_values.append(value) elif element.Type == ELEM_TYPE_INPUT_SPIN: try: value=element.TKStringVar.get() @@ -937,6 +1030,13 @@ def BuildResults(form): value = 0 results[row_num][col_num] = value input_values.append(value) + elif element.Type == ELEM_TYPE_INPUT_SLIDER: + try: + value=element.TKIntVar.get() + except: + value = 0 + results[row_num][col_num] = value + input_values.append(value) elif element.Type == ELEM_TYPE_INPUT_MULTILINE: try: value=element.TKText.get(1.0, tk.END) @@ -947,7 +1047,7 @@ def BuildResults(form): results[row_num][col_num] = value input_values.append(value) - return_value = (button_pressed_text,input_values) + return_value = button_pressed_text,input_values form.ReturnValues = return_value form.ResultsBuilt = True return return_value @@ -957,6 +1057,8 @@ def BuildResults(form): # ===================================== TK CODE STARTS HERE ====================================================== # # ------------------------------------------------------------------------------------------------------------------ # def ConvertFlexToTK(MyFlexForm): + def CharWidthInPixels(): + return tkinter.font.Font().measure('A') # single character width master = MyFlexForm.TKroot # only set title on non-tabbed forms if not MyFlexForm.IsTabbedForm: @@ -1081,6 +1183,18 @@ def ConvertFlexToTK(MyFlexForm): element.TKCombo['values'] = element.Values element.TKCombo.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) element.TKCombo.current(0) + # ------------------------- LISTBOX (Drop Down) element ------------------------- # + elif element_type == ELEM_TYPE_INPUT_LISTBOX: + max_line_len = max([len(str(l)) for l in element.Values]) + if auto_size_text is False: width=element_size[0] + else: width = max_line_len + + element.TKStringVar = tk.StringVar() + element.TKListbox= tk.Listbox(tk_row_frame, height=element_size[1], width=width, selectmode=element.SelectMode, font=font) + for item in element.Values: + element.TKListbox.insert(tk.END, item) + element.TKListbox.selection_set(0,0) + element.TKListbox.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) # ------------------------- INPUT MULTI LINE element ------------------------- # elif element_type == ELEM_TYPE_INPUT_MULTILINE: default_text = element.DefaultText @@ -1162,6 +1276,21 @@ def ConvertFlexToTK(MyFlexForm): tktext_label.image = photo # tktext_label.configure(anchor=tk.NW, image=photo) tktext_label.pack(side=tk.LEFT) + # ------------------------- SLIDER Box element ------------------------- # + elif element_type == ELEM_TYPE_INPUT_SLIDER: + slider_length = element_size[0] * CharWidthInPixels() + slider_width = element_size[1] + element.TKIntVar = tk.IntVar() + element.TKIntVar.set(element.DefaultValue) + if element.Orientation[0] == 'v': + range_from = element.Range[1] + range_to = element.Range[0] + else: + range_from = element.Range[0] + range_to = element.Range[1] + tkscale = tk.Scale(tk_row_frame, orient=element.Orientation, variable=element.TKIntVar, from_=range_from, to_=range_to, length=slider_length, width=slider_width , bd=element.BorderWidth, relief=element.Relief, font=font) + # tktext_label.configure(anchor=tk.NW, image=photo) + tkscale.pack(side=tk.LEFT) #............................DONE WITH ROW pack the row of widgets ..........................# # done with row, pack the row of widgets tk_row_frame.grid(row=row_num+2, sticky=tk.W, padx=DEFAULT_MARGINS[0]) @@ -1520,7 +1649,6 @@ def ProgressMeterUpdate(bar, value, *args): if bar.BarExpired: return False message, w, h = ConvertArgsToSingleString(*args) - bar.TextToDisplay = message bar.CurrentValue = value rc = bar.UpdateBar(value) @@ -1529,8 +1657,8 @@ def ProgressMeterUpdate(bar, value, *args): bar.ParentForm.Close() if bar.ParentForm.RootNeedsDestroying: try: - bar.ParentForm.TKroot.destroy() _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 + bar.ParentForm.TKroot.destroy() except: pass bar.ParentForm.RootNeedsDestroying = False bar.ParentForm.__del__() @@ -1841,9 +1969,12 @@ def SetGlobalIcon(icon): # ============================== SetOptions =========# # Sets the icon to be used by default # # ===================================================# -def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), margins=(None,None), element_padding=(None,None), - auto_size_text=None, font=None, border_width=None, autoclose_time=None, message_box_line_width=None, +def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), margins=(None,None), + element_padding=(None,None),auto_size_text=None, font=None, border_width=None, + slider_border_width=None, slider_relief=None, slider_orientation=None, + autoclose_time=None, message_box_line_width=None, progress_meter_border_depth=None, text_justification=None, debug_win_size=(None,None)): + global DEFAULT_ELEMENT_SIZE global DEFAULT_MARGINS # Margins for each LEFT/RIGHT margin is first term global DEFAULT_ELEMENT_PADDING # Padding between elements (row, col) in pixels @@ -1856,6 +1987,9 @@ def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), ma global DEFAULT_PROGRESS_BAR_BORDER_WIDTH global DEFAULT_TEXT_JUSTIFICATION global DEFAULT_DEBUG_WINDOW_SIZE + global DEFAULT_SLIDER_BORDER_WIDTH + global DEFAULT_SLIDER_RELIEF + global DEFAULT_SLIDER_ORIENTATION global _my_windows if icon: @@ -1896,6 +2030,15 @@ def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), ma if progress_meter_border_depth != None: DEFAULT_PROGRESS_BAR_BORDER_WIDTH = progress_meter_border_depth + if slider_border_width != None: + DEFAULT_SLIDER_BORDER_WIDTH = slider_border_width + + if slider_orientation != None: + DEFAULT_SLIDER_ORIENTATION = slider_orientation + + if slider_relief != None: + DEFAULT_SLIDER_RELIEF = slider_relief + if text_justification != None: DEFAULT_TEXT_JUSTIFICATION = text_justification @@ -1904,12 +2047,21 @@ def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), ma return True - - - -# ============================== sprint ======# +# ============================== sprint ======#fddddddddddddddddddddddd # Is identical to the Scrolled Text Box # # Provides a crude 'print' mechanism but in a # # GUI environment # # ============================================# sprint=ScrolledTextBox + +# Converts an object's contents into a nice printable string. Great for dumping debug data +def ObjToString_old(obj): + return str(obj.__class__) + '\n' + '\n'.join( + (repr(item) + ' = ' + repr(obj.__dict__[item]) for item in sorted(obj.__dict__))) + +def ObjToString(obj, extra=' '): + return str(obj.__class__) + '\n' + '\n'.join( + (extra + (str(item) + ' = ' + + (ObjToString(obj.__dict__[item], extra + ' ') if hasattr(obj.__dict__[item], '__dict__') else str( + obj.__dict__[item]))) + for item in sorted(obj.__dict__))) \ No newline at end of file diff --git a/readme.md b/readme.md index 199845992..79abcc07e 100644 --- a/readme.md +++ b/readme.md @@ -2,11 +2,12 @@ [![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 # PySimpleGUI - -This really is a simple GUI, but also powerfully customizable. + (Ver 2.3) + +This really is a simple GUI, but also powerfully customizable. + + import PySimpleGUI as SG - import PySimpleGUI as SG - SG.MsgBox('My Message Box', 'This is the shortest GUI program ever!') ![snap0102](https://user-images.githubusercontent.com/13696193/42781058-1d28d9fa-8913-11e8-847e-5c2afc16ca4c.jpg) @@ -14,10 +15,10 @@ This really is a simple GUI, but also powerfully customizable. Add a Progress Meter to your code with ONE LINE of code EasyProgressMeter('My meter title', current_value, max value) - + ![progress meter 2](https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg) -I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? +I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? There are a number of 'easy to use' Python GUIs, but they're **very** limiting. PySimpleGUI takes the best of packages like `EasyGUI`(no longer maintained) and `WxSimpleGUI` (a great package, but limited). The primary difference between these and PySimpleGUI is that in addition to getting those simple Message Boxes you also get the ability to make your own forms that are highly customizeable. Don't like the standard Message Box? Then make your own! @@ -28,30 +29,30 @@ GUI Packages with more functionality, like QT and WxPython, require configuring With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. The `PySimpleGUI` solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? - - Features of PySimpleGUI include: - Text - Single Line Input - Buttons including these types: + + Features of PySimpleGUI include: + Text + Single Line Input + Buttons including these types: File Browse Folder Browse Non-closing return - Close form - Checkboxes - Radio Buttons - Icons - Multi-line Text Input - Scroll-able Output - Images - Progress Bar - Async/Non-Blocking Windows + Close form + Checkboxes + Radio Buttons + Icons + Multi-line Text Input + Scroll-able Output + Images + Progress Bar + Async/Non-Blocking Windows Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling window + Persistent Windows + Redirect Python Output/Errors to scrolling window 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) Single-Line-Of-Coide Proress Bar & Debug Print - + An example of many widgets used on a single form. A little further down you'll find the FIFTEEN lines of code required to create this complex form. ![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) @@ -60,41 +61,41 @@ An example of many widgets used on a single form. A little further down you'll ### Design Goals > Copy, Paste, Run. -`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the SDK to visually match what's on the screen. +`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the SDK to visually match what's on the screen. Be Pythonic... Python's lists in particular worked out really well: - - Forms are represented as Python lists. + - Forms are represented as Python lists. - A form is a list of rows - A row is a list of elements - Return values are a list - Each Elements is specified by names such as Text, Button, Checkbox, etc. + Each Elements is specified by names such as Text, Button, Checkbox, etc. Some elements have shortcuts, meant to make it easy on the programmer who will write less code using them. Rather than writing calling `Button`, with `button_name = "Submit"` will create a button with the text 'Submit' on it, Other examples include shortening the name of the function. `Text` is shorted to `Txt` or `T`. See each API call for the shortcuts. ----- -## Getting Started with PySimpleGUI - -### Installing - - pip install PySimpleGUI - or -Simply download the file - PySimpleGUI.py and import it into your code - - -### Prerequisites - -Python 3 -tkinter - -Should run on all Python platforms that have tkinter running on them. Has been thoroughly tested on Windows. While not tested elsewhere, should work on Linux, Mac, Pi, etc. - +## Getting Started with PySimpleGUI + +### Installing + + pip install PySimpleGUI + or +Simply download the file - PySimpleGUI.py and import it into your code + + +### Prerequisites + +Python 3 +tkinter + +Should run on all Python platforms that have tkinter running on them. Has been thoroughly tested on Windows. While not tested elsewhere, should work on Linux, Mac, Pi, etc. + ### Using To use in your code, simply import.... - `import PySimpleGUI as SG` + `import PySimpleGUI as SG` -Then use either "high level" API calls or build your own forms. +Then use either "high level" API calls or build your own forms. SG.MsgBox('This is my first message box') ![snap0103](https://user-images.githubusercontent.com/13696193/42844641-a04bb798-89e1-11e8-8a37-50ddd9905772.jpg) @@ -103,70 +104,70 @@ Yes, it's just that easy to have a window appear on the screen using Python. Wi --- ## APIs - -PySimpleGUI can be broken down into 2 types of API's: - * High Level single call functions - * Custom form functions - + +PySimpleGUI can be broken down into 2 types of API's: + * High Level single call functions + * Custom form functions + ### Python Language Features There are a couple of Python language features that PySimpleGUI utilizes heavily that should be understood first... - * Variable number of arguments to a function call + * Variable number of arguments to a function call * Optional parameters to a function call - + #### Variable Number of Arguments The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. - + SG.MsgBox('Variable number of parameters example', var1, var2, "etc") Each new item begins on a new line in the Message Box ![snap0104](https://user-images.githubusercontent.com/13696193/42844739-ebea22ac-89e1-11e8-8dd1-e61441325701.jpg) - + #### Optional Parameters to a Function Call - + This feature of the Python language is utilized ***heavily*** as a method of customizing forms and form Elements. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. -Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't *have* to be specified on each and every call. +Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't *have* to be specified on each and every call. - def MsgBox(*args, - button_color=None, - button_type=MSG_BOX_OK, - auto_close=False, - auto_close_duration=None, - icon=DEFAULT_WINDOW_ICON, + def MsgBox(*args, + button_color=None, + button_type=MSG_BOX_OK, + auto_close=False, + auto_close_duration=None, + icon=DEFAULT_WINDOW_ICON, line_width=MESSAGE_BOX_LINE_WIDTH, font=None): If the caller wanted to change the button color to be black on yellow, the call would look something like this: - SG.MsgBox('This box has a custom button color', + SG.MsgBox('This box has a custom button color', button_color=('black', 'yellow')) - + ![snap0105](https://user-images.githubusercontent.com/13696193/42844830-2d7e8b9a-89e2-11e8-8ef4-5af9e36f30f3.jpg) --- -### High Level API Calls - -The classic "input a value, print result" example. -Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. -This code prompts user to input a line of text and then displays that text in a messages box: - - import PySimpleGUI_local as SG - - rc = SG.GetTextBox('Title', 'Please input something') - SG.MsgBox('Results', 'The value returned from GetTextBox', rc) - -![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) - -![MsgBox](https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg) - +### High Level API Calls + +The classic "input a value, print result" example. +Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. +This code prompts user to input a line of text and then displays that text in a messages box: + + import PySimpleGUI_local as SG + + rc = SG.GetTextBox('Title', 'Please input something') + SG.MsgBox('Results', 'The value returned from GetTextBox', rc) + +![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) + +![MsgBox](https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg) + #### Message Boxes In addition to MsgBox, you'll find a several API calls that are shortcuts to common messages boxes. You can achieve similar results by calling MsgBox with the correct parameters. @@ -175,7 +176,7 @@ The differences tend to be the number and types of buttons. Here are the calls import PySimpleGUI as SG `SG.MsgBoxOK('This is an OK MsgBox')` - + ![msgboxok](https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg) SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') @@ -209,7 +210,7 @@ This becomes a debug print of sorts that will route to a scrolled window. There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. If you need only 1 value, then perhaps one of these high level functions will work. - GetTextBox - - GetFileBox + - GetFileBox - GetFolderBox `submit_clicked, value = SG.GetTextBox('Title', 'Please enter anything')` @@ -241,7 +242,7 @@ We all have loops in our code. 'Isn't it joyful waiting, watching a counter scr Here's the one-line Progress Meter in action! - for i in range(1,10000): + for i in range(1,10000): SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') That line of code resulted in this window popping up and updating. @@ -249,10 +250,10 @@ That line of code resulted in this window popping up and updating. ![progress meter 5](https://user-images.githubusercontent.com/13696193/42696912-a5c958b8-8687-11e8-9a7d-a390a465407a.jpg) A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. -With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. +With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. if not SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message'): - break + break ***Be sure and add one to your loop counter*** so that your counter goes from 1 to the max value. If you do not add one, your counter will never hit the max value. Instead it will go from 0 to max-1. @@ -271,17 +272,17 @@ It's both not enjoyable nor helpful to immediately jump into tweaking each and e # Copy these design patterns! ## Pattern 1 - With Context Manager - with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], - [SG.InputText(), SG.FileBrowse()], - [SG.Submit(), SG.Cancel()]] + with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + [SG.InputText(), SG.FileBrowse()], + [SG.Submit(), SG.Cancel()]] button, (source_filename, ) = form.LayoutAndShow(form_rows) ## Pattern 2 - No Context Manager - form = SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], - [SG.InputText(), SG.FileBrowse()], + form = SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + [SG.InputText(), SG.FileBrowse()], [SG.Submit(), SG.Cancel()]] button, (source_filename,) = form.LayoutAndShow(form_rows) @@ -300,13 +301,13 @@ You will use these design patterns or code templates for all of your "normal" (b Going through each line of code in the above form will help explain how to use this design patter. Copy, modify and run it! - with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: -This creates a new form, storing it in the variable `form`. + with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: +This creates a new form, storing it in the variable `form`. - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. - [SG.InputText(), SG.FileBrowse()], + [SG.InputText(), SG.FileBrowse()], Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. [SG.Submit(), SG.Cancel()]] @@ -322,67 +323,75 @@ This is the code that **displays** the form, collects the information and return ## Return values - Return information from FlexForm, SG's primary form builder interface, is in this format: - - (button, (value1, value2, ...)) - + Return information from FlexForm, SG's primary form builder interface, is in this format: + + (button, (value1, value2, ...)) + Each of the Elements that are Input Elements will have a value in the list of return values. You can unpack your GUI directly into the variables you want to use. (button, (filename, folder1, folder2, should_overwrite) = form.LayoutAndShow(form_rows) - -If you have a SINGLE value being returned, it is written this way: - + +If you have a SINGLE value being returned, it is written this way: + (button, (value1,)) = form.LayoutAndShow(form_rows) Another way of parsing the return values is to store the list of values into a variable representing the list of values. - (button, (value_list)) = form.LayoutAndShow(form_rows) + (button, (value_list)) = form.LayoutAndShow(form_rows) value1 = value_list[0] value2 = value_list[1] ... - + --- ## All Widgets / Elements This code utilizes as many of the elements in one form as possible. - with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: - layout = [[Text('Here they all are!', size=(30,1), font=("Helvetica", 25), text_color='red')], - [Text('Here is some text with font sizing', font=("Helvetica", 15))], - [InputText()], - [Checkbox('My first checkbox!'), Checkbox('My second checkbox!', default=True)], - [Radio('My first Radio!', "RADIO1", default=True), Radio('My second checkbox!', "RADIO1")], - [Multiline(DefaultText='This is the DEFAULT text should you decide not to type anything', scale=(2, 10))], - [InputCombo(['choice 1', 'choice 2'], size=(20, 3))], - [Text('_' * 90, size=(60, 1))], - [Text('Choose Source and Destination Folders', size=(35,1))], - [Text('Source Folder', size=(15, 1), auto_size_text=False), InputText('Source'), FolderBrowse()], - [Text('Destination Folder', size=(15, 1), auto_size_text=False), InputText('Dest'), FolderBrowse()], - [SimpleButton('Your Button with any text you want')], - [SimpleButton('Big Text', size=(12,1), font=("Helvetica", 20))], - [Submit(), Cancel()]] - - (button, (values)) = form.LayoutAndShow(layout) - - MsgBox('Results', 'You clicked {}'.format(button),'The values returned from form', values , font = ("Helvetica", 15)) + with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [SG.Text('Here is some text.... and a place to enter text')], + [SG.InputText()], + [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], + [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], + [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [SG.Text('_' * 100, size=(70, 1))], + [SG.Text('Choose Source and Destination Folders', size=(35, 1))], + [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], + [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), + SG.FolderBrowse()], + [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + + MsgBox('Results', 'You clicked {}'.format(button),'The values returned from form', values , font = ("Helvetica", 15)) This is a somewhat complex form with quite a bit of custom sizing to make things line up well. This is code you only have to write once. When looking at the code, remember that what you're seeing is a list of lists. Each row contains a list of Graphical Elements that are used to create the form. -![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) +![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) Clicking the Submit button caused the form call to return. The call to MsgBox resulted in this dialog box. -![results](https://user-images.githubusercontent.com/13696193/42604952-502f64e6-8543-11e8-8045-bc10d38c5fd4.jpg) +![results 2](https://user-images.githubusercontent.com/13696193/43097502-44e3ed32-8e8a-11e8-9a51-2b8af0b1a682.jpg) + (button, (values)) = form.LayoutAndShow(layout) **`Note, button value can be None`**. The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. -You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. +You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. --- # Building Custom Forms You will find it much easier to write code using PySimpleGUI if you use an IDE such as PyCharm. The features that show you documentation about the API call you are making will help you determine which settings you want to change, if any. In PyCharm, two commands are particularly helpful. - Control-Q (when cursor is on function name) brings up a box with the function definition + Control-Q (when cursor is on function name) brings up a box with the function definition Control-P (when cursor inside function call "()") shows a list of parameters and their default values ## Synchronous Forms @@ -396,11 +405,11 @@ NON-BLOCKING form call: ### Beginning a Form The first step is to create the form object using the desired form customization. - with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: + with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: This is the definition of the FlexForm object: - def FlexForm(title, + def FlexForm(title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=DEFAULT_AUTOSIZE_TEXT, scale=(None, None), @@ -412,7 +421,7 @@ This is the definition of the FlexForm object: auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON): - + Parameter Descriptions. You will find these same parameters specified for each `Element` and some of them in `Row` specifications. The `Element` specified value will take precedence over the `Row` and `Form` values. default_element_size - Size of elements in form in characters (width, height) @@ -437,6 +446,10 @@ Sizes can be set at the element level, or in this case, the size variables apply In addition to `size` there is a `scale` option. `scale` will take the Element's size and scale it up or down depending on the scale value. `scale=(1,1)` doesn't change the Element's size. `scale=(2,1)` will set the Element's size to be twice as wide as the size setting. +There are a couple of widgets where one of the size values is in pixels rather than characters. This is true for Progress Meters and Sliders. The second parameter is the 'height' in pixels. + + + #### FlexForm - form-level variables overview A summary of the variables that can be changed when a FlexForm is created @@ -457,22 +470,24 @@ A summary of the variables that can be changed when a FlexForm is created ## Elements "Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. - Text - Single Line Input - Buttons including these types: + Text + Single Line Input + Buttons including these types: File Browse Folder Browse Non-closing return - Close form - Checkboxes - Radio Buttons - Multi-line Text Input - Scroll-able Output - Progress Bar - Async/Non-Blocking Windows + Close form + Checkboxes + Radio Buttons + Listbox + Slider + Multi-line Text Input + Scroll-able Output + Progress Bar + Async/Non-Blocking Windows Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling Window + Persistent Windows + Redirect Python Output/Errors to scrolling Window "Higher level" APIs (e.g. MessageBox, YesNobox, ...) @@ -484,15 +499,15 @@ Building a form is simply making lists of Elements. Each list is a row in the o The code is a crude representation of the GUI, laid out in text. #### Text Element - layout = [[SG.Text('This is what a Text Element looks like')]] + layout = [[SG.Text('This is what a Text Element looks like')]] + - ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. - Text(Text, + Text(Text, scale=(None, None), size=(None, None), auto_size_text=None, @@ -568,7 +583,7 @@ Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. ### Input Elements These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. - + #### Text Input Element layout = [[SG.InputText('Default text')]] @@ -594,10 +609,10 @@ Shorthand functions that are equivalent to `InputText` are `Input` and `In` Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. layout = [[SG.InputCombo(['choice 1', 'choice 2'])]] - + ![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) - InputCombo(values, + InputCombo(values, scale=(None, None), size=(None, None), auto_size_text=None) @@ -608,6 +623,68 @@ Also known as a drop-down list. Only required parameter is the list of choices. size - (width, height) of element in characters auto_size_text - Bool. True if size should fit the text length +#### Listbox Element +The standard listbox like you'll find in most GUIs. Note that the return values from this element will be a ***list of results, not a single result***. This is because the user can select more than 1 item from the list (if you set the right mode). + + Listbox(values, + select_mode=None, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None) +. + + values - Choices to be displayed. List of strings + select_mode - Defines how to list is to operate. + Choices include constants or strings: + Constants version: + LISTBOX_SELECT_MODE_BROWSE + LISTBOX_SELECT_MODE_EXTENDED + LISTBOX_SELECT_MODE_MULTIPLE + LISTBOX_SELECT_MODE_SINGLE - the default + Strings version: + 'browse' + 'extended' + 'multiple' + 'single' + scale - Amount to scale size by + size - (width, height) of element in characters + auto_size_text - Bool. True if size should fit the text length + +The `select_mode` option can be a string or a constant value defined as a variable. Generally speaking strings are used for these kinds of options. + +#### Slider Element +Sliders have a couple of slider-specific settings as well as appearance settings. Examples include the `orientation` and `range` settings. + + Slider(range=(None,None), + default_value=None, + orientation=None, + border_width=None, + relief=None, + scale=(None, None), + size=(None, None), + font=None): +. + + range - (min, max) slider's range + default_value - default setting (within range) + orientation - 'horizontal' or 'vertical' ('h' or 'v' work) + border_width - how deep the widget looks + relief - relief style. Values are same as progress meter relief values. Can be a constant or a string: + RELIEF_RAISED= 'raised' + RELIEF_SUNKEN= 'sunken' + RELIEF_FLAT= 'flat' + RELIEF_RIDGE= 'ridge' + RELIEF_GROOVE= 'groove' + RELIEF_SOLID = 'solid' + scale - Amount to scale size by + size - (width, height) of element in characters + auto_size_text - Bool. True if size should fit the text + + + + + #### Radio Button Element Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. @@ -635,7 +712,7 @@ Creates one radio button that is assigned to a group of radio buttons. Only 1 o #### Checkbox Element -Checkbox elements are like Radio Button elements. They return a bool indicating whether or not they are checked. +Checkbox elements are like Radio Button elements. They return a bool indicating whether or not they are checked. layout = [[SG.Checkbox('My first Checkbox!', default=True), SG.Checkbox('My second Checkbox!')]] @@ -665,7 +742,7 @@ An up/down spinner control. The valid values are passed in as a list. ![spin element](https://user-images.githubusercontent.com/13696193/42717231-8ddb51d4-86cd-11e8-827a-75f2237477fa.jpg) - Spin(values, + Spin(values, intiial_value=None, scale=(None, None), size=(None, None), @@ -679,7 +756,7 @@ An up/down spinner control. The valid values are passed in as a list. size - (width, height) size of element in characters auto_size_text - Bool. True if should size width to fit text font - Font type and size for text display - + #### Button Element Buttons are the most important element of all! They cause the majority of the action to happen. After all, it's a button press that will get you out of a form, whether it but Submit or Cancel, one way or another a button is involved in all forms. The only exception is to this is when the user closes the window using the "X" in the upper corner which means no button was involved. @@ -691,9 +768,9 @@ The Types of buttons include: Close Form - Normal buttons like Submit, Cancel, Yes, No, etc, are "Close Form" buttons. They cause the input values to be read and then the form is closed, returning the values to the caller. - -Folder Browse - When clicked a folder browse dialog box is opened. The results of the Folder Browse dialog box are written into one of the input fields of the form. - + +Folder Browse - When clicked a folder browse dialog box is opened. The results of the Folder Browse dialog box are written into one of the input fields of the form. + File Browse - Same as the Folder Browse except rather than choosing a folder, a single file is chosen. Read Form - This is an async form button that will read a snapshot of all of the input fields, but does not close the form after it's clicked. @@ -706,7 +783,7 @@ While it's possible to build forms using the Button Element directly, you should auto_size_text=None, button_color=None, font=None) - + Pre-made buttons include: OK @@ -722,7 +799,7 @@ Pre-made buttons include: ![ok cancel](https://user-images.githubusercontent.com/13696193/42717733-1803f584-86d1-11e8-9223-36b782971b9f.jpg) -The FileBrowse and FolderBrowse buttons both fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. +The FileBrowse and FolderBrowse buttons both fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. The default value for `Target` is `(ThisRow, -1)`. ThisRow is a special value that tells the GUI to use the same row as the button. The Y-value of -1 means the field one value to the left of the button. For a File or Folder Browse button, the field that it fills are generally to the left of the button is most cases. @@ -736,30 +813,30 @@ The `InputText` element is located at (1,0)... row 1, column 0. The `Browse` bu Target = (-1,0) The code for the entire form could be: - layout = [[SG.T('Source Folder')], - [SG.In()], + layout = [[SG.T('Source Folder')], + [SG.In()], [SG.FolderBrowse(Target=(-1,0)), SG.OK()]] **Custom Buttons** If you want to define your own button, you will generally do this with the Button Element `SimpleButton`. - + layout = [[SG.SimpleButton('My Button')]] ![singlebutton](https://user-images.githubusercontent.com/13696193/42718281-9453deca-86d5-11e8-83c7-4b6d33720858.jpg) -All buttons can have their text changed by changing the `button_text` variable. +All buttons can have their text changed by changing the `button_text` variable. **File Types** -The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is +The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is FileTypes=(("ALL Files", "*.*"),) - + This code produces a form where the Browse button only shows files of type .TXT layout = [[SG.In() ,SG.FileBrowse(file_types=(("Text Files", "*.txt"),))]] ***The ENTER key*** - The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. + The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. --- @@ -770,7 +847,7 @@ The **easiest** way to get progress meters into your code is to use the `EasyPro You've already seen EasyProgressMeter calls presented earlier in this readme. SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') - + The return value for `EasyProgressMeter` is: `True` if meter updated correctly `False` if user clicked the Cancel button, closed the form, or vale reached the max value. @@ -779,25 +856,25 @@ If you want a bit more customization of your meter, then you can go up 1 level a You setup the progress meter by calling - my_meter = ProgressMeter(title, + my_meter = ProgressMeter(title, max_value, *args, - orientantion=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, + orientantion=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) Then to update the bar within your loop return_code = ProgressMeterUpdate(my_meter, - value, + value, *args): Putting it all together you get this design pattern - my_meter = SG.ProgressMeter('Meter Title', 100000, orentation='Vert') - - for i in range(0, 100000): + my_meter = SG.ProgressMeter('Meter Title', 100000, orentation='Vert') + + for i in range(0, 100000): SG.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') @@ -812,27 +889,31 @@ The Output Element is a re-direction of Stdout. Anything "printed" will be disp Here's a complete solution for a chat-window using an Async form with an Output Element - import PySimpleGUI as g - - with g.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: - form.AddRow(g.Text('This is where standard out is being routed', size=[40,1])) - form.AddRow(g.Output(size=(80, 20))) - form.AddRow(g.Multiline(size=(70, 5), enter_submits=True), g.ReadFormButton('SEND', button_color=(g.YELLOWS[0], g.BLUES[0])), g.SimpleButton('EXIT', button_color=(g.YELLOWS[0], g.GREENS[0]))) - - # ---===--- Loop taking in user input and printing it --- # - while True: - (button, value) = form.Read() - if button == 'SEND': - print(value) - else: - print('Exiting the form now') - break - + import PySimpleGUI as SG + # Blocking form that doesn't close + def ChatBot(): + with SG.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + layout = [[(SG.Text('This is where standard out is being routed', size=[40, 1]))], + [SG.Output(size=(80, 20))], + [SG.Multiline(size=(70, 5), enter_submits=True), SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))]] + # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form + # if you call LayoutAndRead from here, then you will miss the first button click + form.Layout(layout) + # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # + while True: + button, value = form.Read() + if button == 'SEND': + print(value) + else: + break + + + ## Tabbed Forms Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format - results = ShowTabbedForm('Title for the form', + results = ShowTabbedForm('Title for the form', (form,layout,'Tab 1 label'), (form2,layout2, 'Tab 2 label')) @@ -842,21 +923,26 @@ Each of the tabs of the form is in fact a form. The same steps are taken to cre **Global Settings** Let's have some fun customizing! Make PySimpleGUI look the way you want it to look. You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. - SetOptions(icon=None, + SetOptions(icon=None, button_color=(None,None), - element_size=(None,None), - margins=(None,None), - element_padding=(None,None), + element_size=(None,None), + margins=(None,None), + element_padding=(None,None), auto_size_text=None, - font=None, border_width=None, - autoclose_time=None, - message_box_line_width=None, + font=None, + border_width=None, + slider_border_width=None, + slider_relief=None, + slider_orientation=None, + autoclose_time=None, + message_box_line_width=None, progress_meter_border_depth=None, - text_justification=None): + text_justification=None, + debug_win_size=(None,None): Explanation of parameters - icon - filename of icon used for taskbar and title bar + icon - filename of icon used for taskbar and title bar button_color - button color (foreground, background) element_size - element size (width, height) in characters margins - tkinter margins around outsize @@ -864,12 +950,16 @@ Explanation of parameters auto_size_text - autosize the elements to fit their text font - font used for elements border_width - amount of bezel or border around sunken or raised elements + slider_border_width - changes the way sliders look + slider_relief - changes the way sliders look + slider_orientation - changes orientation of slider autoclose_time - time in seconds for autoclose boxes message_box_line_width - number of characers in a line of text in message boxes progress_meter_border_depth - amount of border around raised or lowered progress meters text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' + debug_win_size - size of the Print output window + - These settings apply to all forms `SetOptions`. The Row options and Element options will take precedence over these settings. Settings can be thought of as levels of settings with the Form-level being the highest and the Element-level the lowest. Thus the levels are: - Form level @@ -878,8 +968,8 @@ These settings apply to all forms `SetOptions`. The Row options and Element opt Each lower level overrides the settings of the higher level -## Asynchronous (Non-Blocking) Forms -So you want to be a wizard do ya? Well go boldly! While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. With asynchronous forms the form is shown, user input is read, but your code keeps right on chugging. YOUR responsibility is to call `PySimpleGUI.refresh` on a periodic basis. Once a second or more will produce a reasonably snappy GUI. +## Asynchronous (Non-Blocking) Forms +So you want to be a wizard do ya? Well go boldly! While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. With asynchronous forms the form is shown, user input is read, but your code keeps right on chugging. YOUR responsibility is to call `PySimpleGUI.ReadNonBlocking` on a periodic basis. Once a second or more will produce a reasonably snappy GUI. When do you use a non-blocking form? A couple of examples are * A media file player like an MP3 player @@ -887,11 +977,11 @@ When do you use a non-blocking form? A couple of examples are * Progress Meters - when you want to make your own progress meters * Output using print to a scrolled text element. Good for debugging. -Word of warning... version 2.2, the currently released, and upcoming version 2.3 differ in the return code for the `Refresh` call. Previously the function returned 2 values, except when the form is closed using the "X" which returned a single value of `None`. The *new* way is that Refresh always returns 2 values. If the user closed the form with the "X" then the return values will be None, None. You will want to key off the second value to catch this case. +Word of warning... version 2.2, the currently released, and upcoming version 2.3 differ in the return code for the `ReadNonBlocking` call. Previously the function returned 2 values, except when the form is closed using the "X" which returned a single value of `None`. The *new* way is that `ReadNonBlocking` always returns 2 values. If the user closed the form with the "X" then the return values will be None, None. You will want to key off the second value to catch this case. The proper code to check if the user has exited the form will be a polling-loop that looks something like this: while True: - button, values = form.Refresh() + button, values = form.ReadNonBlocking() if values is None or button == 'Quit': break @@ -906,38 +996,38 @@ Setup Periodic refresh - form.Refresh() + form.ReadNonBlocking() If you need to close the form form.CloseNonBlockingForm() -Rather than the usual `form.LayoutAndShow()` call, we're manually adding the rows (doing the layout) and then showing the form. After the form is shown, you simply call `form.Refresh()` every now and then. +Rather than the usual `form.LayoutAndShow()` call, we're manually adding the rows (doing the layout) and then showing the form. After the form is shown, you simply call `form.ReadNonBlocking()` every now and then. When you are ready to close the form (assuming the form wasn't closed by the user or a button click) you simply call `form.CloseNonBlockingForm()` **Example - Running timer that updates** We're going to make a form and update one of the elements of that form every .01 seconds. Here's the entire code to do that. - with SG.FlexForm('Running Timer', auto_size_text=True) as form: - output_element = SG.Text('', size=(8, 2), font=('Helvetica', 20)) - form_rows = [[SG.Text('Non-blocking GUI with updates')], - [output_element], - [SG.SimpleButton('Quit')]] - - form.AddRows(form_rows) - form.Show(non_blocking=True) - for i in range(1, 100): - output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i/100), 60), i%100)) - button, values = form.Refresh() - if values is None or button == 'Quit': - break - time.sleep(.01) - else: + with SG.FlexForm('Running Timer', auto_size_text=True) as form: + output_element = SG.Text('', size=(8, 2), font=('Helvetica', 20)) + form_rows = [[SG.Text('Non-blocking GUI with updates')], + [output_element], + [SG.SimpleButton('Quit')]] + + form.AddRows(form_rows) + form.Show(non_blocking=True) + for i in range(1, 100): + output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i/100), 60), i%100)) + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + time.sleep(.01) + else: form.CloseNonBlockingForm() - + What we have here is the same sequence of function calls as in the description. Get a form, add rows to it, show the form, and then refresh it every now and then. -The new thing in this example is the call use of the Update method for the Text Element. The first thing we do inside the loop is "update" the text element that we made earlier. This changes the value of the text field on the form. The new value will be displayed when `form.Refresh()` is called. +The new thing in this example is the call use of the Update method for the Text Element. The first thing we do inside the loop is "update" the text element that we made earlier. This changes the value of the text field on the form. The new value will be displayed when `form.ReadNonBlocking()` is called. Note the `else` statement on the for loop. This is needed because we're about to exit the loop while the form is still open. The user has not closed the form using the X nor a button so it's up to the caller to close the form using `CloseNonBlockingForm`. @@ -954,19 +1044,19 @@ Use the example programs as a starting basis for your GUI. Copy, paste, modify `Demo Recipes.py` - Three sample forms including an asynchronous form -`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. +`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. ## Fun Stuff Here are some things to try if you're bored or want to further customize **Random colors** To set a button or text to a random color, use the string `'random'` as the color value. You can also call `PySimpleGUI.GetRandomColor`. -To get a random color pair call `PySimpleGUI.GetRandomColorPair`. This returns a tuple containing a random color and +To get a random color pair call `PySimpleGUI.GetRandomColorPair`. This returns a tuple containing a random color and that color's compliment. sprint **sprint** -Call `sprint` with as many parameters as you want and it'll print them all out in a `ScrolledTextBox`. This is simply a function pointing to `PySimpleGUI.ScrolledTextBox`. +Call `sprint` with as many parameters as you want and it'll print them all out in a `ScrolledTextBox`. This is simply a function pointing to `PySimpleGUI.ScrolledTextBox`. --- # Known Issues @@ -980,48 +1070,63 @@ While not an "issue" this is a ***stern warning*** **EasyPrint** - EasyPrint is a new feature that's pretty awesome. You print and the output goes to a window, with a scroll bar, that you can copy and paste from. Being a new feature, it's got some potential problems. There are known interaction problems with other GUI windows. For example, closing a Print window can also close other windows you have open. For now, don't close your debug print window until other windows are closed too. -## Contributing - +## Contributing + A MikeTheWatchGuy production... entirely responsible for this code.... unless it causes you trouble in which case I'm not at all responsible. - -## Versioning -|Version | Description | + +## Versions +|Version | Description | |--|--| | 1.0.9 | July 10, 2018 - Initial Release | | 1.0.21 | July 13, 2018 - Readme updates | | 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case | 2.1.1 | July 18, 2018 - Global settings exposed, fixes | 2.2.0| July 20, 2018 - Image Elements, Print output -| 2.3.0 | July XX, 2018 - Changed form.Read return codes, Slider Elements, Listbox element - -## Code Condition +| 2.3.0 | July XX, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. + +### Release Notes +2.3 - Sliders, Listbox's and Image elements (oh my!) This Readme is being updated with Listbox and Image elements. If you want to use them, they behave as one would expect. Note use of pixels in some parameters. + +If using Progress Meters, avoid cancelling them when you have another window open. It could lead to future windows being blank. It's being worked on. + +### Upcoming +Make suggestions people! Future release features + +Button images. Ability to replace boring rectangular buttons with your own images. - Make it run - Make it right +Columns. How multiple columns would be specified in the SDK interface are still being designed. + +Progress Meters - Replace custom meter with tkinter meter. + + +## Code Condition + + Make it run + Make it right Make it fast -It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor for PEP 8 compliance. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. +It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor for PEP 8 compliance. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. -While the internals to PySimpleGUI are a tad sketchy, the public interfaces into the SDK are more strictly defined and comply with PEP 8 for the most part. +While the internals to PySimpleGUI are a tad sketchy, the public interfaces into the SDK are more strictly defined and comply with PEP 8 for the most part. Please log bugs and suggestions in the GitHub! It will only make the code stronger and better in the end, a good thing for us all, right? - -## Authors + +## Authors MikeTheWatchGuy - -## License - + +## License + This project is limited to non-commercial applications. If you wish to use it commercially, please contact one of the authors. For non-commercial individuals, the GNU Lesser General Public License (LGPL 3) applies. - -## Acknowledgments - + +## Acknowledgments + * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence ## How Do I Finally, I must thank the fine folks at How Do I. https://github.com/gleitz/howdoi -Their utility has forever changed the way and pace in which I can program. I urge you to try the HowDoI.py application here on GitHub. Trust me, **it's going to be worth the effort!** +Their utility has forever changed the way and pace in which I can program. I urge you to try the HowDoI.py application here on GitHub. Trust me, **it's going to be worth the effort!** Here are the steps to run that application Install howdoi: @@ -1031,7 +1136,7 @@ Here are the steps to run that application To run it: Python HowDoI.py -The pip command is all there is to the setup. +The pip command is all there is to the setup. The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. @@ -1044,3 +1149,4 @@ The PySimpleGUI window that the results are shown in is an 'input' field which m + From c6b0f4111a2072a19410402eccab763c0507bc6b Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 23 Jul 2018 15:20:41 -0400 Subject: [PATCH 055/209] New picture of all widgets --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 79abcc07e..29dc5073a 100644 --- a/readme.md +++ b/readme.md @@ -55,7 +55,7 @@ The `PySimpleGUI` solution is focused on the ***developer***. How can the desir An example of many widgets used on a single form. A little further down you'll find the FIFTEEN lines of code required to create this complex form. -![all widgets](https://user-images.githubusercontent.com/13696193/42604818-adb1dd5c-8542-11e8-94cb-575881590f21.jpg) +![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) --- ### Design Goals From 9bc4eddce60b1f9149a29c525fbb60135183b3df Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 23 Jul 2018 18:33:49 -0400 Subject: [PATCH 056/209] Forgot to add Listbox and Slider to feature list! --- readme.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 29dc5073a..df3995ddc 100644 --- a/readme.md +++ b/readme.md @@ -40,6 +40,8 @@ The `PySimpleGUI` solution is focused on the ***developer***. How can the desir Close form Checkboxes Radio Buttons + Listbox + Slider Icons Multi-line Text Input Scroll-able Output @@ -1082,10 +1084,11 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case | 2.1.1 | July 18, 2018 - Global settings exposed, fixes | 2.2.0| July 20, 2018 - Image Elements, Print output -| 2.3.0 | July XX, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. +| 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. +| 2.4.0 | July XX, 2018 - Planned release. Will have button images. ### Release Notes -2.3 - Sliders, Listbox's and Image elements (oh my!) This Readme is being updated with Listbox and Image elements. If you want to use them, they behave as one would expect. Note use of pixels in some parameters. +2.3 - Sliders, Listbox's and Image elements (oh my!) If using Progress Meters, avoid cancelling them when you have another window open. It could lead to future windows being blank. It's being worked on. From b88483bb767522ae3ae497b016931c1611c17dfc Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 24 Jul 2018 00:05:01 -0400 Subject: [PATCH 057/209] Readme update More on Listbox and Slider. SimpleGUI Print function for debug output. --- readme.md | 105 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 87 insertions(+), 18 deletions(-) diff --git a/readme.md b/readme.md index df3995ddc..729420885 100644 --- a/readme.md +++ b/readme.md @@ -24,11 +24,11 @@ There are a number of 'easy to use' Python GUIs, but they're **very** limiting. Every call has optional parameters so that you can change the look and feel. Don't like the button color? It's easy to change by adding a button_color parameter to your widget. -GUI Packages with more functionality, like QT and WxPython, require configuring and can take a ***week*** to get *reasonably familiar* with the interfaces. +GUI Packages with more functionality, like QT and WxPython, require configuring and can take a ***week*** to get *reasonably familiar* with the interfaces. Clearly there needs to be a middle ground between forms with 1 or two input fields and a full-blown GUI. You'll be making your own custom forms with PySimpleGUI within minutes, even Async forms. With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. -The `PySimpleGUI` solution is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? +The `PySimpleGUI` package is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? Features of PySimpleGUI include: Text @@ -55,10 +55,43 @@ The `PySimpleGUI` solution is focused on the ***developer***. How can the desir Single-Line-Of-Coide Proress Bar & Debug Print -An example of many widgets used on a single form. A little further down you'll find the FIFTEEN lines of code required to create this complex form. +An example of many widgets used on a single form. A little further down you'll find the TWENTY lines of code required to create this complex form. Try it if you don't believe it. Copy and paste into a temp file and it'll run, presenting you with the screen you see. ![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) +Here is the code that produced the above screenshot. + + import PySimpleGUI as SG + + with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [SG.Text('Here is some text.... and a place to enter text')], + [SG.InputText()], + [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], + [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], + [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [SG.Text('_' * 100, size=(70, 1))], + [SG.Text('Choose Source and Destination Folders', size=(35, 1))], + [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], + [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), + SG.FolderBrowse()], + [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + + **A note on screen shots** +You will see a number of different styles of buttons, data entry fields, etc, in this readme. They were all made with the same SDK, the only difference is in the settings that are specified on a per-element, row, form, or global basis. One setting in particular, border_width, can make a big difference on the look of the form. Some of the screenshots had a border_width of 6, others a value of 1. + + --- ### Design Goals > Copy, Paste, Run. @@ -258,6 +291,33 @@ With a little trickery you can provide a way to break out of your loop using the break ***Be sure and add one to your loop counter*** so that your counter goes from 1 to the max value. If you do not add one, your counter will never hit the max value. Instead it will go from 0 to max-1. +#### Debug Output +Another call in the 'Easy' families of APIs is `EasyPrint`. It will output to a debug window. If the debug window isn't open, then the first call will open it. No need to do anything but stick a 'print' call in your code. You can even replace your 'print' calls with calls to EasyPrint by simply sticking the statement + + print = SG.EasyPrint + +at the top of your code. +There are a number of names for the same EasyPrint function. `Print` is one of the better ones to use as it's easy to remember. It is simply `print` with a capital P. + + import PySimpleGUI as SG + + for i in range(100): + SG.Print(i) + +![snap0125](https://user-images.githubusercontent.com/13696193/43114979-a696189e-8ecf-11e8-83c7-473fcf0ccc66.jpg) +Or if you didn't want to change your code: + + import PySimpleGUI as SG + + print=SG.Print + for i in range(100): + print(i) + +Just like the standard print call, `EasyPrint` supports the `sep` and `end` keyword arguments. Other names that can be used to call `EasyPrint` include Print, `eprint`, If you want to close the window, call the function `EasyPrintClose`. + +A word of caution. There are known problems when multiple PySimpleGUI windows are opened, particularly if the user closes them in an unusual way. Not a reason to stay away from using it. Just something to keep in mind if you encounter a problem. + +You can change the size of the debug window using the `SetOptions` call with the `debug_win_size` parameter. --- # Custom Form API Calls @@ -327,19 +387,25 @@ This is the code that **displays** the form, collects the information and return Return information from FlexForm, SG's primary form builder interface, is in this format: - (button, (value1, value2, ...)) + button, (value1, value2, ...) Each of the Elements that are Input Elements will have a value in the list of return values. You can unpack your GUI directly into the variables you want to use. - (button, (filename, folder1, folder2, should_overwrite) = form.LayoutAndShow(form_rows) + button, (filename, folder1, folder2, should_overwrite) = form.LayoutAndShow(form_rows) + Or, you can unpack the return results separately. + + button, values = form.LayoutAndShow(form_rows) + filename, folder1, folder2, should_overwrite = values If you have a SINGLE value being returned, it is written this way: - (button, (value1,)) = form.LayoutAndShow(form_rows) + button, (value1,) = form.LayoutAndShow(form_rows) + + Another way of parsing the return values is to store the list of values into a variable representing the list of values. - (button, (value_list)) = form.LayoutAndShow(form_rows) + button, value_list = form.LayoutAndShow(form_rows) value1 = value_list[0] value2 = value_list[1] ... @@ -373,8 +439,6 @@ This code utilizes as many of the elements in one form as possible. button, values = form.LayoutAndRead(layout) - MsgBox('Results', 'You clicked {}'.format(button),'The values returned from form', values , font = ("Helvetica", 15)) - This is a somewhat complex form with quite a bit of custom sizing to make things line up well. This is code you only have to write once. When looking at the code, remember that what you're seeing is a list of lists. Each row contains a list of Graphical Elements that are used to create the form. ![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) @@ -383,8 +447,6 @@ Clicking the Submit button caused the form call to return. The call to MsgBox r ![results 2](https://user-images.githubusercontent.com/13696193/43097502-44e3ed32-8e8a-11e8-9a51-2b8af0b1a682.jpg) - - (button, (values)) = form.LayoutAndShow(layout) **`Note, button value can be None`**. The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. @@ -628,6 +690,11 @@ Also known as a drop-down list. Only required parameter is the list of choices. #### Listbox Element The standard listbox like you'll find in most GUIs. Note that the return values from this element will be a ***list of results, not a single result***. This is because the user can select more than 1 item from the list (if you set the right mode). + layout = [[SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6))]] + +![snap0130](https://user-images.githubusercontent.com/13696193/43115859-2fbf0646-8ed3-11e8-9979-bbee8eaebfab.jpg) + + Listbox(values, select_mode=None, scale=(None, None), @@ -658,6 +725,10 @@ The `select_mode` option can be a string or a constant value defined as a variab #### Slider Element Sliders have a couple of slider-specific settings as well as appearance settings. Examples include the `orientation` and `range` settings. + layout = [[SG.Slider(range=(1,500), default_value=222, size=(20,15), orientation='horizontal', font=('Helvetica', 12))]] + +![snap0129](https://user-images.githubusercontent.com/13696193/43115741-e1cb52c8-8ed2-11e8-80bb-0e99ae846ec1.jpg) + Slider(range=(None,None), default_value=None, orientation=None, @@ -683,10 +754,6 @@ Sliders have a couple of slider-specific settings as well as appearance settings size - (width, height) of element in characters auto_size_text - Bool. True if size should fit the text - - - - #### Radio Button Element Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. @@ -1085,7 +1152,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.1.1 | July 18, 2018 - Global settings exposed, fixes | 2.2.0| July 20, 2018 - Image Elements, Print output | 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. -| 2.4.0 | July XX, 2018 - Planned release. Will have button images. +| 2.4.0 | July XX, 2018 - Planned release. Button images. ### Release Notes 2.3 - Sliders, Listbox's and Image elements (oh my!) @@ -1119,8 +1186,7 @@ MikeTheWatchGuy ## License -This project is limited to non-commercial applications. If you wish to use it commercially, please contact one of the authors. -For non-commercial individuals, the GNU Lesser General Public License (LGPL 3) applies. +GNU Lesser General Public License (LGPL 3) ## Acknowledgments @@ -1153,3 +1219,6 @@ The PySimpleGUI window that the results are shown in is an 'input' field which m + + + From e2f9f5c83450a625a12475c9fecff3ad002caa19 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 24 Jul 2018 00:07:07 -0400 Subject: [PATCH 058/209] Readme --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index 729420885..f624212e4 100644 --- a/readme.md +++ b/readme.md @@ -262,8 +262,10 @@ There are 3 very basic user input high-level function calls. It's expected that #### Progress Meter! We all have loops in our code. 'Isn't it joyful waiting, watching a counter scrolling past in a text window? How about one line of code to get a progress meter, that contains statistics about your code? + ![progress meter 3](https://user-images.githubusercontent.com/13696193/42696332-dca3ca6e-8685-11e8-846b-6bee8362ee5f.jpg) + EasyProgressMeter(title, current_value, max_value, From 8e329e7690b9393d45fc6c79f71d9a41a68fa8ec Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 24 Jul 2018 12:20:34 -0400 Subject: [PATCH 059/209] Removed F-string Oops, and f-string creaped in --- Demo Recipes.py | 134 ++++++++++++++++++++++++------------------------ 1 file changed, 66 insertions(+), 68 deletions(-) diff --git a/Demo Recipes.py b/Demo Recipes.py index db2168a4e..adb5e0fff 100644 --- a/Demo Recipes.py +++ b/Demo Recipes.py @@ -1,22 +1,20 @@ import time from random import randint -import random -import string -import PySimpleGUI as SG +import PySimpleGUI as sg # A simple blocking form. Your best starter-form def SourceDestFolders(): - with SG.FlexForm('Demo Source / Destination Folders', auto_size_text=True) as form: - form_rows = [[SG.Text('Enter the Source and Destination folders')], - [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source')], - [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), SG.FolderBrowse()], - [SG.Submit(), SG.Cancel()]] + with sg.FlexForm('Demo Source / Destination Folders', auto_size_text=True) as form: + form_rows = [[sg.Text('Enter the Source and Destination folders')], + [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source')], + [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), sg.FolderBrowse()], + [sg.Submit(), sg.Cancel()]] button, (source, dest) = form.LayoutAndRead(form_rows) if button == 'Submit': - SG.MsgBox('Submitted', 'The user entered source:', source, 'Destination folder:', dest, 'Using button', button) + sg.MsgBox('Submitted', 'The user entered source:', source, 'Destination folder:', dest, 'Using button', button) else: - SG.MsgBoxError('Cancelled', 'User Cancelled') + sg.MsgBoxError('Cancelled', 'User Cancelled') # YOUR BEST STARTING POINT # This is a form showing you all of the basic Elements (widgets) @@ -25,71 +23,71 @@ def SourceDestFolders(): # Use this especially if you are runningm multi-threaded # Where you free up resources is really important to tkinter def Everything(): - with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: layout = [ - [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [SG.Text('Here is some text.... and a place to enter text')], - [SG.InputText()], - [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], - [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], - [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText()], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', scale=(2, 10))], - [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [SG.Text('_' * 100, size=(70, 1))], - [SG.Text('Choose Source and Destination Folders', size=(35, 1))], - [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], - [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), - SG.FolderBrowse()], - [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] + [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [sg.Text('_' * 100, size=(70, 1))], + [sg.Text('Choose Source and Destination Folders', size=(35, 1))], + [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], + [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), + sg.FolderBrowse()], + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] ] button, values = form.LayoutAndRead(layout) - SG.MsgBox('Title', 'Typical message box', 'The results of the form are a lot of data! Get ready... ', 'The button clicked was "{}"'.format(button), 'The values are', values) + sg.MsgBox('Title', 'Typical message box', 'The results of the form are a lot of data! Get ready... ', 'The button clicked was "{}"'.format(button), 'The values are', values) # Should you decide not to use a context manager, then try this form as your starting point # Be aware that tkinter, which this is based on, is picky about who frees up resources, especially if # you are running multithreaded def Everything_NoContextManager(): - form = SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) - layout = [[SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [SG.Text('Here is some text.... and a place to enter text')], - [SG.InputText()], - [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], - [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], - [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', scale=(2, 10))], - [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), SG.Slider(range=(1,100), orientation='h', size=(35,20), default_value=85)], - [SG.Listbox(values=['Listbox 1','Listbox 2', 'Listbox 3'], size=(30,6)), - SG.Slider(range=(1,100), orientation='v', size=(10, 20), default_value=25), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [SG.Text('_' * 100, size=(70, 1))], - [SG.Text('Choose Source and Destination Folders', size=(35, 1), text_color='red')], - [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], - [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), SG.FolderBrowse()], - [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))]] + form = sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) + layout = [[sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText()], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', scale=(2, 10))], + [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [sg.Text('_' * 100, size=(70, 1))], + [sg.Text('Choose Source and Destination Folders', size=(35, 1), text_color='red')], + [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], + [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), sg.FolderBrowse()], + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))]] button, values = form.LayoutAndRead(layout) del(form) - SG.MsgBox('Title', 'Typical message box', 'Here are the restults! There is one entry per input field ', 'The button clicked was "{}"'.format(button), 'The values are', values) + sg.MsgBox('Title', 'Typical message box', 'Here are the restults! There is one entry per input field ', 'The button clicked was "{}"'.format(button), 'The values are', values) def ProgressMeter(): for i in range(1,10000): - if not SG.EasyProgressMeter('My Meter', i+1, 10000): break + if not sg.EasyProgressMeter('My Meter', i + 1, 10000): break # SG.Print(i) # Blocking form that doesn't close def ChatBot(): - with SG.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: - layout = [[(SG.Text('This is where standard out is being routed', size=[40, 1]))], - [SG.Output(size=(80, 20))], - [SG.Multiline(size=(70, 5), enter_submits=True), SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))]] + with sg.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + layout = [[(sg.Text('This is where standard out is being routed', size=[40, 1]))], + [sg.Output(size=(80, 20))], + [sg.Multiline(size=(70, 5), enter_submits=True), sg.ReadFormButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0])), sg.SimpleButton('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]] # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form # if you call LayoutAndRead from here, then you will miss the first button click form.Layout(layout) @@ -106,15 +104,15 @@ def ChatBot(): # form within the 'with' block. If your read occurs far away in your code from the form creation # then you will want to use the NonBlockingPeriodicUpdateForm example def NonBlockingPeriodicUpdateForm_ContextManager(): - with SG.FlexForm('Running Timer', auto_size_text=True) as form: - text_element = SG.Text('',size=(10,2), font=('Helvetica', 20), text_color='red', justification='center') - layout = [[SG.Text('Non blocking GUI with updates', justification='center')], - [text_element], - [SG.T(' '*15), SG.Quit()]] + with sg.FlexForm('Running Timer', auto_size_text=True) as form: + text_element = sg.Text('', size=(10, 2), font=('Helvetica', 20), text_color='red', justification='center') + layout = [[sg.Text('Non blocking GUI with updates', justification='center')], + [text_element], + [sg.T(' ' * 15), sg.Quit()]] form.LayoutAndRead(layout, non_blocking=True) for i in range(1,500): - text_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i/100), 60), i%100)) + text_element.Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100)) button, values = form.ReadNonBlocking() if values is None or button == 'Quit': # if user closed the window using X break @@ -127,15 +125,15 @@ def NonBlockingPeriodicUpdateForm_ContextManager(): # from the form creation (call to LayoutAndRead) def NonBlockingPeriodicUpdateForm(): # Show a form that's a running counter - form = SG.FlexForm('Running Timer', auto_size_text=True) - text_element = SG.Text('',size=(10,2), font=('Helvetica', 20), justification='center') - form_rows = [[SG.Text('Non blocking GUI with updates')], + form = sg.FlexForm('Running Timer', auto_size_text=True) + text_element = sg.Text('', size=(10, 2), font=('Helvetica', 20), justification='center') + form_rows = [[sg.Text('Non blocking GUI with updates')], [text_element], - [SG.T(' ' * 15), SG.Quit()]] + [sg.T(' ' * 15), sg.Quit()]] form.LayoutAndRead(form_rows, non_blocking=True) for i in range(1,50000): - text_element.Update(f'{(i//100)//60:02d}:{(i//100)%60:02d}.{i%100:02d}') + text_element.Update('{:02d}:{:02d}.{:02d}'.format((i//100)//60, (i//100)%60, i%100)) button, values = form.ReadNonBlocking() if values is None or button == 'Quit': # if user closed the window using X or clicked Quit button break @@ -148,22 +146,22 @@ def NonBlockingPeriodicUpdateForm(): def DebugTest(): # SG.Print('How about we print a bunch of random numbers?', , size=(90,40)) for i in range (1,300): - SG.Print(i, randint(1, 1000), end='', sep='-') + sg.Print(i, randint(1, 1000), end='', sep='-') def main(): # SG.SetOptions(border_width=1, font=("Helvetica", 10), button_color=('white', SG.BLUES[0]), slider_border_width=1) - Everything_NoContextManager() - Everything() NonBlockingPeriodicUpdateForm_ContextManager() NonBlockingPeriodicUpdateForm() + Everything_NoContextManager() + Everything() ChatBot() Everything() ProgressMeter() SourceDestFolders() ChatBot() DebugTest() - SG.MsgBox('Done with all recipes') + sg.MsgBox('Done with all recipes') if __name__ == '__main__': main() From b7eb946027a10937b8babddf9dd6e5b39843b19e Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 24 Jul 2018 14:12:39 -0400 Subject: [PATCH 060/209] RELEASE 2.4 (early) Wasn't building correctly on Raspberry Pi and wanted to correct it quickly. Am not paracticing good source code management! --- PySimpleGUI.py | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 76f53a7b7..ab01ba2cf 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -37,12 +37,16 @@ # DEFAULT_BUTTON_COLOR = (YELLOWS[0], PURPLES[2]) # Foreground, Background (None, None) == System Default DEFAULT_ERROR_BUTTON_COLOR =("#FFFFFF", "#FF0000") DEFAULT_CANCEL_BUTTON_COLOR = (GREENS[3], TANS[0]) -BarColor=() # DEFAULT_PROGRESS_BAR_COLOR = (GREENS[2], GREENS[0]) # a nice green progress bar DEFAULT_PROGRESS_BAR_COLOR = (GREENS[3], GREENS[3]) # a nice green progress bar # DEFAULT_PROGRESS_BAR_COLOR = (BLUES[1], BLUES[1]) # a nice green progress bar # DEFAULT_PROGRESS_BAR_COLOR = (BLUES[0], BLUES[0]) # a nice green progress bar # DEFAULT_PROGRESS_BAR_COLOR = (PURPLES[1],PURPLES[0]) # a nice purple progress bar + +# A transparent button is simply one that matches the background +TRANSPARENT_BUTTON = ('#F0F0F0', '#F0F0F0') +#-------------------------------------------------------------------------------- + DEFAULT_PROGRESS_BAR_SIZE = (35,25) # Size of Progress Bar (characters for length, pixels for width) DEFAULT_PROGRESS_BAR_BORDER_WIDTH=1 DEFAULT_PROGRESS_BAR_RELIEF = tk.SUNKEN @@ -459,14 +463,18 @@ def __del__(self): # Button Class # # ---------------------------------------------------------------------- # class Button(Element): - def __init__(self, button_type=CLOSES_WIN, target=(None, None), button_text='', file_types=(("ALL Files", "*.*"),), scale=(None, None), size=(None, None), auto_size_text=None, button_color=None, font=None): + def __init__(self, button_type=CLOSES_WIN, target=(None, None), button_text='', file_types=(("ALL Files", "*.*"),), image_filename=None, image_size=(None,None), image_subsample=None, border_width=None, scale=(None, None), size=(None, None), auto_size_text=None, button_color=None, font=None): self.BType = button_type self.FileTypes = file_types self.TKButton = None self.Target = target self.ButtonText = button_text self.ButtonColor = button_color if button_color else DEFAULT_BUTTON_COLOR + self.ImageFilename = image_filename + self.ImageSize = image_size + self.ImageSubsample = image_subsample self.UserData = None + self.BorderWidth = border_width if border_width is not None else DEFAULT_BORDER_WIDTH super().__init__(ELEM_TYPE_BUTTON, scale, size, auto_size_text, font=font) return @@ -913,13 +921,13 @@ def No(button_text='No', scale=(None, None), size=(None, None), auto_size_text=N # ------------------------- GENERIC BUTTON Element lazy function ------------------------- # # this is the only button that REQUIRES button text field -def SimpleButton(button_text, scale=(None, None), size=(None, None), auto_size_text=None, button_color=None, font=None): - return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color, font=font) +def SimpleButton(button_text, image_filename=None, image_size=(None, None), image_subsample=None, border_width=None, scale=(None, None), size=(None, None), auto_size_text=None, button_color=None, font=None): + return Button(CLOSES_WIN, image_filename=image_filename, image_size=image_size,image_subsample=image_subsample, button_text=button_text,border_width=border_width, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color, font=font) # ------------------------- GENERIC BUTTON Element lazy function ------------------------- # # this is the only button that REQUIRES button text field -def ReadFormButton(button_text, scale=(None, None), size=(None, None), auto_size_text=None, button_color=None, font=None): - return Button(READ_FORM, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color, font=font) +def ReadFormButton(button_text, image_filename=None, image_size=(None, None),image_subsample=None,border_width=None,scale=(None, None), size=(None, None), auto_size_text=None, button_color=None, font=None): + return Button(READ_FORM, image_filename=image_filename, image_size=image_size,image_subsample=image_subsample,border_width=border_width, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color, font=font) #------------------------------------------------------------------------------------------------------# # ------- FUNCTION InitializeResults. Sets up form results matrix ------- # @@ -1151,9 +1159,20 @@ def CharWidthInPixels(): bc = DEFAULT_BUTTON_COLOR if bc == 'Random' or bc == 'random': bc = GetRandomColorPair() + border_depth = element.BorderWidth tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height,command=element.ButtonCallBack, justify=tk.LEFT, foreground=bc[0], background=bc[1], bd=border_depth) element.TKButton = tkbutton # not used yet but save the TK button in case wraplen = tkbutton.winfo_reqwidth() # width of widget in Pixels + if element.ImageFilename: + photo = tk.PhotoImage(file=element.ImageFilename) + if element.ImageSize != (None, None): + width, height = element.ImageSize + if element.ImageSubsample: + photo = photo.subsample(element.ImageSubsample) + else: + width, height = photo.width(), photo.height() + tkbutton.config(image=photo, width=width, height=height) + tkbutton.image = photo tkbutton.configure(wraplength=wraplen+10, font=font) # set wrap to width of widget tkbutton.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) if not focus_set and btype == CLOSES_WIN: @@ -1757,7 +1776,8 @@ def EasyProgressMeter(title, current_value, max_value, *args, orientation=None, for line in EasyProgressMeter.EasyProgressMeterData.StatMessages: message = message + str(line) + '\n' message = "\n".join(EasyProgressMeter.EasyProgressMeterData.StatMessages) - rc = ProgressMeterUpdate(EasyProgressMeter.EasyProgressMeterData.MeterID, current_value, *args, message) + args= args + (message,) + rc = ProgressMeterUpdate(EasyProgressMeter.EasyProgressMeterData.MeterID, current_value, *args) # if counter >= max then the progress meter is all done. Indicate none running if current_value >= EasyProgressMeter.EasyProgressMeterData.MaxValue or not rc: EasyProgressMeter.EasyProgressMeterData.MeterID = None From efa5b5fc6bf3da973b8e52e3af72d9e52f9da8c4 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 24 Jul 2018 14:13:12 -0400 Subject: [PATCH 061/209] Minor change --- Demo Recipes.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Demo Recipes.py b/Demo Recipes.py index adb5e0fff..6f2a76cd2 100644 --- a/Demo Recipes.py +++ b/Demo Recipes.py @@ -156,7 +156,6 @@ def main(): Everything_NoContextManager() Everything() ChatBot() - Everything() ProgressMeter() SourceDestFolders() ChatBot() From d9d548747b47ca7b0c1db6e94dd43f8aef228fc4 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 24 Jul 2018 15:52:14 -0400 Subject: [PATCH 062/209] Readme update for version 2.4 features. Button images --- ButtonGraphics/Exit.png | Bin 0 -> 8167 bytes ButtonGraphics/Loop.png | Bin 0 -> 3441 bytes ButtonGraphics/Next.png | Bin 0 -> 8065 bytes ButtonGraphics/Pause.png | Bin 0 -> 7586 bytes ButtonGraphics/Restart.png | Bin 0 -> 8013 bytes ButtonGraphics/Rewind.png | Bin 0 -> 7902 bytes ButtonGraphics/Stop.png | Bin 0 -> 7747 bytes Demo High Level APIs.py | 11 - Demo Media Player.py | 60 ++++ Demo NonBlocking Form.py | 59 ++++ __pycache__/PySimpleGUI.cpython-36.pyc | Bin 0 -> 54552 bytes readme.md | 370 +++++++++++++++---------- 12 files changed, 340 insertions(+), 160 deletions(-) create mode 100644 ButtonGraphics/Exit.png create mode 100644 ButtonGraphics/Loop.png create mode 100644 ButtonGraphics/Next.png create mode 100644 ButtonGraphics/Pause.png create mode 100644 ButtonGraphics/Restart.png create mode 100644 ButtonGraphics/Rewind.png create mode 100644 ButtonGraphics/Stop.png delete mode 100644 Demo High Level APIs.py create mode 100644 Demo Media Player.py create mode 100644 Demo NonBlocking Form.py create mode 100644 __pycache__/PySimpleGUI.cpython-36.pyc diff --git a/ButtonGraphics/Exit.png b/ButtonGraphics/Exit.png new file mode 100644 index 0000000000000000000000000000000000000000..f2ef87d2f17a082ab91e6a4f57dbd5ecd588ecde GIT binary patch literal 8167 zcmWkz1yod96n!)j3eq7t(k0y`H3E`@GzbWal=Oh40#Z@}BGMo-bazO@e59lV>F!4Q zUuR9MHS67b-@Esmz4zHCT>GgiF##l}YxD1ej|;wC78CWs&m9*vBR2>l zy#McmG4jX%3W69@;7SVm-e1T3j9ln@QdXahi8auzcTb6bNQL36kz+qmF#ee5U_{QV zle817X+p}Xy50GkU#Rj_dON|cBOPD$KUs0pYwX|7y@!gN9;%i!(5rQ~A{z}zG-@^m(V)b??C#K7N&vwlqd&s+BdCJFztPMAj(s`!tjhnT#wZp4doZ>Pv5BgVJ zkKEkc!nJZ_ZPhNS2<6q{VUrG`z9uFnnT3U0mVSQMWC#QT&&H?(N1H&N?F@yozepor zfr{2#>xT{x54-B?>*Y*a{hI@TB~e2RvnI>)EVtY1GG$AE_+RJEQEFAI9txr>CdS=%u~) z8Mn5!TAAUxG;MZ*@NMT)+G~1s;mRquVU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M8`XNti+MW}uP#45%K9D&u0%PAxkNr*=AKEGstRKG0wj0`lFDMYf&r)S63oXRW?Rf!Mdj?F*trMT=w5N8ej*dHgkVsvn z2s1prSXC6mLHpGsa)Lj=d$$HN{Q&)ySQP4L_~j=l_RUK9TgK>O;s9h4O*iP=LvZD% KN+pVx!T$p@`L*x> literal 0 HcmV?d00001 diff --git a/ButtonGraphics/Loop.png b/ButtonGraphics/Loop.png new file mode 100644 index 0000000000000000000000000000000000000000..cb303d8f8e843c5536deb921ece9bd38e3a63370 GIT binary patch literal 3441 zcmV-%4UY1OP)pSBS}O-RCt{2-FuLoXI%&I&z?O^woO8UC6~5aY(ot;sl7;z3PW2{ zp;TuS5N`}Rj<-?kppN4eb;eN<9j}FgI_d}`;xMHa>TN(EREhD z*=(}uUi{d-ibMDco+>^!*^||DfT4a*U>1gPJ}$*evAOvBMy$nh z-OqOh6T*<)*nyqcRg5oSs>IwY!yqtZC0>qeu@x_oxBqPQ&2I+BWEVYx&)`mc3P);s zW?Se7LxzOd7vM(xAU0tImi1vyGdLk4?DO~s{JV&{W5vHeXR!v?;GNiyX<6_fjp<@; z?<(fHrWQ){86((+cZi7SH__W2yNfw*b5e0w^0)wRm&KjXe zep(hYrT>I2JEpJ)H;FdbsEk@Qqahm8Z5Y#kLRLM-@K3nT5@52=MCteVgs8{O zG6XGyVZ0jmh?B101nKvf#Q)%if;K(HFuqGXsAs}?(e7wj`LESOrZi<|JX*too-1R& z?3CKY*N~hU_c*h5#*=su<86L^TEy2jH9JeU$l-OSoEg)?i0_fO%ufk(+WGFJxb(Ml zMd>zhfx%O4Pe}Cd3*xlgi3h}Jd$9QLNAN|76h7U-Zy(1U5-gidgMaRDj@xx$r?e~M zR^pe$UC>X=2x0f)A@MEklaTF`_^Lz(CuMCTGWWF-^!i#{Eb*6%#LAveq&$W9&U*UKAU)gjp^es2T5 z4mGUx<&9q za0B^G{-_H_QExVpr1I>k>) zT%;-*?U5rxL$=B$^~l^KQuxvhwuyd%Pc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{NPAP=Y>lh+x+$!)*0* zt<5c0+GhIlkcSsG#yx$y;)3E{M8&Mw=2C0qUbkJMz}hYgfscE5QKQg4%;gi;y|bWY6ArQ6@O3wGZS37fSYRvy0W| z)~#E2oAGzNQD}2l?Lzth2gD&BLxv3LXT#a?)^p~J966E~y_=2Idu&|^-(3V}@N9c| zdwctQ>j^D3EG_Hk=s2L?Z#v)(5fIAen*QdL(bj8b*pPOPIqOtQPak?Vc6#%r2Vnf? z=ihB6`r|evJz_m!kvU_7%?-PH+wnccd&VI-m{SIsL&l64F{06&Gil(!fyXvBHu44x z56Jj5p*YwGxLW38I^xE*wzd~`?AWo&oUnTH=FM#;{Caan_MNB$kD~a0b~#>@%#rY0 P00000NkvXXu0mjfUC#0B literal 0 HcmV?d00001 diff --git a/ButtonGraphics/Pause.png b/ButtonGraphics/Pause.png new file mode 100644 index 0000000000000000000000000000000000000000..284b1e52eb8e64c911dcb5375ed0201b613cc660 GIT binary patch literal 7586 zcmWkz2RxK-96yr1sjP5Z_I6|wXJut)WG6DS_sAJ%QwZ51XA`msQD^*-y|c6T3je3~ z^WNR(qexg{7 zs#nx>-f_GcnhZC5Jv_d^MMUn-I(zRebw!e4?PIy>{-|?TWsr+~S}H6od}duec|1LB>}qKV)#IQ} zO-oJH8OoQjMfi>1WoA*OEHiM>*V58D>gebw86O`{qo=1&z|_oQ=i-K_501eHj-@#{ zA(MR6gn1_?C#7m?YB?I3n(>2!gB3QlMq}I3IbWpQ<>~0?ctYhCFK%vbh@_>Z*RhBp zRgl7tz5DP8noDoSj+O20?Vgg7k|YZOA8%`G*7j2MQ`Kw&Xmq|xs9eXw!ouwuxc`i3 zrW3iG$TQ-m^gz};lt6V(zm3rHyLa!}KW1cHItkF24z9Xsy>QBwfCdHz;+gwx7BV%| z*SFp2AlmN~ZN5ihN~prNd4i`^UD$-=lN%GWUpWbzZ+Q0ZZIVh>yQf5TI#E!>kfsp@0zZFORiMjE!%w&6N=Ht|A%=dCxeYZ@twK(NPf9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Rj$}XeWHT9WqwRY-1z+S&%e;w*}0;lqhr;}FTb3=dK_YuekSU`qbU9#Bx17`Ag`L& P00000NkvXXu0mjfIJlGQ literal 0 HcmV?d00001 diff --git a/ButtonGraphics/Rewind.png b/ButtonGraphics/Rewind.png new file mode 100644 index 0000000000000000000000000000000000000000..af18729733d6fd0caa2577f5fd999cfbe5fac9d0 GIT binary patch literal 7902 zcmV<49wFh0P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGf5&!@T5&_cPe*6Fc9&<@VK~#8N&7E72 zRmHu=w}U}Z5HNtupb`Nkh)M(#MI$6eVj*55AzGz*NS!<-=cMv*-cl7)m8zV#oSd9g zotLQb5(z436iqamNTj?3HAuK97d6NL1Bx;P&;&jIU$ejMH%+fSdxo1|)mPoCSFi4W zf8XkL+iUNAOzjhl;lqayI_8*TI!25b(LQ9zkO{{hfBa|L+uP5IRi^}p7zYQzu3)!u z>*mdyU)#HP@0#xJ?seO@Z{PgUM;~?W*s)_ztouab6JtmSUmGxBz`#+XMvWdbX3UH* zf%%be5;iwqW*4B2+ z=+UD)VkTT0yye(qk3BDnPuRcqV>C0PH={D)d!S<7?tlI3U$4Zhxhwe4mMvR4Km72+ zBR*}8xFInU&OH0{j%YjXT(xS|FJk7b zt(P4U92nJMK%5)e;;=L+@cl4iZVY^AGjYjlxhe&oca(%LrKNfT%hCROVa)xjSFiqQ z9L`q9xrX!5VMWg<4g=!QH0+#n&bc*=_*N_q$whRb^Ssl`l^2vR2~3*jonEfIqrTi7 z#@zO|zy0mjIF!AcRvaeu?EMg8@ZiA%V@AvyJ9g}kV^CvVKp=5N5XbBT%3)p(@>Ix$ zB^Be`)nnPq^SaQ%a`g3P;0G~d7VO%!>x25LLyE&igYy->t1(ySDbq zE3eezoRG>eLZtoN81*R%_59KoUwrY#F#N4lcn~;fLncg^F!^(z``o<|@VPDqV4yCD zn-Di)jpdkKwa7dOS2-*Jw3#!62*ma(5F-Vi`oI=T##le#3?hFQ&qNpx=hX%$Rll`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WV8X!Ytj>tH2%7i>GYCE-2f`oHHoi2KAfT%V^wHw$M zS80zeSg_!Gal^NvDu({zkQ*YzA!gu=88hZhnKI?aF_82Ll8dOkSQ5Ro?AyQ+TuA65 z=c4D!PHziDe{U{dzWfJEmMmEihromTHH8WsHbaECavFB|<(J>u-roMLSZw@jkJ3C} z61`LgwVfju(peJS%X~ZK>*$Uf;@jf>;?}q#d$(S8Sa8@40db;i3u7k5jQReUF=OV& zKpTHjnWtjDoR=wILY27AyiCiUM*Ht=+O+BZm=Qk>BUZ-+$00jcRAGP5M-Y=HO*(Vt z%$eT_WBB8k^j{?|Y%X?hX%(tOu1bOBcZ3mlKK=C5zgWF`_1b#b5y8jN96`j4IVNUI zN8AivJ9+ZtTjJ!;-(>XoX9mzpz8NaSuFCI@ll3brSFXG(ZW14g8PORtqP30=A&!b6 zj<|mr5ayg4=FA&EempOFPY$MMY`O5Q8j-^d0Jh9$+bh?vU%xm^SP&+xi2I4^-<&-H zIO>K7h!pn|1H+WjF>7YTA?>n}BS&5oC*AZz&%ymS1A+d`kO0U3opFJ%dE2&a&&46> zshAB*!i+6(-||6!%|6ul#28XSn8I(NcZ?l7wtdv7QM}&z*@+V;@&*jQq{lUsn*aa+ literal 0 HcmV?d00001 diff --git a/ButtonGraphics/Stop.png b/ButtonGraphics/Stop.png new file mode 100644 index 0000000000000000000000000000000000000000..28c7a0d1adda3b28c63f4974e69f9a9034e5e36b GIT binary patch literal 7747 zcmWkz2RNHu7>!b!+N)+_)vTG?N)U>gwQ3Vmv#Pe*BX;;v6t!DwE48b36;-us)vitL z_1}I^@+HrcC->g(z3+R@d(Oq^XseMCGZ8}|5HfWnLJxe}{d*JQgS-3hR0Hrq6X z0fCTE{d?p5n0<8#fv_B@BOV&~ycrBcJ2OvYuT_?o346h(2FtRdeCmaM6!VTKd0MS> zVLupqY~iKwirhbr>R8oBdEI9_o`Lj3a8T`o--hg}FYLXr-+J(^W%gY;aqB0_?(?g~ zAXsSBb@ftcy32h3b`(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+n_b`G4@RJW&bhhDp42_eSdeB^onc>b>> zZWeOVtnN>~ygc0xs+rlY#Ho_&UpEzp*b$`J$5VyRwR{XZ?t_I$(H)*$_6D7HvR(V3 z(dcIl)&9@?U0Wg0|SORLMb^4mJFsVEa3)_Wl9g4L1d0z~kh?7&LuOd*1L}%8r<5hU32G zgzF0Qv?&zpb2HcKe^XUg=UHhiu#;Iy(O)~uP58F4(bw(qFMbB>i@`U`L2dTf&~Wjcxj%wffBg!`tFGRc4YtsE z;f(t1X2c*G1L;XiPZt&v5Fiy26r7!%oTRAmRv_`+38%nv5=mwaj!aH6JVT?UXbJHw zfCJgfss8Mi4%v{? i6uYp4Ip^!UA#kRryYA?hmHhzcdE(EkCoMd_3P literal 0 HcmV?d00001 diff --git a/Demo High Level APIs.py b/Demo High Level APIs.py deleted file mode 100644 index 92bd53edc..000000000 --- a/Demo High Level APIs.py +++ /dev/null @@ -1,11 +0,0 @@ -import PySimpleGUI as sg - -sg.MsgBox('Title', 'My first message... Is the length the same?') -rc, number = sg.GetTextBox('Title goes here', 'Enter a number') -if not rc: - sg.MsgBoxError('You have cancelled') - exit(0) - -msg = '\n'.join([f'{i}' for i in range(0,int(number))]) - -sg.ScrolledTextBox(msg, height=10) \ No newline at end of file diff --git a/Demo Media Player.py b/Demo Media Player.py new file mode 100644 index 000000000..4770c90e2 --- /dev/null +++ b/Demo Media Player.py @@ -0,0 +1,60 @@ +import PySimpleGUI as sg + +# +# An Async Demonstration of a media player +# Uses button images for a super snazzy look +# See how it looks here: +# https://user-images.githubusercontent.com/13696193/43159403-45c9726e-8f50-11e8-9da0-0d272e20c579.jpg +# + + +def MediaPlayerGUI(): + + # Images are located in a subfolder in the Demo Media Player.py folder + image_pause = './ButtonGraphics/Pause.png' + image_restart = './ButtonGraphics/Restart.png' + image_next = './ButtonGraphics/Next.png' + image_exit = './ButtonGraphics/Exit.png' + + # A text element that will be changed to display messages in the GUI + TextElem = sg.Text('', size=(20, 3), font=("Helvetica", 14)) + + # Open a form, note that context manager can't be used generally speaking for async forms + form = sg.FlexForm('Media File Player', auto_size_text=True, default_element_size=(20, 1), + font=("Helvetica", 25)) + # define layout of the rows + layout= [[sg.Text('Media File Player', size=(20, 1), font=("Helvetica", 25))], + [TextElem], + [sg.ReadFormButton('Restart Song', button_color=sg.TRANSPARENT_BUTTON, + image_filename=image_restart, image_size=(50, 50), image_subsample=2, border_width=0, + size=(10, 2), font=("Helvetica", 15)), sg.Text(' ' * 2), + sg.ReadFormButton('Pause', button_color=sg.TRANSPARENT_BUTTON, + image_filename=image_pause, image_size=(50, 50), image_subsample=2, border_width=0, + font=("Helvetica", 15), size=(10, 2)), sg.Text(' ' * 2), + sg.ReadFormButton('Next', button_color=sg.TRANSPARENT_BUTTON, + image_filename=image_next, image_size=(50, 50), image_subsample=2, border_width=0, + size=(10, 2), font=("Helvetica", 15)), sg.Text(' ' * 2), + sg.Text(' ' * 2), sg.SimpleButton('Exit', button_color=sg.TRANSPARENT_BUTTON, + image_filename=image_exit, image_size=(50, 50), image_subsample=2, border_width=0, + size=(10, 2), font=("Helvetica", 15))], + [sg.Text('Treble', font=("Helvetica", 15), size=(6, 1)), + sg.Slider(range=(-10, 10), default_value=0, size=(10, 20), orientation='vertical', font=("Helvetica", 15)), + sg.Text(' ' * 5), + sg.Text('Volume', font=("Helvetica", 15), size=(7, 1)), + sg.Slider(range=(-10, 10), default_value=0, size=(10, 20), orientation='vertical', font=("Helvetica", 15))], + ] + + # Call the same LayoutAndRead but indicate the form is non-blocking + form.LayoutAndRead(layout, non_blocking=True) + # Our event loop + while(True): + # Read the form (this call will not block) + button, values = form.ReadNonBlocking() + if button == 'Exit': + break + # If a button was pressed, display it on the GUI by updating the text element + if button: + TextElem.Update(button) + +MediaPlayerGUI() + diff --git a/Demo NonBlocking Form.py b/Demo NonBlocking Form.py new file mode 100644 index 000000000..8e43d6dd8 --- /dev/null +++ b/Demo NonBlocking Form.py @@ -0,0 +1,59 @@ +import PySimpleGUI as sg +import time + +def main(): + StatusOutputExample() + +# form that doen't block +def StatusOutputExample_context_manager(): + with sg.FlexForm('Running Timer', auto_size_text=True) as form: + output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) + form_rows = [[sg.Text('Non-blocking GUI with updates')], + [output_element], + [sg.SimpleButton('Quit')]] + + form.LayoutAndRead(form_rows, non_blocking=True) + + for i in range(1, 1000): + output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i/100), 60), i%100)) + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + time.sleep(.01) + else: + form.CloseNonBlockingForm() + + +# form that doen't block +def StatusOutputExample(): + # Make a form, but don't use context manager + form = sg.FlexForm('Running Timer', auto_size_text=True) + # Create a text element that will be updated with status information on the GUI itself + output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) + # Create the rows + form_rows = [[sg.Text('Non-blocking GUI with updates')], + [output_element], + [sg.SimpleButton('Quit')]] + # Layout the rows of the form and perform a read. Indicate the form is non-blocking! + form.LayoutAndRead(form_rows, non_blocking=True) + + # + # Some place later in your code... + # You need to perform a ReadNonBlocking on your form every now and then or + # else it won't refresh + # + + for i in range(1, 1000): + output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + time.sleep(.01) + else: + form.CloseNonBlockingForm() + + + +if __name__ == '__main__': + + main() diff --git a/__pycache__/PySimpleGUI.cpython-36.pyc b/__pycache__/PySimpleGUI.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..19cd01373e01921ea2254dae97571284e134e56e GIT binary patch literal 54552 zcmdtL37j0qRX;xWwX?IQR;T5$t7CgSyEQA#Xm@5+ z(<^D$Gr8o%x#Tz(IWQp!A;jT^{7ncU3FIII2zP+~1u#hnm?J>o7lMK0_x--=={dBL zWrHD~|4LI`U0q#W_3G8DSMR-gwY|MPanH%4FSB0n_kGRR@YjX-UHFxEM|?izQ~p_> z<;OKJ>zfN$0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Z-HP1IM-LgIv&y^&9aKGkJUZ)V!#4Bo=v?F`<*V1~hG8GMn!gABgJ z;LjO6&EPK>$WB3SU(?)IrMdIRmDne`u6WKM(wSrbVZdas!FRf(;^f%0&mf$ zP&=S0nm2N0ii<^>Br*@pWx1>@Wl<)qsud}VXkQpDna&$H=A8tuFln*faHP2~o8x@o zE03aTMto(&Sk(2#f?$&`{1>RFrTytp61h49osp2_j(GX$y^MDazmUn}z8?q$Lcvrx z5{|{)lu*6o3u5)UBvbvJt2%o+*LU`IuE1|)=c?4r-5WbQI*)eV*qQ9?N%f^(;kz}J zP6m^xo%=784qY9>ef?iJiGQ)1W8qjdwmh0=9!F`>$cEozt zY>Hi(>R + abc = abc + attr12 = 12 + c = + b = + a = + attr1 = 1 + attr2 = 2 + attr3 = three + attr10 = 10 + attrx = x + +You'll quickly wonder how you ever coded without it. + + + --- # Known Issues @@ -1154,18 +1234,18 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.1.1 | July 18, 2018 - Global settings exposed, fixes | 2.2.0| July 20, 2018 - Image Elements, Print output | 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. -| 2.4.0 | July XX, 2018 - Planned release. Button images. +| 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi ### Release Notes 2.3 - Sliders, Listbox's and Image elements (oh my!) If using Progress Meters, avoid cancelling them when you have another window open. It could lead to future windows being blank. It's being worked on. +New debug printing capability. `sg.Print` + ### Upcoming Make suggestions people! Future release features -Button images. Ability to replace boring rectangular buttons with your own images. - Columns. How multiple columns would be specified in the SDK interface are still being designed. Progress Meters - Replace custom meter with tkinter meter. @@ -1216,11 +1296,3 @@ For Python questions, I simply start my query with 'Python'. Let's say you forg In the hands of a competent programmer, this tool is **amazing**. It's a must-try kind of program that has completely changed my programming process. I'm not afraid of asking for help! You just have to be smart about using what you find. The PySimpleGUI window that the results are shown in is an 'input' field which means you can copy and paste the results right into your code. - - - - - - - - From a9266a22a7d4696d75031d72a875067e8c38c11b Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 24 Jul 2018 16:19:29 -0400 Subject: [PATCH 063/209] Initial Checkin --- PySimpleGUI_Logo_640.png | Bin 0 -> 26841 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 PySimpleGUI_Logo_640.png diff --git a/PySimpleGUI_Logo_640.png b/PySimpleGUI_Logo_640.png new file mode 100644 index 0000000000000000000000000000000000000000..0de414a322ad2b1f6b3d335e38039cba5447b0b0 GIT binary patch literal 26841 zcmeEtRaBh8((T~x8r)qH2<{#nf_n(=?iyTzTW|{@xVuAeceen+T?QFu?r{G5Ki%j1 zc4nv#E)5{xQYaQ{*uek&$iJTZb_Y*lP>h4#OJ2t*% zOib7EazxRNmDJ!?2^wq>lc$2X{!tg6BksZwJ!yYe!d4$1cX@OM(80iYS7iMF-511fRkRUmHqK0ShiHiQM{Q-chUNttt z`d~ofWxX~Ai5J%V?09mdVA8$yjJNmV>1{Vxpn_H`2|BfueQy`&w9giVlHPBy1G3;b z+*v=cf`53yq&9ny*qh`urzt0ZmP}37F&3qW>E$z$CfnQD)e?eV&9!;tZs995G*>N= zau42r|JfPjduZgxXS(^jJhWw~1>P`=-+0uuxE}Q{Q-3`%gvW>u7SpWM(yJWgjgCrkK>rgNQO z+2e!sLhXAfYU6Sz*{(V+2TTsF2vXxiZ&mw#YmrEd_@7t96yvj_Gk>=WN#zTSFhA2m zD`}G@?L?TJR*~81o%b+8#o-})11fFl{0$Ao(;bkK>qf!x_o;sBobAVVoXRIcfrgYq zXi}(qMTuN)Jao4nO}bgJVffNY-K0sts)Nbm=ugqUuXsW@i>mUO2ln?dyDI?BBo_i_^N3QZF7vw1TqVq4gVml$qOs31NOF5duBN#NX|j{8qz?55vDuXP5c=}gvat&I`$d3%bT zHB@_XV9yab(`wso%suqKb;UR_r8Da91&3`lzFfWG?6N$2RvOt7fwCA zzpjt~MNBf?b>4d?S_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No0Zb18ToXG!ezxfGvg1dyjf0sPjiKyW!|sY^4X7f6j59?y(9NDf=T7egLS0gx$R z^BtqCgay9a&E%gB8oMU4k1YIQzY%;v000Pt0JcL}<;;N2@rTVNr<~s}fh}O`iE;N6 z;x*$}?W#R@*d349o(nE`cA-luj@?rM0I)Isf&Lq2SMB#SAEGcj%F7@jC)4?=0_hDV z3i;&_Sb!j}+4i|U#5__=WoDY*iIz|LfF@Xq(>dM+m;5VPX F{U6S=p0xk~ literal 0 HcmV?d00001 From a89f838a40924e207770d071de348ebf242bc47c Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 24 Jul 2018 16:21:09 -0400 Subject: [PATCH 064/209] Removed --- __pycache__/PySimpleGUI.cpython-36.pyc | Bin 54552 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 __pycache__/PySimpleGUI.cpython-36.pyc diff --git a/__pycache__/PySimpleGUI.cpython-36.pyc b/__pycache__/PySimpleGUI.cpython-36.pyc deleted file mode 100644 index 19cd01373e01921ea2254dae97571284e134e56e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 54552 zcmdtL37j0qRX;xWwX?IQR;T5$t7CgSyEQA#Xm@5+ z(<^D$Gr8o%x#Tz(IWQp!A;jT^{7ncU3FIII2zP+~1u#hnm?J>o7lMK0_x--=={dBL zWrHD~|4LI`U0q#W_3G8DSMR-gwY|MPanH%4FSB0n_kGRR@YjX-UHFxEM|?izQ~p_> z<;OKJ>zfN$0YB4%hzG5p#Qn3OLfDE(&Zxzwq1o76+={zT6IMc=wOMU)O{@szi2$`c}42by_RcKU=HRzgVl)|FzbrZ(D2C zzgp{ZYgA&jFSkzlR{LfG>O1P+a%&mStyWQ{xObAvyIZ9;^4UzpxwOu2;`m zS2mYtrQLh?ed{Xq@74zOAJ#_H?dqJraE*1X>bI^_o2={A4cUIAZenWo285ff8xd}? zZc>}At%%)hZBsW|+Y#Gg-J-TwJ0;Jp>LzQK+G^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)lu*6o3u5)UBvbvJt2%o+*LU`IuE1|)=c?4r-5WbQI*)eV*qQ9?N%f^(;kz}J zP6m^xo%=784qY9>ef?iJiGQ)1W8qjdwmh0=9!F`>$cEozt zY>Hi(>R Date: Tue, 24 Jul 2018 17:01:11 -0400 Subject: [PATCH 065/209] Updated logo --- readme.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 4d20c02d1..343d06dee 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,5 @@ -![logo01 2 _2](https://user-images.githubusercontent.com/13696193/43082437-1252511a-8e62-11e8-9150-fc227cc56cfe.png) - +![pysimplegui_logo](https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png) [![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 # PySimpleGUI (Ver 2.4) From 5af691c029ad6c4cb688d2eaf34369813d2567f0 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 24 Jul 2018 17:02:58 -0400 Subject: [PATCH 066/209] Logo --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index 343d06dee..bef49c49f 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,6 @@ ![pysimplegui_logo](https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png) + [![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 # PySimpleGUI (Ver 2.4) From 892adf86eebb9108f38d46b8b79ff23b29c1e1cb Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 24 Jul 2018 17:09:41 -0400 Subject: [PATCH 067/209] readme --- readme.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index bef49c49f..df5277239 100644 --- a/readme.md +++ b/readme.md @@ -5,8 +5,9 @@ # PySimpleGUI (Ver 2.4) -This really is a simple GUI, but also powerfully customizable. +Super-simple GUI to grasp... Powerfully customizable. +Looking to take your Python code from the world of command lines and into the convenience of a GUI? Have a Raspberry Pi with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK? Look no further, you've found your GUI package. import PySimpleGUI as sg From a723b6f4638945be3628d11ad08838ef2c5685fe Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 24 Jul 2018 17:15:47 -0400 Subject: [PATCH 068/209] Button Image example --- readme.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/readme.md b/readme.md index df5277239..6da4b2198 100644 --- a/readme.md +++ b/readme.md @@ -925,6 +925,14 @@ Three parameters are used for button images. image_size - Size of image file in pixels image_subsample - Amount to divide the size by. 2 means your image will be 1/2 the size. 3 means 1/3 +Here's an example form made with button images. +![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) + +You'll find the source code in the file Demo Media Player. Here is what the button calls look like to create media player form + + sg.ReadFormButton('Pause', button_color=sg.TRANSPARENT_BUTTON, + image_filename=image_pause, image_size=(50, 50), image_subsample=2, border_width=0) + This is one you'll have to experiment with at this point. Not up for an exhaustive explanation. From 13d99dcd75c385cf4c70a77c0cf673ba9b50334b Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 24 Jul 2018 17:44:23 -0400 Subject: [PATCH 069/209] Tabbed forms example and explanation --- Demo Tabbed Form.py | 89 +++++++++++++++++++++++++++++++++++++++++++++ readme.md | 14 ++++++- 2 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 Demo Tabbed Form.py diff --git a/Demo Tabbed Form.py b/Demo Tabbed Form.py new file mode 100644 index 000000000..305202ebb --- /dev/null +++ b/Demo Tabbed Form.py @@ -0,0 +1,89 @@ +import PySimpleGUI as sg + +MAX_NUMBER_OF_THREADS = 12 + +def eBaySuperSearcherGUI(): + # Drop Down list of options + configs = ('0 - Gruen - Started 2 days ago in Watches', + '1 - Gruen - Currently Active in Watches', + '2 - Alpina - Currently Active in Jewelry', + '3 - Gruen - Ends in 1 day in Watches', + '4 - Gruen - Completed in Watches', + '5 - Gruen - Advertising', + '6 - Gruen - Currently Active in Jewelry', + '7 - Gruen - Price Test', + '8 - Gruen - No brand name specified') + + us_categories = ('Use Default with no change', + 'All - 1', + 'Jewelry - 281', + ' Watches - 14324', + ' Wristwatches - 31387', + ' Pocket Watches - 3937', + 'Advertising - 34', + ' Watch Ads - 165254' + ) + + german_categories =('Use Default with no change', + 'All - 1', + 'Jewelry - 281', + ' Watches - 14324', + ' Wristwatches - 31387', + ' Pocket Watches - 3937', + 'Advertising - 1', + ' Watch Ads - 19823' + ) + + + # the form layout + with sg.FlexForm('EBay Super Searcher', auto_size_text=True) as form: + with sg.FlexForm('EBay Super Searcher') as form2: + layout_tab_1 = [[sg.Text('eBay Super Searcher!', size=(60,1), font=('helvetica', 15))], + [sg.Text('Choose base configuration to run')], + [sg.InputCombo(configs)], + [sg.Text('_'*100, size=(80,1))], + [sg.InputText(),sg.Text('Choose Destination Folder'), sg.FolderBrowse(target=(sg.ThisRow,0))], + [sg.InputText(),sg.Text('Custom text to add to folder name')], + [sg.Text('_'*100, size=(80,1))], + [sg.Checkbox('US', default=True, size=(15, 1)), sg.Checkbox('German', size=(15, 1), default=True, )], + [sg.Radio('Active Listings','ActiveComplete', default = True,size=(15, 1)), sg.Radio('Completed Listings', 'ActiveComplete', size=(15, 1))], + [sg.Text('_'*100, size=(80,1))], + [sg.Checkbox('Save Images', size=(15,1)),sg.Checkbox('Save PDFs', size=(15,1)), sg.Checkbox('Extract PDFs', size=(15,1))], + [sg.Text('_'*100, size=(80,1))], + [sg.Text('Time Filters')], + [sg.Radio('No change','time', default=True),sg.Radio('ALL listings','time'),sg.Radio('Started 1 day ago','time', size=(15,1)),sg.Radio('Started 2 days ago','time', size=(15,1)), sg.Radio('Ends in 1 day','time', size=(15,1))], + [sg.Text('_'*100, size=(80,1))], + [sg.Text('Price Range'), sg.InputText(size=(10,1)),sg.Text('To'), sg.InputText(size=(10,1))], + [sg.Text('_'*100, size=(80,1))], + [sg.Submit(button_color=('red', 'yellow')), sg.Cancel(button_color=('white', 'blue')), sg.Text(f'{MAX_NUMBER_OF_THREADS} Threads will be started')]] + + + # First category is default (need to special case this) + layout_tab_2 = [[sg.Text('Choose Category')], + [sg.Text('US Categories'),sg.Text('German Categories')], + [sg.Radio(us_categories[0],'CATUS', default=True), sg.Radio(german_categories[0], 'CATDE', default=True)]] + + for i,cat in enumerate(us_categories): + if i == 0: continue # skip first one + layout_tab_2.append([sg.Radio(cat,'CATUS'), sg.Radio(german_categories[i],'CATDE')]) + + + layout_tab_2.append([sg.Text('_' * 100, size=(75, 1))]) + layout_tab_2.append([sg.Text('US Search String Override')]) + layout_tab_2.append([sg.InputText(size=(100,1))]) + layout_tab_2.append([sg.Text('German Search String Override')]) + layout_tab_2.append([sg.InputText(size=(100,1))]) + layout_tab_2.append([sg.Text('Typical US Search String')]) + layout_tab_2.append([sg.InputText(size=(100,1), default_text='gruen -sara -quarz -quartz -embassy -bob -robert -elephants -adidas -LED ')]) + layout_tab_2.append([sg.Text('_' * 100, size=(75, 1))]) + layout_tab_2.append([sg.Submit(button_color=('red', 'yellow'),auto_size_text=True), sg.Cancel(button_color=('white', 'blue'), auto_size_text=True)]) + + results =sg.ShowTabbedForm('eBay Super Searcher', (form,layout_tab_1,'Where To Save'), (form2, layout_tab_2, 'Categories & Search String')) + + return results + + +if __name__ == '__main__': + results = eBaySuperSearcherGUI() + print(results) + sg.MsgBox('Results', results) \ No newline at end of file diff --git a/readme.md b/readme.md index 6da4b2198..6da141ebd 100644 --- a/readme.md +++ b/readme.md @@ -1023,9 +1023,18 @@ Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format results = ShowTabbedForm('Title for the form', (form,layout,'Tab 1 label'), - (form2,layout2, 'Tab 2 label')) + (form2,layout2, 'Tab 2 label'), ...) + +Each of the tabs of the form is in fact a form. The same steps are taken to create the form as before. A `FlexForm` is created, then rows are filled with Elements, and finally the form is shown. When calling `ShowTabbedForm`, each form is passed in as a tuple. The tuple has the format: `(the form, the rows, a string shown on the tab)` + +Results are returned as a list of lists. For each form you'll get a list that's in the same format as a normal form. A single tab's values would be: + + (button, (values)) + +Recall that values is a list as well. Multiple tabs in the form would return like this: + + ((button1, (values1)), (button2, (values2)) -Each of the tabs of the form is in fact a form. The same steps are taken to create the form as before. A `FlexForm` is created, then rows are filled with Elements, and finally the form is shown. When calling `ShowTabbedForm`, each form is passed in as a tuple. The tuple has the format: `(the form, the rows, a label shown on the tab)` ## Global Settings **Global Settings** @@ -1305,3 +1314,4 @@ For Python questions, I simply start my query with 'Python'. Let's say you forg In the hands of a competent programmer, this tool is **amazing**. It's a must-try kind of program that has completely changed my programming process. I'm not afraid of asking for help! You just have to be smart about using what you find. The PySimpleGUI window that the results are shown in is an 'input' field which means you can copy and paste the results right into your code. + From 2109bdbc97a464c123e0721c26741e35dd56592e Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 25 Jul 2018 06:40:14 -0400 Subject: [PATCH 070/209] Renamed demo files, new demo of tabbed forms Changed filenames to remove spaces so will be easier to work with on Linux. --- Demo_Color.py | 1729 +++++++++++++++++++++++++++++++++++ Demo_Compare_Files.py | 33 + Demo_DisplayHash1and256.py | 123 +++ Demo_DuplicateFileFinder.py | 57 ++ Demo_GoodColors.py | 50 + Demo_HowDoI.py | 55 ++ Demo_Media_Player.py | 64 ++ Demo_NonBlocking_Form.py | 59 ++ Demo_Recipes.py | 168 ++++ Demo_Tabbed_Form.py | 89 ++ 10 files changed, 2427 insertions(+) create mode 100644 Demo_Color.py create mode 100644 Demo_Compare_Files.py create mode 100644 Demo_DisplayHash1and256.py create mode 100644 Demo_DuplicateFileFinder.py create mode 100644 Demo_GoodColors.py create mode 100644 Demo_HowDoI.py create mode 100644 Demo_Media_Player.py create mode 100644 Demo_NonBlocking_Form.py create mode 100644 Demo_Recipes.py create mode 100644 Demo_Tabbed_Form.py diff --git a/Demo_Color.py b/Demo_Color.py new file mode 100644 index 000000000..142b19cba --- /dev/null +++ b/Demo_Color.py @@ -0,0 +1,1729 @@ +import PySimpleGUI as g + +MY_WINDOW_ICON = 'E:\\TheRealMyDocs\\Icons\\The Planets\\jupiter.ico' +reverse = {} +colorhex = {} + +colors = { + "abbey" : ( 76, 79, 86), + "acadia" : ( 27, 20, 4), + "acapulco" : (124, 176, 161), + "aero blue" : (201, 255, 229), + "affair" : (113, 70, 147), + "akaroa" : (212, 196, 168), + "alabaster" : (250, 250, 250), + "albescent white" : (245, 233, 211), + "algae green" : (147, 223, 184), + "alice blue" : (240, 248, 255), + "alizarin crimson" : (227, 38, 54), + "allports" : ( 0, 118, 163), + "almond" : (238, 217, 196), + "almond frost" : (144, 123, 113), + "alpine" : (175, 143, 44), + "alto" : (219, 219, 219), + "aluminium" : (169, 172, 182), + "amaranth" : (229, 43, 80), + "amazon" : ( 59, 122, 87), + "amber" : (255, 191, 0), + "americano" : (135, 117, 110), + "amethyst" : (153, 102, 204), + "amethyst smoke" : (163, 151, 180), + "amour" : (249, 234, 243), + "amulet" : (123, 159, 128), + "anakiwa" : (157, 229, 255), + "antique brass" : (200, 138, 101), + "antique bronze" : (112, 74, 7), + "anzac" : (224, 182, 70), + "apache" : (223, 190, 111), + "apple" : ( 79, 168, 61), + "apple blossom" : (175, 77, 67), + "apple green" : (226, 243, 236), + "apricot" : (235, 147, 115), + "apricot peach" : (251, 206, 177), + "apricot white" : (255, 254, 236), + "aqua deep" : ( 1, 75, 67), + "aqua forest" : ( 95, 167, 119), + "aqua haze" : (237, 245, 245), + "aqua island" : (161, 218, 215), + "aqua spring" : (234, 249, 245), + "aqua squeeze" : (232, 245, 242), + "aquamarine" : (127, 255, 212), + "aquamarine blue" : (113, 217, 226), + "arapawa" : ( 17, 12, 108), + "armadillo" : ( 67, 62, 55), + "arrowtown" : (148, 135, 113), + "ash" : (198, 195, 181), + "asparagus" : (123, 160, 91), + "asphalt" : ( 19, 10, 6), + "astra" : (250, 234, 185), + "astral" : ( 50, 125, 160), + "astronaut" : ( 40, 58, 119), + "astronaut blue" : ( 1, 62, 98), + "athens gray" : (238, 240, 243), + "aths special" : (236, 235, 206), + "atlantis" : (151, 205, 45), + "atoll" : ( 10, 111, 117), + "atomic tangerine" : (255, 153, 102), + "au chico" : (151, 96, 93), + "aubergine" : ( 59, 9, 16), + "australian mint" : (245, 255, 190), + "avocado" : (136, 141, 101), + "axolotl" : ( 78, 102, 73), + "azalea" : (247, 200, 218), + "aztec" : ( 13, 28, 25), + "azure" : ( 49, 91, 161), + "azure radiance" : ( 0, 127, 255), + "baby blue" : (224, 255, 255), + "bahama blue" : ( 2, 99, 149), + "bahia" : (165, 203, 12), + "baja white" : (255, 248, 209), + "bali hai" : (133, 159, 175), + "baltic sea" : ( 42, 38, 48), + "bamboo" : (218, 99, 4), + "banana mania" : (251, 231, 178), + "bandicoot" : (133, 132, 112), + "barberry" : (222, 215, 23), + "barley corn" : (166, 139, 91), + "barley white" : (255, 244, 206), + "barossa" : ( 68, 1, 45), + "bastille" : ( 41, 33, 48), + "battleship gray" : (130, 143, 114), + "bay leaf" : (125, 169, 141), + "bay of many" : ( 39, 58, 129), + "bazaar" : (152, 119, 123), + "bean " : ( 61, 12, 2), + "beauty bush" : (238, 193, 190), + "beaver" : (146, 111, 91), + "beeswax" : (254, 242, 199), + "beige" : (245, 245, 220), + "bermuda" : (125, 216, 198), + "bermuda gray" : (107, 139, 162), + "beryl green" : (222, 229, 192), + "bianca" : (252, 251, 243), + "big stone" : ( 22, 42, 64), + "bilbao" : ( 50, 124, 20), + "biloba flower" : (178, 161, 234), + "birch" : ( 55, 48, 33), + "bird flower" : (212, 205, 22), + "biscay" : ( 27, 49, 98), + "bismark" : ( 73, 113, 131), + "bison hide" : (193, 183, 164), + "bistre" : ( 61, 43, 31), + "bitter" : (134, 137, 116), + "bitter lemon" : (202, 224, 13), + "bittersweet" : (254, 111, 94), + "bizarre" : (238, 222, 218), + "black" : ( 0, 0, 0), + "black bean" : ( 8, 25, 16), + "black forest" : ( 11, 19, 4), + "black haze" : (246, 247, 247), + "black marlin" : ( 62, 44, 28), + "black olive" : ( 36, 46, 22), + "black pearl" : ( 4, 19, 34), + "black rock" : ( 13, 3, 50), + "black rose" : (103, 3, 45), + "black russian" : ( 10, 0, 28), + "black squeeze" : (242, 250, 250), + "black white" : (255, 254, 246), + "blackberry" : ( 77, 1, 53), + "blackcurrant" : ( 50, 41, 58), + "blaze orange" : (255, 102, 0), + "bleach white" : (254, 243, 216), + "bleached cedar" : ( 44, 33, 51), + "blizzard blue" : (163, 227, 237), + "blossom" : (220, 180, 188), + "blue" : ( 0, 0, 255), + "blue bayoux" : ( 73, 102, 121), + "blue bell" : (153, 153, 204), + "blue chalk" : (241, 233, 255), + "blue charcoal" : ( 1, 13, 26), + "blue chill" : ( 12, 137, 144), + "blue diamond" : ( 56, 4, 116), + "blue dianne" : ( 32, 72, 82), + "blue gem" : ( 44, 14, 140), + "blue haze" : (191, 190, 216), + "blue lagoon" : ( 1, 121, 135), + "blue marguerite" : (118, 102, 198), + "blue ribbon" : ( 0, 102, 255), + "blue romance" : (210, 246, 222), + "blue smoke" : (116, 136, 129), + "blue stone" : ( 1, 97, 98), + "blue violet" : (100, 86, 183), + "blue whale" : ( 4, 46, 76), + "blue zodiac" : ( 19, 38, 77), + "blumine" : ( 24, 88, 122), + "blush" : (180, 70, 104), + "blush pink" : (255, 111, 255), + "bombay" : (175, 177, 184), + "bon jour" : (229, 224, 225), + "bondi blue" : ( 0, 149, 182), + "bone" : (228, 209, 192), + "bordeaux" : ( 92, 1, 32), + "bossanova" : ( 78, 42, 90), + "boston blue" : ( 59, 145, 180), + "botticelli" : (199, 221, 229), + "bottle green" : ( 9, 54, 36), + "boulder" : (122, 122, 122), + "bouquet" : (174, 128, 158), + "bourbon" : (186, 111, 30), + "bracken" : ( 74, 42, 4), + "brandy" : (222, 193, 150), + "brandy punch" : (205, 132, 41), + "brandy rose" : (187, 137, 131), + "breaker bay" : ( 93, 161, 159), + "brick red" : (198, 45, 66), + "bridal heath" : (255, 250, 244), + "bridesmaid" : (254, 240, 236), + "bright gray" : ( 60, 65, 81), + "bright green" : (102, 255, 0), + "bright red" : (177, 0, 0), + "bright sun" : (254, 211, 60), + "bright turquoise" : ( 8, 232, 222), + "brilliant rose" : (246, 83, 166), + "brink pink" : (251, 96, 127), + "bronco" : (171, 161, 150), + "bronze" : ( 63, 33, 9), + "bronze olive" : ( 78, 66, 12), + "bronzetone" : ( 77, 64, 15), + "broom" : (255, 236, 19), + "brown" : (150, 75, 0), + "brown bramble" : ( 89, 40, 4), + "brown derby" : ( 73, 38, 21), + "brown pod" : ( 64, 24, 1), + "brown rust" : (175, 89, 62), + "brown tumbleweed" : ( 55, 41, 14), + "bubbles" : (231, 254, 255), + "buccaneer" : ( 98, 47, 48), + "bud" : (168, 174, 156), + "buddha gold" : (193, 160, 4), + "buff" : (240, 220, 130), + "bulgarian rose" : ( 72, 6, 7), + "bull shot" : (134, 77, 30), + "bunker" : ( 13, 17, 23), + "bunting" : ( 21, 31, 76), + "burgundy" : (144, 0, 32), + "burnham" : ( 0, 46, 32), + "burning orange" : (255, 112, 52), + "burning sand" : (217, 147, 118), + "burnt maroon" : ( 66, 3, 3), + "burnt orange" : (204, 85, 0), + "burnt sienna" : (233, 116, 81), + "burnt umber" : (138, 51, 36), + "bush" : ( 13, 46, 28), + "buttercup" : (243, 173, 22), + "buttered rum" : (161, 117, 13), + "butterfly bush" : ( 98, 78, 154), + "buttermilk" : (255, 241, 181), + "buttery white" : (255, 252, 234), + "cab sav" : ( 77, 10, 24), + "cabaret" : (217, 73, 114), + "cabbage pont" : ( 63, 76, 58), + "cactus" : ( 88, 113, 86), + "cadet blue" : (169, 178, 195), + "cadillac" : (176, 76, 106), + "cafe royale" : (111, 68, 12), + "calico" : (224, 192, 149), + "california" : (254, 157, 4), + "calypso" : ( 49, 114, 141), + "camarone" : ( 0, 88, 26), + "camelot" : (137, 52, 86), + "cameo" : (217, 185, 155), + "camouflage" : ( 60, 57, 16), + "camouflage green" : (120, 134, 107), + "can can" : (213, 145, 164), + "canary" : (243, 251, 98), + "candlelight" : (252, 217, 23), + "candy corn" : (251, 236, 93), + "cannon black" : ( 37, 23, 6), + "cannon pink" : (137, 67, 103), + "cape cod" : ( 60, 68, 67), + "cape honey" : (254, 229, 172), + "cape palliser" : (162, 102, 69), + "caper" : (220, 237, 180), + "caramel" : (255, 221, 175), + "cararra" : (238, 238, 232), + "cardin green" : ( 1, 54, 28), + "cardinal" : (196, 30, 58), + "cardinal pink" : (140, 5, 94), + "careys pink" : (210, 158, 170), + "caribbean green" : ( 0, 204, 153), + "carissma" : (234, 136, 168), + "carla" : (243, 255, 216), + "carmine" : (150, 0, 24), + "carnaby tan" : ( 92, 46, 1), + "carnation" : (249, 90, 97), + "carnation pink" : (255, 166, 201), + "carousel pink" : (249, 224, 237), + "carrot orange" : (237, 145, 33), + "casablanca" : (248, 184, 83), + "casal" : ( 47, 97, 104), + "cascade" : (139, 169, 165), + "cashmere" : (230, 190, 165), + "casper" : (173, 190, 209), + "castro" : ( 82, 0, 31), + "catalina blue" : ( 6, 42, 120), + "catskill white" : (238, 246, 247), + "cavern pink" : (227, 190, 190), + "cedar" : ( 62, 28, 20), + "cedar wood finish" : (113, 26, 0), + "celadon" : (172, 225, 175), + "celery" : (184, 194, 93), + "celeste" : (209, 210, 202), + "cello" : ( 30, 56, 91), + "celtic" : ( 22, 50, 34), + "cement" : (141, 118, 98), + "ceramic" : (252, 255, 249), + "cerise" : (218, 50, 135), + "cerise red" : (222, 49, 99), + "cerulean" : ( 2, 164, 211), + "cerulean blue" : ( 42, 82, 190), + "chablis" : (255, 244, 243), + "chalet green" : ( 81, 110, 61), + "chalky" : (238, 215, 148), + "chambray" : ( 53, 78, 140), + "chamois" : (237, 220, 177), + "champagne" : (250, 236, 204), + "chantilly" : (248, 195, 223), + "charade" : ( 41, 41, 55), + "chardon" : (255, 243, 241), + "chardonnay" : (255, 205, 140), + "charlotte" : (186, 238, 249), + "charm" : (212, 116, 148), + "chartreuse" : (127, 255, 0), + "chartreuse yellow" : (223, 255, 0), + "chateau green" : ( 64, 168, 96), + "chatelle" : (189, 179, 199), + "chathams blue" : ( 23, 85, 121), + "chelsea cucumber" : (131, 170, 93), + "chelsea gem" : (158, 83, 2), + "chenin" : (223, 205, 111), + "cherokee" : (252, 218, 152), + "cherry pie" : ( 42, 3, 89), + "cherrywood" : (101, 26, 20), + "cherub" : (248, 217, 233), + "chestnut" : (185, 78, 72), + "chestnut rose" : (205, 92, 92), + "chetwode blue" : (133, 129, 217), + "chicago" : ( 93, 92, 88), + "chiffon" : (241, 255, 200), + "chilean fire" : (247, 119, 3), + "chilean heath" : (255, 253, 230), + "china ivory" : (252, 255, 231), + "chino" : (206, 199, 167), + "chinook" : (168, 227, 189), + "chocolate" : ( 55, 2, 2), + "christalle" : ( 51, 3, 107), + "christi" : (103, 167, 18), + "christine" : (231, 115, 10), + "chrome white" : (232, 241, 212), + "cinder" : ( 14, 14, 24), + "cinderella" : (253, 225, 220), + "cinnabar" : (227, 66, 52), + "cinnamon" : (123, 63, 0), + "cioccolato" : ( 85, 40, 12), + "citrine white" : (250, 247, 214), + "citron" : (158, 169, 31), + "citrus" : (161, 197, 10), + "clairvoyant" : ( 72, 6, 86), + "clam shell" : (212, 182, 175), + "claret" : (127, 23, 52), + "classic rose" : (251, 204, 231), + "clay ash" : (189, 200, 179), + "clay creek" : (138, 131, 96), + "clear day" : (233, 255, 253), + "clementine" : (233, 110, 0), + "clinker" : ( 55, 29, 9), + "cloud" : (199, 196, 191), + "cloud burst" : ( 32, 46, 84), + "cloudy" : (172, 165, 159), + "clover" : ( 56, 73, 16), + "cobalt" : ( 0, 71, 171), + "cocoa bean" : ( 72, 28, 28), + "cocoa brown" : ( 48, 31, 30), + "coconut cream" : (248, 247, 220), + "cod gray" : ( 11, 11, 11), + "coffee" : (112, 101, 85), + "coffee bean" : ( 42, 20, 14), + "cognac" : (159, 56, 29), + "cola" : ( 63, 37, 0), + "cold purple" : (171, 160, 217), + "cold turkey" : (206, 186, 186), + "colonial white" : (255, 237, 188), + "comet" : ( 92, 93, 117), + "como" : ( 81, 124, 102), + "conch" : (201, 217, 210), + "concord" : (124, 123, 122), + "concrete" : (242, 242, 242), + "confetti" : (233, 215, 90), + "congo brown" : ( 89, 55, 55), + "congress blue" : ( 2, 71, 142), + "conifer" : (172, 221, 77), + "contessa" : (198, 114, 107), + "copper" : (184, 115, 51), + "copper canyon" : (126, 58, 21), + "copper rose" : (153, 102, 102), + "copper rust" : (148, 71, 71), + "copperfield" : (218, 138, 103), + "coral" : (255, 127, 80), + "coral red" : (255, 64, 64), + "coral reef" : (199, 188, 162), + "coral tree" : (168, 107, 107), + "corduroy" : ( 96, 110, 104), + "coriander" : (196, 208, 176), + "cork" : ( 64, 41, 29), + "corn" : (231, 191, 5), + "corn field" : (248, 250, 205), + "corn harvest" : (139, 107, 11), + "cornflower" : (147, 204, 234), + "cornflower blue" : (100, 149, 237), + "cornflower lilac" : (255, 176, 172), + "corvette" : (250, 211, 162), + "cosmic" : (118, 57, 93), + "cosmos" : (255, 216, 217), + "costa del sol" : ( 97, 93, 48), + "cotton candy" : (255, 183, 213), + "cotton seed" : (194, 189, 182), + "county green" : ( 1, 55, 26), + "cowboy" : ( 77, 40, 45), + "crail" : (185, 81, 64), + "cranberry" : (219, 80, 121), + "crater brown" : ( 70, 36, 37), + "cream" : (255, 253, 208), + "cream brulee" : (255, 229, 160), + "cream can" : (245, 200, 92), + "creole" : ( 30, 15, 4), + "crete" : (115, 120, 41), + "crimson" : (220, 20, 60), + "crocodile" : (115, 109, 88), + "crown of thorns" : (119, 31, 31), + "crowshead" : ( 28, 18, 8), + "cruise" : (181, 236, 223), + "crusoe" : ( 0, 72, 22), + "crusta" : (253, 123, 51), + "cumin" : (146, 67, 33), + "cumulus" : (253, 255, 213), + "cupid" : (251, 190, 218), + "curious blue" : ( 37, 150, 209), + "cutty sark" : ( 80, 118, 114), + "cyan / aqua" : ( 0, 255, 255), + "cyprus" : ( 0, 62, 64), + "daintree" : ( 1, 39, 49), + "dairy cream" : (249, 228, 188), + "daisy bush" : ( 79, 35, 152), + "dallas" : (110, 75, 38), + "dandelion" : (254, 216, 93), + "danube" : ( 96, 147, 209), + "dark blue" : ( 0, 0, 200), + "dark burgundy" : (119, 15, 5), + "dark ebony" : ( 60, 32, 5), + "dark fern" : ( 10, 72, 13), + "dark tan" : (102, 16, 16), + "dawn" : (166, 162, 154), + "dawn pink" : (243, 233, 229), + "de york" : (122, 196, 136), + "deco" : (210, 218, 151), + "deep blue" : ( 34, 8, 120), + "deep blush" : (228, 118, 152), + "deep bronze" : ( 74, 48, 4), + "deep cerulean" : ( 0, 123, 167), + "deep cove" : ( 5, 16, 64), + "deep fir" : ( 0, 41, 0), + "deep forest green" : ( 24, 45, 9), + "deep koamaru" : ( 27, 18, 123), + "deep oak" : ( 65, 32, 16), + "deep sapphire" : ( 8, 37, 103), + "deep sea" : ( 1, 130, 107), + "deep sea green" : ( 9, 88, 89), + "deep teal" : ( 0, 53, 50), + "del rio" : (176, 154, 149), + "dell" : ( 57, 100, 19), + "delta" : (164, 164, 157), + "deluge" : (117, 99, 168), + "denim" : ( 21, 96, 189), + "derby" : (255, 238, 216), + "desert" : (174, 96, 32), + "desert sand" : (237, 201, 175), + "desert storm" : (248, 248, 247), + "dew" : (234, 255, 254), + "di serria" : (219, 153, 94), + "diesel" : ( 19, 0, 0), + "dingley" : ( 93, 119, 71), + "disco" : (135, 21, 80), + "dixie" : (226, 148, 24), + "dodger blue" : ( 30, 144, 255), + "dolly" : (249, 255, 139), + "dolphin" : (100, 96, 119), + "domino" : (142, 119, 94), + "don juan" : ( 93, 76, 81), + "donkey brown" : (166, 146, 121), + "dorado" : (107, 87, 85), + "double colonial white" : (238, 227, 173), + "double pearl lusta" : (252, 244, 208), + "double spanish white" : (230, 215, 185), + "dove gray" : (109, 108, 108), + "downriver" : ( 9, 34, 86), + "downy" : (111, 208, 197), + "driftwood" : (175, 135, 81), + "drover" : (253, 247, 173), + "dull lavender" : (168, 153, 230), + "dune" : ( 56, 53, 51), + "dust storm" : (229, 204, 201), + "dusty gray" : (168, 152, 155), + "eagle" : (182, 186, 164), + "earls green" : (201, 185, 59), + "early dawn" : (255, 249, 230), + "east bay" : ( 65, 76, 125), + "east side" : (172, 145, 206), + "eastern blue" : ( 30, 154, 176), + "ebb" : (233, 227, 227), + "ebony" : ( 12, 11, 29), + "ebony clay" : ( 38, 40, 59), + "eclipse" : ( 49, 28, 23), + "ecru white" : (245, 243, 229), + "ecstasy" : (250, 120, 20), + "eden" : ( 16, 88, 82), + "edgewater" : (200, 227, 215), + "edward" : (162, 174, 171), + "egg sour" : (255, 244, 221), + "egg white" : (255, 239, 193), + "eggplant" : ( 97, 64, 81), + "el paso" : ( 30, 23, 8), + "el salva" : (143, 62, 51), + "electric lime" : (204, 255, 0), + "electric violet" : (139, 0, 255), + "elephant" : ( 18, 52, 71), + "elf green" : ( 8, 131, 112), + "elm" : ( 28, 124, 125), + "emerald" : ( 80, 200, 120), + "eminence" : (108, 48, 130), + "emperor" : ( 81, 70, 73), + "empress" : (129, 115, 119), + "endeavour" : ( 0, 86, 167), + "energy yellow" : (248, 221, 92), + "english holly" : ( 2, 45, 21), + "english walnut" : ( 62, 43, 35), + "envy" : (139, 166, 144), + "equator" : (225, 188, 100), + "espresso" : ( 97, 39, 24), + "eternity" : ( 33, 26, 14), + "eucalyptus" : ( 39, 138, 91), + "eunry" : (207, 163, 157), + "evening sea" : ( 2, 78, 70), + "everglade" : ( 28, 64, 46), + "faded jade" : ( 66, 121, 119), + "fair pink" : (255, 239, 236), + "falcon" : (127, 98, 109), + "fall green" : (236, 235, 189), + "falu red" : (128, 24, 24), + "fantasy" : (250, 243, 240), + "fedora" : (121, 106, 120), + "feijoa" : (159, 221, 140), + "fern" : ( 99, 183, 108), + "fern frond" : (101, 114, 32), + "fern green" : ( 79, 121, 66), + "ferra" : (112, 79, 80), + "festival" : (251, 233, 108), + "feta" : (240, 252, 234), + "fiery orange" : (179, 82, 19), + "finch" : ( 98, 102, 73), + "finlandia" : ( 85, 109, 86), + "finn" : (105, 45, 84), + "fiord" : ( 64, 81, 105), + "fire" : (170, 66, 3), + "fire bush" : (232, 153, 40), + "firefly" : ( 14, 42, 48), + "flame pea" : (218, 91, 56), + "flamenco" : (255, 125, 7), + "flamingo" : (242, 85, 42), + "flax" : (238, 220, 130), + "flax smoke" : (123, 130, 101), + "flesh" : (255, 203, 164), + "flint" : (111, 106, 97), + "flirt" : (162, 0, 109), + "flush mahogany" : (202, 52, 53), + "flush orange" : (255, 127, 0), + "foam" : (216, 252, 250), + "fog" : (215, 208, 255), + "foggy gray" : (203, 202, 182), + "forest green" : ( 34, 139, 34), + "forget me not" : (255, 241, 238), + "fountain blue" : ( 86, 180, 190), + "frangipani" : (255, 222, 179), + "french gray" : (189, 189, 198), + "french lilac" : (236, 199, 238), + "french pass" : (189, 237, 253), + "french rose" : (246, 74, 138), + "fresh eggplant" : (153, 0, 102), + "friar gray" : (128, 126, 121), + "fringy flower" : (177, 226, 193), + "froly" : (245, 117, 132), + "frost" : (237, 245, 221), + "frosted mint" : (219, 255, 248), + "frostee" : (228, 246, 231), + "fruit salad" : ( 79, 157, 93), + "fuchsia blue" : (122, 88, 193), + "fuchsia pink" : (193, 84, 193), + "fuego" : (190, 222, 13), + "fuel yellow" : (236, 169, 39), + "fun blue" : ( 25, 89, 168), + "fun green" : ( 1, 109, 57), + "fuscous gray" : ( 84, 83, 77), + "fuzzy wuzzy brown" : (196, 86, 85), + "gable green" : ( 22, 53, 49), + "gallery" : (239, 239, 239), + "galliano" : (220, 178, 12), + "gamboge" : (228, 155, 15), + "geebung" : (209, 143, 27), + "genoa" : ( 21, 115, 107), + "geraldine" : (251, 137, 137), + "geyser" : (212, 223, 226), + "ghost" : (199, 201, 213), + "gigas" : ( 82, 60, 148), + "gimblet" : (184, 181, 106), + "gin" : (232, 242, 235), + "gin fizz" : (255, 249, 226), + "givry" : (248, 228, 191), + "glacier" : (128, 179, 196), + "glade green" : ( 97, 132, 95), + "go ben" : (114, 109, 78), + "goblin" : ( 61, 125, 82), + "gold" : (255, 215, 0), + "gold drop" : (241, 130, 0), + "gold sand" : (230, 190, 138), + "gold tips" : (222, 186, 19), + "golden bell" : (226, 137, 19), + "golden dream" : (240, 213, 45), + "golden fizz" : (245, 251, 61), + "golden glow" : (253, 226, 149), + "golden grass" : (218, 165, 32), + "golden sand" : (240, 219, 125), + "golden tainoi" : (255, 204, 92), + "goldenrod" : (252, 214, 103), + "gondola" : ( 38, 20, 20), + "gordons green" : ( 11, 17, 7), + "gorse" : (255, 241, 79), + "gossamer" : ( 6, 155, 129), + "gossip" : (210, 248, 176), + "gothic" : (109, 146, 161), + "governor bay" : ( 47, 60, 179), + "grain brown" : (228, 213, 183), + "grandis" : (255, 211, 140), + "granite green" : (141, 137, 116), + "granny apple" : (213, 246, 227), + "granny smith" : (132, 160, 160), + "granny smith apple" : (157, 224, 147), + "grape" : ( 56, 26, 81), + "graphite" : ( 37, 22, 7), + "gravel" : ( 74, 68, 75), + "gray" : (128, 128, 128), + "gray asparagus" : ( 70, 89, 69), + "gray chateau" : (162, 170, 179), + "gray nickel" : (195, 195, 189), + "gray nurse" : (231, 236, 230), + "gray olive" : (169, 164, 145), + "gray suit" : (193, 190, 205), + "green" : ( 0, 255, 0), + "green haze" : ( 1, 163, 104), + "green house" : ( 36, 80, 15), + "green kelp" : ( 37, 49, 28), + "green leaf" : ( 67, 106, 13), + "green mist" : (203, 211, 176), + "green pea" : ( 29, 97, 66), + "green smoke" : (164, 175, 110), + "green spring" : (184, 193, 177), + "green vogue" : ( 3, 43, 82), + "green waterloo" : ( 16, 20, 5), + "green white" : (232, 235, 224), + "green yellow" : (173, 255, 47), + "grenadier" : (213, 70, 0), + "guardsman red" : (186, 1, 1), + "gulf blue" : ( 5, 22, 87), + "gulf stream" : (128, 179, 174), + "gull gray" : (157, 172, 183), + "gum leaf" : (182, 211, 191), + "gumbo" : (124, 161, 166), + "gun powder" : ( 65, 66, 87), + "gunsmoke" : (130, 134, 133), + "gurkha" : (154, 149, 119), + "hacienda" : (152, 129, 27), + "hairy heath" : (107, 42, 20), + "haiti" : ( 27, 16, 53), + "half baked" : (133, 196, 204), + "half colonial white" : (253, 246, 211), + "half dutch white" : (254, 247, 222), + "half spanish white" : (254, 244, 219), + "half and half" : (255, 254, 225), + "hampton" : (229, 216, 175), + "harlequin" : ( 63, 255, 0), + "harp" : (230, 242, 234), + "harvest gold" : (224, 185, 116), + "havelock blue" : ( 85, 144, 217), + "hawaiian tan" : (157, 86, 22), + "hawkes blue" : (212, 226, 252), + "heath" : ( 84, 16, 18), + "heather" : (183, 195, 208), + "heathered gray" : (182, 176, 149), + "heavy metal" : ( 43, 50, 40), + "heliotrope" : (223, 115, 255), + "hemlock" : ( 94, 93, 59), + "hemp" : (144, 120, 116), + "hibiscus" : (182, 49, 108), + "highland" : (111, 142, 99), + "hillary" : (172, 165, 134), + "himalaya" : (106, 93, 27), + "hint of green" : (230, 255, 233), + "hint of red" : (251, 249, 249), + "hint of yellow" : (250, 253, 228), + "hippie blue" : ( 88, 154, 175), + "hippie green" : ( 83, 130, 75), + "hippie pink" : (174, 69, 96), + "hit gray" : (161, 173, 181), + "hit pink" : (255, 171, 129), + "hokey pokey" : (200, 165, 40), + "hoki" : (101, 134, 159), + "holly" : ( 1, 29, 19), + "hollywood cerise" : (244, 0, 161), + "honey flower" : ( 79, 28, 112), + "honeysuckle" : (237, 252, 132), + "hopbush" : (208, 109, 161), + "horizon" : ( 90, 135, 160), + "horses neck" : ( 96, 73, 19), + "hot cinnamon" : (210, 105, 30), + "hot pink" : (255, 105, 180), + "hot toddy" : (179, 128, 7), + "humming bird" : (207, 249, 243), + "hunter green" : ( 22, 29, 16), + "hurricane" : (135, 124, 123), + "husk" : (183, 164, 88), + "ice cold" : (177, 244, 231), + "iceberg" : (218, 244, 240), + "illusion" : (246, 164, 201), + "inch worm" : (176, 227, 19), + "indian khaki" : (195, 176, 145), + "indian tan" : ( 77, 30, 1), + "indigo" : ( 79, 105, 198), + "indochine" : (194, 107, 3), + "international klein blue" : ( 0, 47, 167), + "international orange" : (255, 79, 0), + "irish coffee" : ( 95, 61, 38), + "iroko" : ( 67, 49, 32), + "iron" : (212, 215, 217), + "ironside gray" : (103, 102, 98), + "ironstone" : (134, 72, 60), + "island spice" : (255, 252, 238), + "ivory" : (255, 255, 240), + "jacaranda" : ( 46, 3, 41), + "jacarta" : ( 58, 42, 106), + "jacko bean" : ( 46, 25, 5), + "jacksons purple" : ( 32, 32, 141), + "jade" : ( 0, 168, 107), + "jaffa" : (239, 134, 63), + "jagged ice" : (194, 232, 229), + "jagger" : ( 53, 14, 87), + "jaguar" : ( 8, 1, 16), + "jambalaya" : ( 91, 48, 19), + "janna" : (244, 235, 211), + "japanese laurel" : ( 10, 105, 6), + "japanese maple" : (120, 1, 9), + "japonica" : (216, 124, 99), + "java" : ( 31, 194, 194), + "jazzberry jam" : (165, 11, 94), + "jelly bean" : ( 41, 123, 154), + "jet stream" : (181, 210, 206), + "jewel" : ( 18, 107, 64), + "jon" : ( 59, 31, 31), + "jonquil" : (238, 255, 154), + "jordy blue" : (138, 185, 241), + "judge gray" : ( 84, 67, 51), + "jumbo" : (124, 123, 130), + "jungle green" : ( 41, 171, 135), + "jungle mist" : (180, 207, 211), + "juniper" : (109, 146, 146), + "just right" : (236, 205, 185), + "kabul" : ( 94, 72, 62), + "kaitoke green" : ( 0, 70, 32), + "kangaroo" : (198, 200, 189), + "karaka" : ( 30, 22, 9), + "karry" : (255, 234, 212), + "kashmir blue" : ( 80, 112, 150), + "kelp" : ( 69, 73, 54), + "kenyan copper" : (124, 28, 5), + "keppel" : ( 58, 176, 158), + "key lime pie" : (191, 201, 33), + "khaki" : (240, 230, 140), + "kidnapper" : (225, 234, 212), + "kilamanjaro" : ( 36, 12, 2), + "killarney" : ( 58, 106, 71), + "kimberly" : (115, 108, 159), + "kingfisher daisy" : ( 62, 4, 128), + "kobi" : (231, 159, 196), + "kokoda" : (110, 109, 87), + "korma" : (143, 75, 14), + "koromiko" : (255, 189, 95), + "kournikova" : (255, 231, 114), + "kumera" : (136, 98, 33), + "la palma" : ( 54, 135, 22), + "la rioja" : (179, 193, 16), + "las palmas" : (198, 230, 16), + "laser" : (200, 181, 104), + "laser lemon" : (255, 255, 102), + "laurel" : (116, 147, 120), + "lavender" : (181, 126, 220), + "lavender gray" : (189, 187, 215), + "lavender magenta" : (238, 130, 238), + "lavender pink" : (251, 174, 210), + "lavender purple" : (150, 123, 182), + "lavender rose" : (251, 160, 227), + "lavender blush" : (255, 240, 245), + "leather" : (150, 112, 89), + "lemon" : (253, 233, 16), + "lemon chiffon" : (255, 250, 205), + "lemon ginger" : (172, 158, 34), + "lemon grass" : (155, 158, 143), + "light apricot" : (253, 213, 177), + "light orchid" : (226, 156, 210), + "light wisteria" : (201, 160, 220), + "lightning yellow" : (252, 192, 30), + "lilac" : (200, 162, 200), + "lilac bush" : (152, 116, 211), + "lily" : (200, 170, 191), + "lily white" : (231, 248, 255), + "lima" : (118, 189, 23), + "lime" : (191, 255, 0), + "limeade" : (111, 157, 2), + "limed ash" : (116, 125, 99), + "limed oak" : (172, 138, 86), + "limed spruce" : ( 57, 72, 81), + "linen" : (250, 240, 230), + "link water" : (217, 228, 245), + "lipstick" : (171, 5, 99), + "lisbon brown" : ( 66, 57, 33), + "livid brown" : ( 77, 40, 46), + "loafer" : (238, 244, 222), + "loblolly" : (189, 201, 206), + "lochinvar" : ( 44, 140, 132), + "lochmara" : ( 0, 126, 199), + "locust" : (168, 175, 142), + "log cabin" : ( 36, 42, 29), + "logan" : (170, 169, 205), + "lola" : (223, 207, 219), + "london hue" : (190, 166, 195), + "lonestar" : (109, 1, 1), + "lotus" : (134, 60, 60), + "loulou" : ( 70, 11, 65), + "lucky" : (175, 159, 28), + "lucky point" : ( 26, 26, 104), + "lunar green" : ( 60, 73, 58), + "luxor gold" : (167, 136, 44), + "lynch" : (105, 126, 154), + "mabel" : (217, 247, 255), + "macaroni and cheese" : (255, 185, 123), + "madang" : (183, 240, 190), + "madison" : ( 9, 37, 93), + "madras" : ( 63, 48, 2), + "magenta / fuchsia" : (255, 0, 255), + "magic mint" : (170, 240, 209), + "magnolia" : (248, 244, 255), + "mahogany" : ( 78, 6, 6), + "mai tai" : (176, 102, 8), + "maize" : (245, 213, 160), + "makara" : (137, 125, 109), + "mako" : ( 68, 73, 84), + "malachite" : ( 11, 218, 81), + "malibu" : (125, 200, 247), + "mallard" : ( 35, 52, 24), + "malta" : (189, 178, 161), + "mamba" : (142, 129, 144), + "manatee" : (141, 144, 161), + "mandalay" : (173, 120, 27), + "mandy" : (226, 84, 101), + "mandys pink" : (242, 195, 178), + "mango tango" : (231, 114, 0), + "manhattan" : (245, 201, 153), + "mantis" : (116, 195, 101), + "mantle" : (139, 156, 144), + "manz" : (238, 239, 120), + "mardi gras" : ( 53, 0, 54), + "marigold" : (185, 141, 40), + "marigold yellow" : (251, 232, 112), + "mariner" : ( 40, 106, 205), + "maroon" : (128, 0, 0), + "maroon flush" : (195, 33, 72), + "maroon oak" : ( 82, 12, 23), + "marshland" : ( 11, 15, 8), + "martini" : (175, 160, 158), + "martinique" : ( 54, 48, 80), + "marzipan" : (248, 219, 157), + "masala" : ( 64, 59, 56), + "matisse" : ( 27, 101, 157), + "matrix" : (176, 93, 84), + "matterhorn" : ( 78, 59, 65), + "mauve" : (224, 176, 255), + "mauvelous" : (240, 145, 169), + "maverick" : (216, 194, 213), + "medium carmine" : (175, 64, 53), + "medium purple" : (147, 112, 219), + "medium red violet" : (187, 51, 133), + "melanie" : (228, 194, 213), + "melanzane" : ( 48, 5, 41), + "melon" : (254, 186, 173), + "melrose" : (199, 193, 255), + "mercury" : (229, 229, 229), + "merino" : (246, 240, 230), + "merlin" : ( 65, 60, 55), + "merlot" : (131, 25, 35), + "metallic bronze" : ( 73, 55, 27), + "metallic copper" : (113, 41, 29), + "meteor" : (208, 125, 18), + "meteorite" : ( 60, 31, 118), + "mexican red" : (167, 37, 37), + "mid gray" : ( 95, 95, 110), + "midnight" : ( 1, 22, 53), + "midnight blue" : ( 0, 51, 102), + "midnight moss" : ( 4, 16, 4), + "mikado" : ( 45, 37, 16), + "milan" : (250, 255, 164), + "milano red" : (184, 17, 4), + "milk punch" : (255, 246, 212), + "millbrook" : ( 89, 68, 51), + "mimosa" : (248, 253, 211), + "mindaro" : (227, 249, 136), + "mine shaft" : ( 50, 50, 50), + "mineral green" : ( 63, 93, 83), + "ming" : ( 54, 116, 125), + "minsk" : ( 63, 48, 127), + "mint green" : (152, 255, 152), + "mint julep" : (241, 238, 193), + "mint tulip" : (196, 244, 235), + "mirage" : ( 22, 25, 40), + "mischka" : (209, 210, 221), + "mist gray" : (196, 196, 188), + "mobster" : (127, 117, 137), + "moccaccino" : (110, 29, 20), + "mocha" : (120, 45, 25), + "mojo" : (192, 71, 55), + "mona lisa" : (255, 161, 148), + "monarch" : (139, 7, 35), + "mondo" : ( 74, 60, 48), + "mongoose" : (181, 162, 127), + "monsoon" : (138, 131, 137), + "monte carlo" : (131, 208, 198), + "monza" : (199, 3, 30), + "moody blue" : (127, 118, 211), + "moon glow" : (252, 254, 218), + "moon mist" : (220, 221, 204), + "moon raker" : (214, 206, 246), + "morning glory" : (158, 222, 224), + "morocco brown" : ( 68, 29, 0), + "mortar" : ( 80, 67, 81), + "mosque" : ( 3, 106, 110), + "moss green" : (173, 223, 173), + "mountain meadow" : ( 26, 179, 133), + "mountain mist" : (149, 147, 150), + "mountbatten pink" : (153, 122, 141), + "muddy waters" : (183, 142, 92), + "muesli" : (170, 139, 91), + "mulberry" : (197, 75, 140), + "mulberry wood" : ( 92, 5, 54), + "mule fawn" : (140, 71, 47), + "mulled wine" : ( 78, 69, 98), + "mustard" : (255, 219, 88), + "my pink" : (214, 145, 136), + "my sin" : (255, 179, 31), + "mystic" : (226, 235, 237), + "nandor" : ( 75, 93, 82), + "napa" : (172, 164, 148), + "narvik" : (237, 249, 241), + "natural gray" : (139, 134, 128), + "navajo white" : (255, 222, 173), + "navy blue" : ( 0, 0, 128), + "nebula" : (203, 219, 214), + "negroni" : (255, 226, 197), + "neon carrot" : (255, 153, 51), + "nepal" : (142, 171, 193), + "neptune" : (124, 183, 187), + "nero" : ( 20, 6, 0), + "nevada" : (100, 110, 117), + "new orleans" : (243, 214, 157), + "new york pink" : (215, 131, 127), + "niagara" : ( 6, 161, 137), + "night rider" : ( 31, 18, 15), + "night shadz" : (170, 55, 90), + "nile blue" : ( 25, 55, 81), + "nobel" : (183, 177, 177), + "nomad" : (186, 177, 162), + "norway" : (168, 189, 159), + "nugget" : (197, 153, 34), + "nutmeg" : (129, 66, 44), + "nutmeg wood finish" : (104, 54, 0), + "oasis" : (254, 239, 206), + "observatory" : ( 2, 134, 111), + "ocean green" : ( 65, 170, 120), + "ochre" : (204, 119, 34), + "off green" : (230, 248, 243), + "off yellow" : (254, 249, 227), + "oil" : ( 40, 30, 21), + "old brick" : (144, 30, 30), + "old copper" : (114, 74, 47), + "old gold" : (207, 181, 59), + "old lace" : (253, 245, 230), + "old lavender" : (121, 104, 120), + "old rose" : (192, 128, 129), + "olive" : (128, 128, 0), + "olive drab" : (107, 142, 35), + "olive green" : (181, 179, 92), + "olive haze" : (139, 132, 112), + "olivetone" : (113, 110, 16), + "olivine" : (154, 185, 115), + "onahau" : (205, 244, 255), + "onion" : ( 47, 39, 14), + "opal" : (169, 198, 194), + "opium" : (142, 111, 112), + "oracle" : ( 55, 116, 117), + "orange" : (255, 104, 31), + "orange peel" : (255, 160, 0), + "orange roughy" : (196, 87, 25), + "orange white" : (254, 252, 237), + "orchid" : (218, 112, 214), + "orchid white" : (255, 253, 243), + "oregon" : (155, 71, 3), + "orient" : ( 1, 94, 133), + "oriental pink" : (198, 145, 145), + "orinoco" : (243, 251, 212), + "oslo gray" : (135, 141, 145), + "ottoman" : (233, 248, 237), + "outer space" : ( 45, 56, 58), + "outrageous orange" : (255, 96, 55), + "oxford blue" : ( 56, 69, 85), + "oxley" : (119, 158, 134), + "oyster bay" : (218, 250, 255), + "oyster pink" : (233, 206, 205), + "paarl" : (166, 85, 41), + "pablo" : (119, 111, 97), + "pacific blue" : ( 0, 157, 196), + "pacifika" : (119, 129, 32), + "paco" : ( 65, 31, 16), + "padua" : (173, 230, 196), + "pale canary" : (255, 255, 153), + "pale leaf" : (192, 211, 185), + "pale oyster" : (152, 141, 119), + "pale prim" : (253, 254, 184), + "pale rose" : (255, 225, 242), + "pale sky" : (110, 119, 131), + "pale slate" : (195, 191, 193), + "palm green" : ( 9, 35, 15), + "palm leaf" : ( 25, 51, 14), + "pampas" : (244, 242, 238), + "panache" : (234, 246, 238), + "pancho" : (237, 205, 171), + "papaya whip" : (255, 239, 213), + "paprika" : (141, 2, 38), + "paradiso" : ( 49, 125, 130), + "parchment" : (241, 233, 210), + "paris daisy" : (255, 244, 110), + "paris m" : ( 38, 5, 106), + "paris white" : (202, 220, 212), + "parsley" : ( 19, 79, 25), + "pastel green" : (119, 221, 119), + "pastel pink" : (255, 209, 220), + "patina" : ( 99, 154, 143), + "pattens blue" : (222, 245, 255), + "paua" : ( 38, 3, 104), + "pavlova" : (215, 196, 152), + "peach" : (255, 229, 180), + "peach cream" : (255, 240, 219), + "peach orange" : (255, 204, 153), + "peach schnapps" : (255, 220, 214), + "peach yellow" : (250, 223, 173), + "peanut" : (120, 47, 22), + "pear" : (209, 226, 49), + "pearl bush" : (232, 224, 213), + "pearl lusta" : (252, 244, 220), + "peat" : (113, 107, 86), + "pelorous" : ( 62, 171, 191), + "peppermint" : (227, 245, 225), + "perano" : (169, 190, 242), + "perfume" : (208, 190, 248), + "periglacial blue" : (225, 230, 214), + "periwinkle" : (204, 204, 255), + "periwinkle gray" : (195, 205, 230), + "persian blue" : ( 28, 57, 187), + "persian green" : ( 0, 166, 147), + "persian indigo" : ( 50, 18, 122), + "persian pink" : (247, 127, 190), + "persian plum" : (112, 28, 28), + "persian red" : (204, 51, 51), + "persian rose" : (254, 40, 162), + "persimmon" : (255, 107, 83), + "peru tan" : (127, 58, 2), + "pesto" : (124, 118, 49), + "petite orchid" : (219, 150, 144), + "pewter" : (150, 168, 161), + "pharlap" : (163, 128, 123), + "picasso" : (255, 243, 157), + "pickled bean" : (110, 72, 38), + "pickled bluewood" : ( 49, 68, 89), + "picton blue" : ( 69, 177, 232), + "pig pink" : (253, 215, 228), + "pigeon post" : (175, 189, 217), + "pigment indigo" : ( 75, 0, 130), + "pine cone" : (109, 94, 84), + "pine glade" : (199, 205, 144), + "pine green" : ( 1, 121, 111), + "pine tree" : ( 23, 31, 4), + "pink" : (255, 192, 203), + "pink flamingo" : (255, 102, 255), + "pink flare" : (225, 192, 200), + "pink lace" : (255, 221, 244), + "pink lady" : (255, 241, 216), + "pink salmon" : (255, 145, 164), + "pink swan" : (190, 181, 183), + "piper" : (201, 99, 35), + "pipi" : (254, 244, 204), + "pippin" : (255, 225, 223), + "pirate gold" : (186, 127, 3), + "pistachio" : (157, 194, 9), + "pixie green" : (192, 216, 182), + "pizazz" : (255, 144, 0), + "pizza" : (201, 148, 21), + "plantation" : ( 39, 80, 75), + "plum" : (132, 49, 121), + "pohutukawa" : (143, 2, 28), + "polar" : (229, 249, 246), + "polo blue" : (141, 168, 204), + "pomegranate" : (243, 71, 35), + "pompadour" : (102, 0, 69), + "porcelain" : (239, 242, 243), + "porsche" : (234, 174, 105), + "port gore" : ( 37, 31, 79), + "portafino" : (255, 255, 180), + "portage" : (139, 159, 238), + "portica" : (249, 230, 99), + "pot pourri" : (245, 231, 226), + "potters clay" : (140, 87, 56), + "powder ash" : (188, 201, 194), + "powder blue" : (176, 224, 230), + "prairie sand" : (154, 56, 32), + "prelude" : (208, 192, 229), + "prim" : (240, 226, 236), + "primrose" : (237, 234, 153), + "provincial pink" : (254, 245, 241), + "prussian blue" : ( 0, 49, 83), + "puce" : (204, 136, 153), + "pueblo" : (125, 44, 20), + "puerto rico" : ( 63, 193, 170), + "pumice" : (194, 202, 196), + "pumpkin" : (255, 117, 24), + "pumpkin skin" : (177, 97, 11), + "punch" : (220, 67, 51), + "punga" : ( 77, 61, 20), + "purple" : (102, 0, 153), + "purple heart" : (101, 45, 193), + "purple mountain's majesty" : (150, 120, 182), + "purple pizzazz" : (255, 0, 204), + "putty" : (231, 205, 140), + "quarter pearl lusta" : (255, 253, 244), + "quarter spanish white" : (247, 242, 225), + "quicksand" : (189, 151, 142), + "quill gray" : (214, 214, 209), + "quincy" : ( 98, 63, 45), + "racing green" : ( 12, 25, 17), + "radical red" : (255, 53, 94), + "raffia" : (234, 218, 184), + "rainee" : (185, 200, 172), + "rajah" : (247, 182, 104), + "rangitoto" : ( 46, 50, 34), + "rangoon green" : ( 28, 30, 19), + "raven" : (114, 123, 137), + "raw sienna" : (210, 125, 70), + "raw umber" : (115, 74, 18), + "razzle dazzle rose" : (255, 51, 204), + "razzmatazz" : (227, 11, 92), + "rebel" : ( 60, 18, 6), + "red" : (255, 0, 0), + "red beech" : (123, 56, 1), + "red berry" : (142, 0, 0), + "red damask" : (218, 106, 65), + "red devil" : (134, 1, 17), + "red orange" : (255, 63, 52), + "red oxide" : (110, 9, 2), + "red ribbon" : (237, 10, 63), + "red robin" : (128, 52, 31), + "red stage" : (208, 95, 4), + "red violet" : (199, 21, 133), + "redwood" : ( 93, 30, 15), + "reef" : (201, 255, 162), + "reef gold" : (159, 130, 28), + "regal blue" : ( 1, 63, 106), + "regent gray" : (134, 148, 159), + "regent st blue" : (170, 214, 230), + "remy" : (254, 235, 243), + "reno sand" : (168, 101, 21), + "resolution blue" : ( 0, 35, 135), + "revolver" : ( 44, 22, 50), + "rhino" : ( 46, 63, 98), + "rice cake" : (255, 254, 240), + "rice flower" : (238, 255, 226), + "rich gold" : (168, 83, 7), + "rio grande" : (187, 208, 9), + "ripe lemon" : (244, 216, 28), + "ripe plum" : ( 65, 0, 86), + "riptide" : (139, 230, 216), + "river bed" : ( 67, 76, 89), + "rob roy" : (234, 198, 116), + "robin's egg blue" : ( 0, 204, 204), + "rock" : ( 77, 56, 51), + "rock blue" : (158, 177, 205), + "rock spray" : (186, 69, 12), + "rodeo dust" : (201, 178, 155), + "rolling stone" : (116, 125, 131), + "roman" : (222, 99, 96), + "roman coffee" : (121, 93, 76), + "romance" : (255, 254, 253), + "romantic" : (255, 210, 183), + "ronchi" : (236, 197, 78), + "roof terracotta" : (166, 47, 32), + "rope" : (142, 77, 30), + "rose" : (255, 0, 127), + "rose bud" : (251, 178, 163), + "rose bud cherry" : (128, 11, 71), + "rose fog" : (231, 188, 180), + "rose white" : (255, 246, 245), + "rose of sharon" : (191, 85, 0), + "rosewood" : (101, 0, 11), + "roti" : (198, 168, 75), + "rouge" : (162, 59, 108), + "royal blue" : ( 65, 105, 225), + "royal heath" : (171, 52, 114), + "royal purple" : (107, 63, 160), + "rum" : (121, 105, 137), + "rum swizzle" : (249, 248, 228), + "russet" : (128, 70, 27), + "russett" : (117, 90, 87), + "rust" : (183, 65, 14), + "rustic red" : ( 72, 4, 4), + "rusty nail" : (134, 86, 10), + "saddle" : ( 76, 48, 36), + "saddle brown" : ( 88, 52, 1), + "saffron" : (244, 196, 48), + "saffron mango" : (249, 191, 88), + "sage" : (158, 165, 135), + "sahara" : (183, 162, 20), + "sahara sand" : (241, 231, 136), + "sail" : (184, 224, 249), + "salem" : ( 9, 127, 75), + "salmon" : (255, 140, 105), + "salomie" : (254, 219, 141), + "salt box" : (104, 94, 110), + "saltpan" : (241, 247, 242), + "sambuca" : ( 58, 32, 16), + "san felix" : ( 11, 98, 7), + "san juan" : ( 48, 75, 106), + "san marino" : ( 69, 108, 172), + "sand dune" : (130, 111, 101), + "sandal" : (170, 141, 111), + "sandrift" : (171, 145, 122), + "sandstone" : (121, 109, 98), + "sandwisp" : (245, 231, 162), + "sandy beach" : (255, 234, 200), + "sandy brown" : (244, 164, 96), + "sangria" : (146, 0, 10), + "sanguine brown" : (141, 61, 56), + "santa fe" : (177, 109, 82), + "santas gray" : (159, 160, 177), + "sapling" : (222, 212, 164), + "sapphire" : ( 47, 81, 158), + "saratoga" : ( 85, 91, 16), + "satin linen" : (230, 228, 212), + "sauvignon" : (255, 245, 243), + "sazerac" : (255, 244, 224), + "scampi" : (103, 95, 166), + "scandal" : (207, 250, 244), + "scarlet" : (255, 36, 0), + "scarlet gum" : ( 67, 21, 96), + "scarlett" : (149, 0, 21), + "scarpa flow" : ( 88, 85, 98), + "schist" : (169, 180, 151), + "school bus yellow" : (255, 216, 0), + "schooner" : (139, 132, 126), + "science blue" : ( 0, 102, 204), + "scooter" : ( 46, 191, 212), + "scorpion" : (105, 95, 98), + "scotch mist" : (255, 251, 220), + "screamin' green" : (102, 255, 102), + "sea buckthorn" : (251, 161, 41), + "sea green" : ( 46, 139, 87), + "sea mist" : (197, 219, 202), + "sea nymph" : (120, 163, 156), + "sea pink" : (237, 152, 158), + "seagull" : (128, 204, 234), + "seance" : (115, 30, 143), + "seashell" : (241, 241, 241), + "seashell peach" : (255, 245, 238), + "seaweed" : ( 27, 47, 17), + "selago" : (240, 238, 253), + "selective yellow" : (255, 186, 0), + "sepia" : (112, 66, 20), + "sepia black" : ( 43, 2, 2), + "sepia skin" : (158, 91, 64), + "serenade" : (255, 244, 232), + "shadow" : (131, 112, 80), + "shadow green" : (154, 194, 184), + "shady lady" : (170, 165, 169), + "shakespeare" : ( 78, 171, 209), + "shalimar" : (251, 255, 186), + "shamrock" : ( 51, 204, 153), + "shark" : ( 37, 39, 44), + "sherpa blue" : ( 0, 73, 80), + "sherwood green" : ( 2, 64, 44), + "shilo" : (232, 185, 179), + "shingle fawn" : (107, 78, 49), + "ship cove" : (120, 139, 186), + "ship gray" : ( 62, 58, 68), + "shiraz" : (178, 9, 49), + "shocking" : (226, 146, 192), + "shocking pink" : (252, 15, 192), + "shuttle gray" : ( 95, 102, 114), + "siam" : (100, 106, 84), + "sidecar" : (243, 231, 187), + "silk" : (189, 177, 168), + "silver" : (192, 192, 192), + "silver chalice" : (172, 172, 172), + "silver rust" : (201, 192, 187), + "silver sand" : (191, 193, 194), + "silver tree" : (102, 181, 143), + "sinbad" : (159, 215, 211), + "siren" : (122, 1, 58), + "sirocco" : (113, 128, 128), + "sisal" : (211, 203, 186), + "skeptic" : (202, 230, 218), + "sky blue" : (118, 215, 234), + "slate gray" : (112, 128, 144), + "smalt" : ( 0, 51, 153), + "smalt blue" : ( 81, 128, 143), + "smoky" : ( 96, 91, 115), + "snow drift" : (247, 250, 247), + "snow flurry" : (228, 255, 209), + "snowy mint" : (214, 255, 219), + "snuff" : (226, 216, 237), + "soapstone" : (255, 251, 249), + "soft amber" : (209, 198, 180), + "soft peach" : (245, 237, 239), + "solid pink" : (137, 56, 67), + "solitaire" : (254, 248, 226), + "solitude" : (234, 246, 255), + "sorbus" : (253, 124, 7), + "sorrell brown" : (206, 185, 143), + "soya bean" : (106, 96, 81), + "spanish green" : (129, 152, 133), + "spectra" : ( 47, 90, 87), + "spice" : (106, 68, 46), + "spicy mix" : (136, 83, 66), + "spicy mustard" : (116, 100, 13), + "spicy pink" : (129, 110, 113), + "spindle" : (182, 209, 234), + "spray" : (121, 222, 236), + "spring green" : ( 0, 255, 127), + "spring leaves" : ( 87, 131, 99), + "spring rain" : (172, 203, 177), + "spring sun" : (246, 255, 220), + "spring wood" : (248, 246, 241), + "sprout" : (193, 215, 176), + "spun pearl" : (170, 171, 183), + "squirrel" : (143, 129, 118), + "st tropaz" : ( 45, 86, 155), + "stack" : (138, 143, 138), + "star dust" : (159, 159, 156), + "stark white" : (229, 215, 189), + "starship" : (236, 242, 69), + "steel blue" : ( 70, 130, 180), + "steel gray" : ( 38, 35, 53), + "stiletto" : (156, 51, 54), + "stonewall" : (146, 133, 115), + "storm dust" : (100, 100, 99), + "storm gray" : (113, 116, 134), + "stratos" : ( 0, 7, 65), + "straw" : (212, 191, 141), + "strikemaster" : (149, 99, 135), + "stromboli" : ( 50, 93, 82), + "studio" : (113, 74, 178), + "submarine" : (186, 199, 201), + "sugar cane" : (249, 255, 246), + "sulu" : (193, 240, 124), + "summer green" : (150, 187, 171), + "sun" : (251, 172, 19), + "sundance" : (201, 179, 91), + "sundown" : (255, 177, 179), + "sunflower" : (228, 212, 34), + "sunglo" : (225, 104, 101), + "sunglow" : (255, 204, 51), + "sunset orange" : (254, 76, 64), + "sunshade" : (255, 158, 44), + "supernova" : (255, 201, 1), + "surf" : (187, 215, 193), + "surf crest" : (207, 229, 210), + "surfie green" : ( 12, 122, 121), + "sushi" : (135, 171, 57), + "suva gray" : (136, 131, 135), + "swamp" : ( 0, 27, 28), + "swamp green" : (172, 183, 142), + "swans down" : (220, 240, 234), + "sweet corn" : (251, 234, 140), + "sweet pink" : (253, 159, 162), + "swirl" : (211, 205, 197), + "swiss coffee" : (221, 214, 213), + "sycamore" : (144, 141, 57), + "tabasco" : (160, 39, 18), + "tacao" : (237, 179, 129), + "tacha" : (214, 197, 98), + "tahiti gold" : (233, 124, 7), + "tahuna sands" : (238, 240, 200), + "tall poppy" : (179, 45, 41), + "tallow" : (168, 165, 137), + "tamarillo" : (153, 22, 19), + "tamarind" : ( 52, 21, 21), + "tan" : (210, 180, 140), + "tan hide" : (250, 157, 90), + "tana" : (217, 220, 193), + "tangaroa" : ( 3, 22, 60), + "tangerine" : (242, 133, 0), + "tango" : (237, 122, 28), + "tapa" : (123, 120, 116), + "tapestry" : (176, 94, 129), + "tara" : (225, 246, 232), + "tarawera" : ( 7, 58, 80), + "tasman" : (207, 220, 207), + "taupe" : ( 72, 60, 50), + "taupe gray" : (179, 175, 149), + "tawny port" : (105, 37, 69), + "te papa green" : ( 30, 67, 60), + "tea" : (193, 186, 176), + "tea green" : (208, 240, 192), + "teak" : (177, 148, 97), + "teal" : ( 0, 128, 128), + "teal blue" : ( 4, 66, 89), + "temptress" : ( 59, 0, 11), + "tenn" : (205, 87, 0), + "tequila" : (255, 230, 199), + "terracotta" : (226, 114, 91), + "texas" : (248, 249, 156), + "texas rose" : (255, 181, 85), + "thatch" : (182, 157, 152), + "thatch green" : ( 64, 61, 25), + "thistle" : (216, 191, 216), + "thistle green" : (204, 202, 168), + "thunder" : ( 51, 41, 47), + "thunderbird" : (192, 43, 24), + "tia maria" : (193, 68, 14), + "tiara" : (195, 209, 209), + "tiber" : ( 6, 53, 55), + "tickle me pink" : (252, 128, 165), + "tidal" : (241, 255, 173), + "tide" : (191, 184, 176), + "timber green" : ( 22, 50, 44), + "timberwolf" : (217, 214, 207), + "titan white" : (240, 238, 255), + "toast" : (154, 110, 97), + "tobacco brown" : (113, 93, 71), + "toledo" : ( 58, 0, 32), + "tolopea" : ( 27, 2, 69), + "tom thumb" : ( 63, 88, 59), + "tonys pink" : (231, 159, 140), + "topaz" : (124, 119, 138), + "torch red" : (253, 14, 53), + "torea bay" : ( 15, 45, 158), + "tory blue" : ( 20, 80, 170), + "tosca" : (141, 63, 63), + "totem pole" : (153, 27, 7), + "tower gray" : (169, 189, 191), + "tradewind" : ( 95, 179, 172), + "tranquil" : (230, 255, 255), + "travertine" : (255, 253, 232), + "tree poppy" : (252, 156, 29), + "treehouse" : ( 59, 40, 32), + "trendy green" : (124, 136, 26), + "trendy pink" : (140, 100, 149), + "trinidad" : (230, 78, 3), + "tropical blue" : (195, 221, 249), + "tropical rain forest" : ( 0, 117, 94), + "trout" : ( 74, 78, 90), + "true v" : (138, 115, 214), + "tuatara" : ( 54, 53, 52), + "tuft bush" : (255, 221, 205), + "tulip tree" : (234, 179, 59), + "tumbleweed" : (222, 166, 129), + "tuna" : ( 53, 53, 66), + "tundora" : ( 74, 66, 68), + "turbo" : (250, 230, 0), + "turkish rose" : (181, 114, 129), + "turmeric" : (202, 187, 72), + "turquoise" : ( 48, 213, 200), + "turquoise blue" : (108, 218, 231), + "turtle green" : ( 42, 56, 11), + "tuscany" : (189, 94, 46), + "tusk" : (238, 243, 195), + "tussock" : (197, 153, 75), + "tutu" : (255, 241, 249), + "twilight" : (228, 207, 222), + "twilight blue" : (238, 253, 255), + "twine" : (194, 149, 93), + "tyrian purple" : (102, 2, 60), + "ultramarine" : ( 18, 10, 143), + "valencia" : (216, 68, 55), + "valentino" : ( 53, 14, 66), + "valhalla" : ( 43, 25, 79), + "van cleef" : ( 73, 23, 12), + "vanilla" : (209, 190, 168), + "vanilla ice" : (243, 217, 223), + "varden" : (255, 246, 223), + "venetian red" : (114, 1, 15), + "venice blue" : ( 5, 89, 137), + "venus" : (146, 133, 144), + "verdigris" : ( 93, 94, 55), + "verdun green" : ( 73, 84, 0), + "vermilion" : (255, 77, 0), + "vesuvius" : (177, 74, 11), + "victoria" : ( 83, 68, 145), + "vida loca" : ( 84, 144, 25), + "viking" : (100, 204, 219), + "vin rouge" : (152, 61, 97), + "viola" : (203, 143, 169), + "violent violet" : ( 41, 12, 94), + "violet" : ( 36, 10, 64), + "violet eggplant" : (153, 17, 153), + "violet red" : (247, 70, 138), + "viridian" : ( 64, 130, 109), + "viridian green" : (103, 137, 117), + "vis vis" : (255, 239, 161), + "vista blue" : (143, 214, 180), + "vista white" : (252, 248, 247), + "vivid tangerine" : (255, 153, 128), + "vivid violet" : (128, 55, 144), + "voodoo" : ( 83, 52, 85), + "vulcan" : ( 16, 18, 29), + "wafer" : (222, 203, 198), + "waikawa gray" : ( 90, 110, 156), + "waiouru" : ( 54, 60, 13), + "walnut" : (119, 63, 26), + "wasabi" : (120, 138, 37), + "water leaf" : (161, 233, 222), + "watercourse" : ( 5, 111, 87), + "waterloo " : (123, 124, 148), + "wattle" : (220, 215, 71), + "watusi" : (255, 221, 207), + "wax flower" : (255, 192, 168), + "we peep" : (247, 219, 230), + "web orange" : (255, 165, 0), + "wedgewood" : ( 78, 127, 158), + "well read" : (180, 51, 50), + "west coast" : ( 98, 81, 25), + "west side" : (255, 145, 15), + "westar" : (220, 217, 210), + "wewak" : (241, 155, 171), + "wheat" : (245, 222, 179), + "wheatfield" : (243, 237, 207), + "whiskey" : (213, 154, 111), + "whisper" : (247, 245, 250), + "white" : (255, 255, 255), + "white ice" : (221, 249, 241), + "white lilac" : (248, 247, 252), + "white linen" : (248, 240, 232), + "white pointer" : (254, 248, 255), + "white rock" : (234, 232, 212), + "wild blue yonder" : (122, 137, 184), + "wild rice" : (236, 224, 144), + "wild sand" : (244, 244, 244), + "wild strawberry" : (255, 51, 153), + "wild watermelon" : (253, 91, 120), + "wild willow" : (185, 196, 106), + "william" : ( 58, 104, 108), + "willow brook" : (223, 236, 218), + "willow grove" : (101, 116, 93), + "windsor" : ( 60, 8, 120), + "wine berry" : ( 89, 29, 53), + "winter hazel" : (213, 209, 149), + "wisp pink" : (254, 244, 248), + "wisteria" : (151, 113, 181), + "wistful" : (164, 166, 211), + "witch haze" : (255, 252, 153), + "wood bark" : ( 38, 17, 5), + "woodland" : ( 77, 83, 40), + "woodrush" : ( 48, 42, 15), + "woodsmoke" : ( 12, 13, 15), + "woody brown" : ( 72, 49, 49), + "xanadu" : (115, 134, 120), + "yellow" : (255, 255, 0), + "yellow green" : (197, 225, 122), + "yellow metal" : (113, 99, 56), + "yellow orange" : (255, 174, 66), + "yellow sea" : (254, 169, 4), + "your pink" : (255, 195, 192), + "yukon gold" : (123, 102, 8), + "yuma" : (206, 194, 145), + "zambezi" : (104, 85, 88), + "zanah" : (218, 236, 214), + "zest" : (229, 132, 27), + "zeus" : ( 41, 35, 25), + "ziggurat" : (191, 219, 226), + "zinnwaldite" : (235, 194, 175), + "zircon" : (244, 248, 255), + "zombie" : (228, 214, 155), + "zorba" : (165, 155, 145), + "zuccini" : ( 4, 64, 34), + "zumthor" : (237, 246, 255)} + +def build_reverse_dict(): + global reverse + global colorhex + global colors + for color in colors: + rgb = colors[color] + hex = '#%02X%02X%02X' % (rgb) + reverse[hex] = color + colorhex[color] = hex + return + + +def get_complementary_hex(color): + # strip the # from the beginning + color = color[1:] + # convert the string into hex + color = int(color, 16) + # invert the three bytes + # as good as substracting each of RGB component by 255(FF) + comp_color = 0xFFFFFF ^ color + # convert the color back to hex by prefixing a # + comp_color = "#%06X" % comp_color + # return the result + return comp_color + +def get_complementary_rgb(red, green, blue): + color_string = '#%02X%02X%02X' % (red, green, blue) + # strip the # from the beginning + color = color_string[1:] + # convert the string into hex + color = int(color, 16) + # invert the three bytes + # as good as substracting each of RGB component by 255(FF) + comp_color = 0xFFFFFF ^ color + # convert the color back to hex by prefixing a # + comp_color = "#%06X" % comp_color + # return the result + return comp_color + +def get_name_from_hex(hex): + global reverse + global colorhex + global colors + + hex = hex.upper() + try: + name = reverse[hex] + except: + name = 'No Hex For Name' + return name + +def get_hex_from_name(name): + global reverse + global colorhex + global colors + + name = name.lower() + try: + hex = colorhex[name] + except: + hex = '#000000' + return hex + +def show_all_colors_on_buttons(): + global reverse + global colorhex + global colors + form = g.FlexForm('Colors on Buttons Demo', default_element_size=(3,1), location=(0,0), icon=MY_WINDOW_ICON, font=("Helvetica", 7)) + row = [] + row_len = 20 + for i, c in enumerate(colors): + hex = get_hex_from_name(c) + button1 = g.Button(button_text=c, button_color=(get_complementary_hex(hex), hex), size=(8,1)) + button2 = g.Button(button_text=c, button_color=(hex,get_complementary_hex(hex)), size=(8,1)) + row.append(button1) + row.append(button2) + if (i+1) % row_len == 0: + form.AddRow(*row) + row = [] + if row != []: + form.AddRow(*row) + form.Show() + + +GoodColors = [('#0e6251',g.RGB(255,246,122) ), + ('white', g.RGB(0,74,60)), + (g.RGB(0,210,124),g.RGB(0,74,60) ), + (g.RGB(0,210,87),g.RGB(0,74,60) ), + (g.RGB(0,164,73),g.RGB(0,74,60) ), + (g.RGB(0,74,60),g.RGB(0,74,60) ), + + ] + + +def main(): + global colors + global reverse + + build_reverse_dict() + list_of_colors = [c for c in colors] + printable = '\n'.join(map(str, list_of_colors)) + # show_all_colors_on_buttons() + while True: + # ------- Form show ------- # + layout = [[g.Text('Find color')], + [g.Text('Demonstration of colors')], + [g.Text('Enter a color name in text or hex #RRGGBB format')], + [g.InputText()], + [g.Listbox(list_of_colors, size=(20,30)), g.T('Or choose from list')], + [g.Submit(), g.Quit(), g.SimpleButton('Show me lots of colors!', button_color=('white','#0e6251'))], + ] + # [g.Multiline(DefaultText=str(printable), Size=(30,20))]] + (button, (hex_input, drop_down_value)) = g.FlexForm('Color Demo', auto_size_text=True, icon=MY_WINDOW_ICON).LayoutAndShow(layout) + + drop_down_value = drop_down_value[0] + + # ------- Form show ------- # + # layout = [[g.Text('Find color')], + # [g.Text('Demonstration of colors')], + # [g.Text('Enter a color name in text or hex #RRGGBB format')], + # [g.InputText()], + # [g.InputCombo(list_of_colors, size=(20,6)), g.T('Or choose from list')], + # [g.Submit(), g.Quit(), g.SimpleButton('Show me lots of colors!', button_color=('white','#0e6251'))], + # ] + # # [g.Multiline(DefaultText=str(printable), Size=(30,20))]] + # (button, (hex_input, drop_down_value)) = g.FlexForm('Color Demo', auto_size_text=True, icon=MY_WINDOW_ICON).LayoutAndShow(layout) + + + # ------- OUTPUT results portion ------- # + if button == '' or button == 'Quit' or button is None: + exit(0) + elif button == 'Show me lots of colors!': + show_all_colors_on_buttons() + + if hex_input is not '' and hex_input[0] == '#': + color_hex = hex_input.upper() + color_name = get_name_from_hex(hex_input) + else: + color_name = drop_down_value + color_hex = get_hex_from_name(color_name) + + complementary_hex = get_complementary_hex(color_hex) + complementary_color = get_name_from_hex(complementary_hex) + + # g.MsgBox('Colors', 'The RBG value is', rgb, 'color and comp are', color_string, compl) + layout = [[g.Text('That color and it\'s compliment are shown on these buttons. This form auto-closes')], + [g.Button(button_text=color_name, button_color=(color_hex, complementary_hex))], + [g.Button(button_text=complementary_hex + ' ' + complementary_color, button_color=(complementary_hex , color_hex), size=(30,1))], + ] + g.FlexForm('Color demo', default_element_size=(100,1), auto_size_text=True, auto_close=True, auto_close_duration=5, icon=MY_WINDOW_ICON).LayoutAndShow(layout) + + + +if __name__ == '__main__': + main() diff --git a/Demo_Compare_Files.py b/Demo_Compare_Files.py new file mode 100644 index 000000000..25077a9a3 --- /dev/null +++ b/Demo_Compare_Files.py @@ -0,0 +1,33 @@ +import PySimpleGUI as sg + +def GetFilesToCompare(): + with sg.FlexForm('File Compare', auto_size_text=True) as form: + form_rows = [[sg.Text('Enter 2 files to comare')], + [sg.Text('File 1', size=(15, 1)), sg.InputText(), sg.FileBrowse()], + [sg.Text('File 2', size=(15, 1)), sg.InputText(), sg.FileBrowse()], + [sg.Submit(), sg.Cancel()]] + rc = form.LayoutAndShow(form_rows) + return rc + +def main(): + button, (f1, f2) = GetFilesToCompare() + if any((button != 'Submit', f1 =='', f2 == '')): + sg.MsgBoxError('Operation cancelled') + exit(69) + + with open(f1, 'rb') as file1: + with open(f2, 'rb') as file2: + a = file1.read() + b = file2.read() + + for i, x in enumerate(a): + if x != b[i]: + sg.MsgBox('Compare results for files', f1, f2, '**** Mismatch at offset {} ****'.format(i)) + break + else: + if len(a) == len(b): + sg.MsgBox('**** The files are IDENTICAL ****') + + +if __name__ == '__main__': + main() diff --git a/Demo_DisplayHash1and256.py b/Demo_DisplayHash1and256.py new file mode 100644 index 000000000..4aa3db1d0 --- /dev/null +++ b/Demo_DisplayHash1and256.py @@ -0,0 +1,123 @@ +#!Python 3 +import hashlib +import PySimpleGUI as SG + + ######################################################################### +# DisplayHash # +# A PySimpleGUI demo app that displays SHA1 hash for user browsed file # +# Useful and a recipe for GUI success # + ######################################################################### + +# ====____====____==== FUNCTION compute_hash_for_file(filename) ====____====____==== # +# Reads a file, computes the Hash # +# ---------------------------------------------------------------------------------- # +def compute_sha1_hash_for_file(filename): + try: + x = open(filename, "rb").read() + except: + return 0 + + m = hashlib.sha1() + m.update(x) + f_sha = m.hexdigest() + + return f_sha + + +# ====____====____==== FUNCTION compute_hash_for_file(filename) ====____====____==== # +# Reads a file, computes the Hash # +# ---------------------------------------------------------------------------------- # +def compute_sha256_hash_for_file(filename): + try: + f = open(filename, "rb") + x = f.read() + except: + return 0 + + m = hashlib.sha256() + m.update(x) + f_sha = m.hexdigest() + + return f_sha + + + # ====____====____==== Uses A GooeyGUI GUI ====____====____== # +# Get the filename, display the hash, dirt simple all around # + # ----------------------------------------------------------- # + +# ---------------------------------------------------------------------- # +# Compute and display SHA1 hash # +# Builds and displays the form using the most basic building blocks # +# ---------------------------------------------------------------------- # +def HashManuallyBuiltGUI(): + # ------- Form design ------- # + with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + [SG.InputText(), SG.FileBrowse()], + [SG.Submit(), SG.Cancel()]] + (button, (source_filename, )) = form.LayoutAndShow(form_rows) + + if button == 'Submit': + if source_filename != '': + hash_sha1 = compute_sha1_hash_for_file(source_filename).upper() + hash_sha256 = compute_sha256_hash_for_file(source_filename).upper() + SG.MsgBox( 'Display A Hash in PySimpleGUI', 'The SHA-1 Hash for the file\n', source_filename, hash_sha1, 'SHA-256 is', hash_sha256, line_width=75) + else: SG.MsgBoxError('Display A Hash in PySimpleGUI', 'Illegal filename') + else: + SG.MsgBoxError('Display A Hash in PySimpleGUI', '* Cancelled *') + +def HashManuallyBuiltGUINonContext(): + # ------- Form design ------- # + form = SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) + form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + [SG.InputText(), SG.FileBrowse()], + [SG.Submit(), SG.Cancel()]] + button, (source_filename, ) = form.LayoutAndShow(form_rows) + + if button == 'Submit': + if source_filename != '': + hash_sha1 = compute_sha1_hash_for_file(source_filename).upper() + hash_sha256 = compute_sha256_hash_for_file(source_filename).upper() + SG.MsgBox( 'Display A Hash in PySimpleGUI', 'The SHA-1 Hash for the file\n', source_filename, hash_sha1, 'SHA-256 is', hash_sha256, line_width=75) + else: SG.MsgBoxError('Display A Hash in PySimpleGUI', 'Illegal filename') + else: + SG.MsgBoxError('Display A Hash in PySimpleGUI', '* Cancelled *') + + + + +# ---------------------------------------------------------------------- # +# Compute and display SHA1 hash # +# This one cheats and uses the higher-level Get A File pre-made func # +# Hey, it's a really common operation so why not? # +# ---------------------------------------------------------------------- # +def HashMostCompactGUI(): + # ------- INPUT GUI portion ------- # + + rc, source_filename = SG.GetFileBox('Display A Hash Using PySimpleGUI', + 'Display a Hash code for file of your choice') + + # ------- OUTPUT GUI results portion ------- # + if rc == True: + hash = compute_sha1_hash_for_file(source_filename) + SG.MsgBox('Display Hash - Compact GUI', 'The SHA-1 Hash for the file\n', source_filename, hash) + else: + SG.MsgBox('Display Hash - Compact GUI', '* Cancelled *') + + +# ---------------------------------------------------------------------- # +# Our main calls two GUIs that act identically but use different calls # +# ---------------------------------------------------------------------- # +def main(): + HashManuallyBuiltGUINonContext() + HashMostCompactGUI() + + +# ====____====____==== Pseudo-MAIN program ====____====____==== # +# This is our main-alike piece of code # +# + Starts up the GUI # +# + Gets values from GUI # +# + Runs DeDupe_folder based on GUI inputs # +# ------------------------------------------------------------- # +if __name__ == '__main__': + main() diff --git a/Demo_DuplicateFileFinder.py b/Demo_DuplicateFileFinder.py new file mode 100644 index 000000000..40cef6996 --- /dev/null +++ b/Demo_DuplicateFileFinder.py @@ -0,0 +1,57 @@ +import hashlib +import os +import PySimpleGUI as sg + + +# ====____====____==== FUNCTION DeDuplicate_folder(path) ====____====____==== # +# Function to de-duplicate the folder passed in # +# --------------------------------------------------------------------------- # +def FindDuplicatesFilesInFolder(path): + shatab = [] + total = 0 + small_count, dup_count, error_count = 0,0,0 + pngdir = path + if not os.path.exists(path): + sg.MsgBox('Duplicate Finder', '** Folder doesn\'t exist***', path) + return + pngfiles = os.listdir(pngdir) + total_files = len(pngfiles) + for idx, f in enumerate(pngfiles): + if not sg.EasyProgressMeter('Counting Duplicates', idx + 1, total_files, 'Counting Duplicate Files'): + break + total += 1 + fname = os.path.join(pngdir, f) + if os.path.isdir(fname): + continue + x = open(fname, "rb").read() + + m = hashlib.sha256() + m.update(x) + f_sha = m.digest() + if f_sha in shatab: + # uncomment next line to remove duplicate files + # os.remove(fname) + dup_count += 1 + # sg.Print(f'Duplicate file - {f}') # cannot current use sg.Print with Progress Meter + continue + shatab.append(f_sha) + + msg = f'{total} Files processed\n'\ + f'{dup_count} Duplicates found\n' + sg.MsgBox('Duplicate Finder Ended', msg) + +# ====____====____==== Pseudo-MAIN program ====____====____==== # +# This is our main-alike piece of code # +# + Starts up the GUI # +# + Gets values from GUI # +# + Runs DeDupe_folder based on GUI inputs # +# ------------------------------------------------------------- # +if __name__ == '__main__': + + source_folder = None + rc, source_folder = sg.GetPathBox('Duplicate Finder - Count number of duplicate files', 'Enter path to folder you wish to find duplicates in') + if rc is True and source_folder is not None: + FindDuplicatesFilesInFolder(source_folder) + else: + sg.MsgBoxCancel('Cancelling', '*** Cancelling ***') + exit(0) diff --git a/Demo_GoodColors.py b/Demo_GoodColors.py new file mode 100644 index 000000000..7d0402f8d --- /dev/null +++ b/Demo_GoodColors.py @@ -0,0 +1,50 @@ +import PySimpleGUI as gg +import time + +def main(): + # ------- Make a new FlexForm ------- # + form = gg.FlexForm('GoodColors', auto_size_text=True, default_element_size=(30,2)) + form.AddRow(gg.Text('Having trouble picking good colors? Try one of the colors defined by PySimpleGUI')) + form.AddRow(gg.Text('Here come the good colors as defined by PySimpleGUI')) + + #===== Show some nice BLUE colors with yellow text ===== ===== ===== ===== ===== ===== =====# + text_color = gg.YELLOWS[0] + buttons = (gg.SimpleButton(f'BLUES[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.BLUES)) + form.AddRow(gg.T('Button Colors Using PySimpleGUI.BLUES')) + form.AddRow(*buttons) + form.AddRow(gg.Text('_' * 100, size=(65, 1))) + + #===== Show some nice PURPLE colors with yellow text ===== ===== ===== ===== ===== ===== =====# + buttons = (gg.SimpleButton(f'PURPLES[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.PURPLES)) + form.AddRow(gg.T('Button Colors Using PySimpleGUI.PURPLES')) + form.AddRow(*buttons) + form.AddRow(gg.Text('_' * 100, size=(65, 1))) + + #===== Show some nice GREEN colors with yellow text ===== ===== ===== ===== ===== ===== =====# + buttons = (gg.SimpleButton(f'GREENS[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.GREENS)) + form.AddRow(gg.T('Button Colors Using PySimpleGUI.GREENS')) + form.AddRow(*buttons) + form.AddRow(gg.Text('_' * 100, size=(65, 1))) + + #===== Show some nice TAN colors with yellow text ===== ===== ===== ===== ===== ===== =====# + text_color = gg.GREENS[0] # let's use GREEN text on the tan + buttons = (gg.SimpleButton(f'TANS[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.TANS)) + form.AddRow(gg.T('Button Colors Using PySimpleGUI.TANS')) + form.AddRow(*buttons) + form.AddRow(gg.Text('_' * 100, size=(65, 1))) + + #===== Show some nice YELLOWS colors with black text ===== ===== ===== ===== ===== ===== =====# + text_color = 'black' # let's use black text on the tan + buttons = (gg.SimpleButton(f'YELLOWS[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.YELLOWS)) + form.AddRow(gg.T('Button Colors Using PySimpleGUI.YELLOWS')) + form.AddRow(*buttons) + form.AddRow(gg.Text('_' * 100, size=(65, 1))) + + + #===== Add a click me button for fun and SHOW the form ===== ===== ===== ===== ===== ===== =====# + form.AddRow(gg.SimpleButton('Click ME!')) + (button, value) = form.Show() # show it! + + +if __name__ == '__main__': + main() diff --git a/Demo_HowDoI.py b/Demo_HowDoI.py new file mode 100644 index 000000000..e7385bfdc --- /dev/null +++ b/Demo_HowDoI.py @@ -0,0 +1,55 @@ +import PySimpleGUI 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 FlexForm ------- # + SG.SetOptions(border_width=1) + form = SG.FlexForm('How Do I ??', auto_size_text=True, default_element_size=(30, 2), icon=DEFAULT_ICON) + form.AddRow(SG.Text('Ask and your answer will appear here....', size=(40, 1))) + form.AddRow(SG.Output(size=(90, 20))) + form.AddRow(SG.Multiline(size=(85, 5), enter_submits=True), + SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), + SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))) + + # ---===--- Loop taking in user input and using it to query HowDoI --- # + while True: + (button, value) = form.Read() + if button == 'SEND': + QueryHowDoI(value[0][:-1]) # send string without carriage return on end + else: + break # exit button clicked + + exit(69) + +def QueryHowDoI(Query): + ''' + 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 + t = subprocess.Popen(howdoi_command + ' '+ Query, stdout=subprocess.PIPE) + (output, err) = t.communicate() + print('You asked: '+ Query) + print('_______________________________________') + print(output.decode("utf-8") ) + exit_code = t.wait() + +if __name__ == '__main__': + HowDoI() + diff --git a/Demo_Media_Player.py b/Demo_Media_Player.py new file mode 100644 index 000000000..fdc014346 --- /dev/null +++ b/Demo_Media_Player.py @@ -0,0 +1,64 @@ +import PySimpleGUI as sg + +# +# An Async Demonstration of a media player +# Uses button images for a super snazzy look +# See how it looks here: +# https://user-images.githubusercontent.com/13696193/43159403-45c9726e-8f50-11e8-9da0-0d272e20c579.jpg +# +def MediaPlayerGUI(): + + # Images are located in a subfolder in the Demo Media Player.py folder + image_pause = './ButtonGraphics/Pause.png' + image_restart = './ButtonGraphics/Restart.png' + image_next = './ButtonGraphics/Next.png' + image_exit = './ButtonGraphics/Exit.png' + + # A text element that will be changed to display messages in the GUI + TextElem = sg.Text('', size=(15, 2), font=("Helvetica", 14)) + + # Open a form, note that context manager can't be used generally speaking for async forms + form = sg.FlexForm('Media File Player', auto_size_text=True, default_element_size=(20, 1), + font=("Helvetica", 25)) + # define layout of the rows + layout= [[sg.Text('Media File Player',size=(17,1), font=("Helvetica", 25))], + [TextElem], + [sg.ReadFormButton('Restart Song', button_color=sg.TRANSPARENT_BUTTON, + image_filename=image_restart, image_size=(50, 50), image_subsample=2, border_width=0), + sg.Text(' ' * 2), + sg.ReadFormButton('Pause', button_color=sg.TRANSPARENT_BUTTON, + image_filename=image_pause, image_size=(50, 50), image_subsample=2, border_width=0), + sg.Text(' ' * 2), + sg.ReadFormButton('Next', button_color=sg.TRANSPARENT_BUTTON, + image_filename=image_next, image_size=(50, 50), image_subsample=2, border_width=0), + sg.Text(' ' * 2), + sg.Text(' ' * 2), sg.SimpleButton('Exit', button_color=sg.TRANSPARENT_BUTTON, + image_filename=image_exit, image_size=(50, 50), image_subsample=2, border_width=0)], + [sg.Text('_'*30)], + [sg.Text(' '*30)], + [ + sg.Slider(range=(-10, 10), default_value=0, size=(10, 20), orientation='vertical', font=("Helvetica", 15)), + sg.Text(' ' * 2), + sg.Slider(range=(-10, 10), default_value=0, size=(10, 20), orientation='vertical', font=("Helvetica", 15)), + sg.Text(' ' * 8), + sg.Slider(range=(-10, 10), default_value=0, size=(10, 20), orientation='vertical', font=("Helvetica", 15))], + [sg.Text('Bass', font=("Helvetica", 15), size=(6, 1)), + sg.Text('Treble', font=("Helvetica", 15), size=(10, 1)), + sg.Text('Volume', font=("Helvetica", 15), size=(7, 1))] + + ] + + # Call the same LayoutAndRead but indicate the form is non-blocking + form.LayoutAndRead(layout, non_blocking=True) + # Our event loop + while(True): + # Read the form (this call will not block) + button, values = form.ReadNonBlocking() + if button == 'Exit': + break + # If a button was pressed, display it on the GUI by updating the text element + if button: + TextElem.Update(button) + +MediaPlayerGUI() + diff --git a/Demo_NonBlocking_Form.py b/Demo_NonBlocking_Form.py new file mode 100644 index 000000000..8e43d6dd8 --- /dev/null +++ b/Demo_NonBlocking_Form.py @@ -0,0 +1,59 @@ +import PySimpleGUI as sg +import time + +def main(): + StatusOutputExample() + +# form that doen't block +def StatusOutputExample_context_manager(): + with sg.FlexForm('Running Timer', auto_size_text=True) as form: + output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) + form_rows = [[sg.Text('Non-blocking GUI with updates')], + [output_element], + [sg.SimpleButton('Quit')]] + + form.LayoutAndRead(form_rows, non_blocking=True) + + for i in range(1, 1000): + output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i/100), 60), i%100)) + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + time.sleep(.01) + else: + form.CloseNonBlockingForm() + + +# form that doen't block +def StatusOutputExample(): + # Make a form, but don't use context manager + form = sg.FlexForm('Running Timer', auto_size_text=True) + # Create a text element that will be updated with status information on the GUI itself + output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) + # Create the rows + form_rows = [[sg.Text('Non-blocking GUI with updates')], + [output_element], + [sg.SimpleButton('Quit')]] + # Layout the rows of the form and perform a read. Indicate the form is non-blocking! + form.LayoutAndRead(form_rows, non_blocking=True) + + # + # Some place later in your code... + # You need to perform a ReadNonBlocking on your form every now and then or + # else it won't refresh + # + + for i in range(1, 1000): + output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + time.sleep(.01) + else: + form.CloseNonBlockingForm() + + + +if __name__ == '__main__': + + main() diff --git a/Demo_Recipes.py b/Demo_Recipes.py new file mode 100644 index 000000000..8b8e92936 --- /dev/null +++ b/Demo_Recipes.py @@ -0,0 +1,168 @@ +import time +from random import randint +import PySimpleGUI as sg + +# A simple blocking form. Your best starter-form +def SourceDestFolders(): + with sg.FlexForm('Demo Source / Destination Folders', auto_size_text=True) as form: + form_rows = [[sg.Text('Enter the Source and Destination folders')], + [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source')], + [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), sg.FolderBrowse()], + [sg.Submit(), sg.Cancel()]] + + button, (source, dest) = form.LayoutAndRead(form_rows) + if button == 'Submit': + sg.MsgBox('Submitted', 'The user entered source:', source, 'Destination folder:', dest, 'Using button', button) + else: + sg.MsgBoxError('Cancelled', 'User Cancelled') + +# YOUR BEST STARTING POINT +# This is a form showing you all of the basic Elements (widgets) +# Some have a few of the optional parameters set, but there are more to choose from +# You want to use the context manager because it will free up resources when you are finished +# Use this especially if you are runningm multi-threaded +# Where you free up resources is really important to tkinter +def Everything(): + with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText()], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10), + sg.Spin(values=('Spin Box 1', '2','3'), initial_value='Spin Box 1')], + [sg.Text('_' * 100, size=(70, 1))], + [sg.Text('Choose Source and Destination Folders', size=(35, 1))], + [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], + [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), + sg.FolderBrowse()], + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + + sg.MsgBox('Title', 'Typical message box', 'The results of the form are a lot of data! Get ready... ', 'The button clicked was "{}"'.format(button), 'The values are', values) + +# Should you decide not to use a context manager, then try this form as your starting point +# Be aware that tkinter, which this is based on, is picky about who frees up resources, especially if +# you are running multithreaded +def Everything_NoContextManager(): + form = sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) + layout = [[sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText()], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', scale=(2, 10))], + [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [sg.Text('_' * 100, size=(70, 1))], + [sg.Text('Choose Source and Destination Folders', size=(35, 1), text_color='red')], + [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], + [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), sg.FolderBrowse()], + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))]] + + button, values = form.LayoutAndRead(layout) + del(form) + + sg.MsgBox('Title', 'Typical message box', 'Here are the restults! There is one entry per input field ', 'The button clicked was "{}"'.format(button), 'The values are', values) + +def ProgressMeter(): + for i in range(1,10000): + if not sg.EasyProgressMeter('My Meter', i + 1, 10000): break + # SG.Print(i) + +# Blocking form that doesn't close +def ChatBot(): + with sg.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + layout = [[(sg.Text('This is where standard out is being routed', size=[40, 1]))], + [sg.Output(size=(80, 20))], + [sg.Multiline(size=(70, 5), enter_submits=True), sg.ReadFormButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0])), sg.SimpleButton('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]] + # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form + # if you call LayoutAndRead from here, then you will miss the first button click + form.Layout(layout) + # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # + while True: + button, value = form.Read() + if button == 'SEND': + print(value) + else: + break + +# Shows a form that's a running counter +# this is the basic design pattern if you can keep your reading of the +# form within the 'with' block. If your read occurs far away in your code from the form creation +# then you will want to use the NonBlockingPeriodicUpdateForm example +def NonBlockingPeriodicUpdateForm_ContextManager(): + with sg.FlexForm('Running Timer', auto_size_text=True) as form: + text_element = sg.Text('', size=(10, 2), font=('Helvetica', 20), text_color='red', justification='center') + layout = [[sg.Text('Non blocking GUI with updates', justification='center')], + [text_element], + [sg.T(' ' * 15), sg.Quit()]] + form.LayoutAndRead(layout, non_blocking=True) + + for i in range(1,500): + text_element.Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100)) + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': # if user closed the window using X + break + time.sleep(.01) + else: + # if the loop finished then need to close the form for the user + form.CloseNonBlockingForm() + +# Use this context-manager-free version if your read of the form occurs far away in your code +# from the form creation (call to LayoutAndRead) +def NonBlockingPeriodicUpdateForm(): + # Show a form that's a running counter + form = sg.FlexForm('Running Timer', auto_size_text=True) + text_element = sg.Text('', size=(10, 2), font=('Helvetica', 20), justification='center') + form_rows = [[sg.Text('Non blocking GUI with updates')], + [text_element], + [sg.T(' ' * 15), sg.Quit()]] + form.LayoutAndRead(form_rows, non_blocking=True) + + for i in range(1,50000): + text_element.Update('{:02d}:{:02d}.{:02d}'.format((i//100)//60, (i//100)%60, i%100)) + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': # if user closed the window using X or clicked Quit button + break + time.sleep(.01) + else: + # if the loop finished then need to close the form for the user + form.CloseNonBlockingForm() + del(form) + +def DebugTest(): + # SG.Print('How about we print a bunch of random numbers?', , size=(90,40)) + for i in range (1,300): + sg.Print(i, randint(1, 1000), end='', sep='-') + + +def main(): + # SG.SetOptions(border_width=1, font=("Helvetica", 10), button_color=('white', SG.BLUES[0]), slider_border_width=1) + NonBlockingPeriodicUpdateForm_ContextManager() + NonBlockingPeriodicUpdateForm() + Everything_NoContextManager() + Everything() + ChatBot() + ProgressMeter() + SourceDestFolders() + ChatBot() + DebugTest() + sg.MsgBox('Done with all recipes') + +if __name__ == '__main__': + main() + exit(69) diff --git a/Demo_Tabbed_Form.py b/Demo_Tabbed_Form.py new file mode 100644 index 000000000..e6bcede0c --- /dev/null +++ b/Demo_Tabbed_Form.py @@ -0,0 +1,89 @@ +import PySimpleGUI as sg + +MAX_NUMBER_OF_THREADS = 12 + +def eBaySuperSearcherGUI(): + # Drop Down list of options + configs = ('0 - Gruen - Started 2 days ago in Watches', + '1 - Gruen - Currently Active in Watches', + '2 - Alpina - Currently Active in Jewelry', + '3 - Gruen - Ends in 1 day in Watches', + '4 - Gruen - Completed in Watches', + '5 - Gruen - Advertising', + '6 - Gruen - Currently Active in Jewelry', + '7 - Gruen - Price Test', + '8 - Gruen - No brand name specified') + + us_categories = ('Use Default with no change', + 'All - 1', + 'Jewelry - 281', + ' Watches - 14324', + ' Wristwatches - 31387', + ' Pocket Watches - 3937', + 'Advertising - 34', + ' Watch Ads - 165254' + ) + + german_categories =('Use Default with no change', + 'All - 1', + 'Jewelry - 281', + ' Watches - 14324', + ' Wristwatches - 31387', + ' Pocket Watches - 3937', + 'Advertising - 1', + ' Watch Ads - 19823' + ) + + + # the form layout + with sg.FlexForm('EBay Super Searcher', auto_size_text=True) as form: + with sg.FlexForm('EBay Super Searcher') as form2: + layout_tab_1 = [[sg.Text('eBay Super Searcher!', size=(60,1), font=('helvetica', 15))], + [sg.Text('Choose base configuration to run')], + [sg.InputCombo(configs)], + [sg.Text('_'*100, size=(80,1))], + [sg.InputText(),sg.Text('Choose Destination Folder'), sg.FolderBrowse(target=(sg.ThisRow,0))], + [sg.InputText(),sg.Text('Custom text to add to folder name')], + [sg.Text('_'*100, size=(80,1))], + [sg.Checkbox('US', default=True, size=(15, 1)), sg.Checkbox('German', size=(15, 1), default=True, )], + [sg.Radio('Active Listings','ActiveComplete', default = True,size=(15, 1)), sg.Radio('Completed Listings', 'ActiveComplete', size=(15, 1))], + [sg.Text('_'*100, size=(80,1))], + [sg.Checkbox('Save Images', size=(15,1)),sg.Checkbox('Save PDFs', size=(15,1)), sg.Checkbox('Extract PDFs', size=(15,1))], + [sg.Text('_'*100, size=(80,1))], + [sg.Text('Time Filters')], + [sg.Radio('No change','time', default=True),sg.Radio('ALL listings','time'),sg.Radio('Started 1 day ago','time', size=(15,1)),sg.Radio('Started 2 days ago','time', size=(15,1)), sg.Radio('Ends in 1 day','time', size=(15,1))], + [sg.Text('_'*100, size=(80,1))], + [sg.Text('Price Range'), sg.InputText(size=(10,1)),sg.Text('To'), sg.InputText(size=(10,1))], + [sg.Text('_'*100, size=(80,1))], + [sg.Submit(button_color=('red', 'yellow')), sg.Cancel(button_color=('white', 'blue')), sg.Text(f'{MAX_NUMBER_OF_THREADS} Threads will be started')]] + + + # First category is default (need to special case this) + layout_tab_2 = [[sg.Text('Choose Category')], + [sg.Text('US Categories'),sg.Text('German Categories')], + [sg.Radio(us_categories[0],'CATUS', default=True), sg.Radio(german_categories[0], 'CATDE', default=True)]] + + for i,cat in enumerate(us_categories): + if i == 0: continue # skip first one + layout_tab_2.append([sg.Radio(cat,'CATUS'), sg.Radio(german_categories[i],'CATDE')]) + + + layout_tab_2.append([sg.Text('_' * 100, size=(75, 1))]) + layout_tab_2.append([sg.Text('US Search String Override')]) + layout_tab_2.append([sg.InputText(size=(100,1))]) + layout_tab_2.append([sg.Text('German Search String Override')]) + layout_tab_2.append([sg.InputText(size=(100,1))]) + layout_tab_2.append([sg.Text('Typical US Search String')]) + layout_tab_2.append([sg.InputText(size=(100,1), default_text='gruen -sara -quarz -quartz -embassy -bob -robert -elephants -adidas -LED ')]) + layout_tab_2.append([sg.Text('_' * 100, size=(75, 1))]) + layout_tab_2.append([sg.Submit(button_color=('red', 'yellow'),auto_size_text=True), sg.Cancel(button_color=('white', 'blue'), auto_size_text=True)]) + + results = sg.ShowTabbedForm('eBay Super Searcher', (form,layout_tab_1,'Where To Save'), (form2, layout_tab_2, 'Categories & Search String')) + + return results + + +if __name__ == '__main__': + results = eBaySuperSearcherGUI() + print(results) + sg.MsgBox('Results', results) \ No newline at end of file From bce8382d6e43c0455578fe1a8bb7ef1fe3c3befc Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 25 Jul 2018 07:38:20 -0400 Subject: [PATCH 071/209] Remove renamed files --- Demo DisplayHash1and256.py | 123 -------------------------- Demo DuplicateFileFinder.py | 56 ------------ Demo GoodColors.py | 50 ----------- Demo HowDoI.py | 54 ------------ Demo Media Player.py | 60 ------------- Demo NonBlocking Form.py | 59 ------------- Demo Recipes.py | 167 ------------------------------------ Demo Tabbed Form.py | 89 ------------------- 8 files changed, 658 deletions(-) delete mode 100644 Demo DisplayHash1and256.py delete mode 100644 Demo DuplicateFileFinder.py delete mode 100644 Demo GoodColors.py delete mode 100644 Demo HowDoI.py delete mode 100644 Demo Media Player.py delete mode 100644 Demo NonBlocking Form.py delete mode 100644 Demo Recipes.py delete mode 100644 Demo Tabbed Form.py diff --git a/Demo DisplayHash1and256.py b/Demo DisplayHash1and256.py deleted file mode 100644 index dbc47afcc..000000000 --- a/Demo DisplayHash1and256.py +++ /dev/null @@ -1,123 +0,0 @@ -#!Python 3 -import hashlib -import PySimpleGUI as SG - - ######################################################################### -# DisplayHash # -# A PySimpleGUI demo app that displays SHA1 hash for user browsed file # -# Useful and a recipe for GUI success # - ######################################################################### - -# ====____====____==== FUNCTION compute_hash_for_file(filename) ====____====____==== # -# Reads a file, computes the Hash # -# ---------------------------------------------------------------------------------- # -def compute_sha1_hash_for_file(filename): - try: - x = open(filename, "rb").read() - except: - return 0 - - m = hashlib.sha1() - m.update(x) - f_sha = m.hexdigest() - - return f_sha - - -# ====____====____==== FUNCTION compute_hash_for_file(filename) ====____====____==== # -# Reads a file, computes the Hash # -# ---------------------------------------------------------------------------------- # -def compute_sha256_hash_for_file(filename): - try: - f = open(filename, "rb") - x = f.read() - except: - return 0 - - m = hashlib.sha256() - m.update(x) - f_sha = m.hexdigest() - - return f_sha - - - # ====____====____==== Uses A GooeyGUI GUI ====____====____== # -# Get the filename, display the hash, dirt simple all around # - # ----------------------------------------------------------- # - -# ---------------------------------------------------------------------- # -# Compute and display SHA1 hash # -# Builds and displays the form using the most basic building blocks # -# ---------------------------------------------------------------------- # -def HashManuallyBuiltGUI(): - # ------- Form design ------- # - with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], - [SG.InputText(), SG.FileBrowse()], - [SG.Submit(), SG.Cancel()]] - (button, (source_filename, )) = form.LayoutAndShow(form_rows) - - if button == 'Submit': - if source_filename != '': - hash_sha1 = compute_sha1_hash_for_file(source_filename).upper() - hash_sha256 = compute_sha256_hash_for_file(source_filename).upper() - SG.MsgBox( 'Display A Hash in PySimpleGUI', 'The SHA-1 Hash for the file\n', source_filename, hash_sha1, 'SHA-256 is', hash_sha256, line_width=75) - else: SG.MsgBoxError('Display A Hash in PySimpleGUI', 'Illegal filename') - else: - SG.MsgBoxError('Display A Hash in PySimpleGUI', '* Cancelled *') - -def HashManuallyBuiltGUINonContext(): - # ------- Form design ------- # - form = SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], - [SG.InputText(), SG.FileBrowse()], - [SG.Submit(), SG.Cancel()]] - (button, (source_filename, )) = form.LayoutAndShow(form_rows) - - if button == 'Submit': - if source_filename != '': - hash_sha1 = compute_sha1_hash_for_file(source_filename).upper() - hash_sha256 = compute_sha256_hash_for_file(source_filename).upper() - SG.MsgBox( 'Display A Hash in PySimpleGUI', 'The SHA-1 Hash for the file\n', source_filename, hash_sha1, 'SHA-256 is', hash_sha256, line_width=75) - else: SG.MsgBoxError('Display A Hash in PySimpleGUI', 'Illegal filename') - else: - SG.MsgBoxError('Display A Hash in PySimpleGUI', '* Cancelled *') - - - - -# ---------------------------------------------------------------------- # -# Compute and display SHA1 hash # -# This one cheats and uses the higher-level Get A File pre-made func # -# Hey, it's a really common operation so why not? # -# ---------------------------------------------------------------------- # -def HashMostCompactGUI(): - # ------- INPUT GUI portion ------- # - - rc, source_filename = SG.GetFileBox('Display A Hash Using PySimpleGUI', - 'Display a Hash code for file of your choice') - - # ------- OUTPUT GUI results portion ------- # - if rc == True: - hash = compute_sha1_hash_for_file(source_filename) - SG.MsgBox('Display Hash - Compact GUI', 'The SHA-1 Hash for the file\n', source_filename, hash) - else: - SG.MsgBox('Display Hash - Compact GUI', '* Cancelled *') - - -# ---------------------------------------------------------------------- # -# Our main calls two GUIs that act identically but use different calls # -# ---------------------------------------------------------------------- # -def main(): - HashManuallyBuiltGUINonContext() - HashMostCompactGUI() - - -# ====____====____==== Pseudo-MAIN program ====____====____==== # -# This is our main-alike piece of code # -# + Starts up the GUI # -# + Gets values from GUI # -# + Runs DeDupe_folder based on GUI inputs # -# ------------------------------------------------------------- # -if __name__ == '__main__': - main() diff --git a/Demo DuplicateFileFinder.py b/Demo DuplicateFileFinder.py deleted file mode 100644 index 49b061bbc..000000000 --- a/Demo DuplicateFileFinder.py +++ /dev/null @@ -1,56 +0,0 @@ -import hashlib -import os -import PySimpleGUI as gg - - -# ====____====____==== FUNCTION DeDuplicate_folder(path) ====____====____==== # -# Function to de-duplicate the folder passed in # -# --------------------------------------------------------------------------- # -def FindDuplicatesFilesInFolder(path): - shatab = [] - total = 0 - small_count, dup_count, error_count = 0,0,0 - pngdir = path - if not os.path.exists(path): - gg.MsgBox('Duplicate Finder', '** Folder doesn\'t exist***', path) - return - pngfiles = os.listdir(pngdir) - total_files = len(pngfiles) - for idx, f in enumerate(pngfiles): - if not gg.EasyProgressMeter('Counting Duplicates', idx+1, total_files, 'Counting Duplicate Files'): - break - total += 1 - fname = os.path.join(pngdir, f) - if os.path.isdir(fname): - continue - x = open(fname, "rb").read() - - m = hashlib.sha256() - m.update(x) - f_sha = m.digest() - if f_sha in shatab: - # uncomment next line to remove duplicate files - # os.remove(fname) - dup_count += 1 - continue - shatab.append(f_sha) - - msg = f'{total} Files processed\n'\ - f'{dup_count} Duplicates found\n' - gg.MsgBox('Duplicate Finder Ended', msg) - -# ====____====____==== Pseudo-MAIN program ====____====____==== # -# This is our main-alike piece of code # -# + Starts up the GUI # -# + Gets values from GUI # -# + Runs DeDupe_folder based on GUI inputs # -# ------------------------------------------------------------- # -if __name__ == '__main__': - - source_folder = None - rc, source_folder = gg.GetPathBox('Duplicate Finder - Count number of duplicate files', 'Enter path to folder you wish to find duplicates in') - if rc is True and source_folder is not None: - FindDuplicatesFilesInFolder(source_folder) - else: - gg.MsgBoxCancel('Cancelling', '*** Cancelling ***') - exit(0) diff --git a/Demo GoodColors.py b/Demo GoodColors.py deleted file mode 100644 index 7d0402f8d..000000000 --- a/Demo GoodColors.py +++ /dev/null @@ -1,50 +0,0 @@ -import PySimpleGUI as gg -import time - -def main(): - # ------- Make a new FlexForm ------- # - form = gg.FlexForm('GoodColors', auto_size_text=True, default_element_size=(30,2)) - form.AddRow(gg.Text('Having trouble picking good colors? Try one of the colors defined by PySimpleGUI')) - form.AddRow(gg.Text('Here come the good colors as defined by PySimpleGUI')) - - #===== Show some nice BLUE colors with yellow text ===== ===== ===== ===== ===== ===== =====# - text_color = gg.YELLOWS[0] - buttons = (gg.SimpleButton(f'BLUES[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.BLUES)) - form.AddRow(gg.T('Button Colors Using PySimpleGUI.BLUES')) - form.AddRow(*buttons) - form.AddRow(gg.Text('_' * 100, size=(65, 1))) - - #===== Show some nice PURPLE colors with yellow text ===== ===== ===== ===== ===== ===== =====# - buttons = (gg.SimpleButton(f'PURPLES[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.PURPLES)) - form.AddRow(gg.T('Button Colors Using PySimpleGUI.PURPLES')) - form.AddRow(*buttons) - form.AddRow(gg.Text('_' * 100, size=(65, 1))) - - #===== Show some nice GREEN colors with yellow text ===== ===== ===== ===== ===== ===== =====# - buttons = (gg.SimpleButton(f'GREENS[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.GREENS)) - form.AddRow(gg.T('Button Colors Using PySimpleGUI.GREENS')) - form.AddRow(*buttons) - form.AddRow(gg.Text('_' * 100, size=(65, 1))) - - #===== Show some nice TAN colors with yellow text ===== ===== ===== ===== ===== ===== =====# - text_color = gg.GREENS[0] # let's use GREEN text on the tan - buttons = (gg.SimpleButton(f'TANS[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.TANS)) - form.AddRow(gg.T('Button Colors Using PySimpleGUI.TANS')) - form.AddRow(*buttons) - form.AddRow(gg.Text('_' * 100, size=(65, 1))) - - #===== Show some nice YELLOWS colors with black text ===== ===== ===== ===== ===== ===== =====# - text_color = 'black' # let's use black text on the tan - buttons = (gg.SimpleButton(f'YELLOWS[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.YELLOWS)) - form.AddRow(gg.T('Button Colors Using PySimpleGUI.YELLOWS')) - form.AddRow(*buttons) - form.AddRow(gg.Text('_' * 100, size=(65, 1))) - - - #===== Add a click me button for fun and SHOW the form ===== ===== ===== ===== ===== ===== =====# - form.AddRow(gg.SimpleButton('Click ME!')) - (button, value) = form.Show() # show it! - - -if __name__ == '__main__': - main() diff --git a/Demo HowDoI.py b/Demo HowDoI.py deleted file mode 100644 index 26858ed3f..000000000 --- a/Demo HowDoI.py +++ /dev/null @@ -1,54 +0,0 @@ -import PySimpleGUI 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 FlexForm ------- # - form = SG.FlexForm('How Do I ??', auto_size_text=True, default_element_size=(30, 2), icon=DEFAULT_ICON) - form.AddRow(SG.Text('Ask and your answer will appear here....', size=(40, 1))) - form.AddRow(SG.Output(size=(90, 20))) - form.AddRow(SG.Multiline(size=(85, 5), enter_submits=True), - SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), - SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))) - - # ---===--- Loop taking in user input and using it to query HowDoI --- # - while True: - (button, value) = form.Read() - if button == 'SEND': - QueryHowDoI(value[0][:-1]) # send string without carriage return on end - else: - break # exit button clicked - - exit(69) - -def QueryHowDoI(Query): - ''' - 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 - t = subprocess.Popen(howdoi_command + ' '+ Query, stdout=subprocess.PIPE) - (output, err) = t.communicate() - print('You asked: '+ Query) - print('_______________________________________') - print(output.decode("utf-8") ) - exit_code = t.wait() - -if __name__ == '__main__': - HowDoI() - diff --git a/Demo Media Player.py b/Demo Media Player.py deleted file mode 100644 index 4770c90e2..000000000 --- a/Demo Media Player.py +++ /dev/null @@ -1,60 +0,0 @@ -import PySimpleGUI as sg - -# -# An Async Demonstration of a media player -# Uses button images for a super snazzy look -# See how it looks here: -# https://user-images.githubusercontent.com/13696193/43159403-45c9726e-8f50-11e8-9da0-0d272e20c579.jpg -# - - -def MediaPlayerGUI(): - - # Images are located in a subfolder in the Demo Media Player.py folder - image_pause = './ButtonGraphics/Pause.png' - image_restart = './ButtonGraphics/Restart.png' - image_next = './ButtonGraphics/Next.png' - image_exit = './ButtonGraphics/Exit.png' - - # A text element that will be changed to display messages in the GUI - TextElem = sg.Text('', size=(20, 3), font=("Helvetica", 14)) - - # Open a form, note that context manager can't be used generally speaking for async forms - form = sg.FlexForm('Media File Player', auto_size_text=True, default_element_size=(20, 1), - font=("Helvetica", 25)) - # define layout of the rows - layout= [[sg.Text('Media File Player', size=(20, 1), font=("Helvetica", 25))], - [TextElem], - [sg.ReadFormButton('Restart Song', button_color=sg.TRANSPARENT_BUTTON, - image_filename=image_restart, image_size=(50, 50), image_subsample=2, border_width=0, - size=(10, 2), font=("Helvetica", 15)), sg.Text(' ' * 2), - sg.ReadFormButton('Pause', button_color=sg.TRANSPARENT_BUTTON, - image_filename=image_pause, image_size=(50, 50), image_subsample=2, border_width=0, - font=("Helvetica", 15), size=(10, 2)), sg.Text(' ' * 2), - sg.ReadFormButton('Next', button_color=sg.TRANSPARENT_BUTTON, - image_filename=image_next, image_size=(50, 50), image_subsample=2, border_width=0, - size=(10, 2), font=("Helvetica", 15)), sg.Text(' ' * 2), - sg.Text(' ' * 2), sg.SimpleButton('Exit', button_color=sg.TRANSPARENT_BUTTON, - image_filename=image_exit, image_size=(50, 50), image_subsample=2, border_width=0, - size=(10, 2), font=("Helvetica", 15))], - [sg.Text('Treble', font=("Helvetica", 15), size=(6, 1)), - sg.Slider(range=(-10, 10), default_value=0, size=(10, 20), orientation='vertical', font=("Helvetica", 15)), - sg.Text(' ' * 5), - sg.Text('Volume', font=("Helvetica", 15), size=(7, 1)), - sg.Slider(range=(-10, 10), default_value=0, size=(10, 20), orientation='vertical', font=("Helvetica", 15))], - ] - - # Call the same LayoutAndRead but indicate the form is non-blocking - form.LayoutAndRead(layout, non_blocking=True) - # Our event loop - while(True): - # Read the form (this call will not block) - button, values = form.ReadNonBlocking() - if button == 'Exit': - break - # If a button was pressed, display it on the GUI by updating the text element - if button: - TextElem.Update(button) - -MediaPlayerGUI() - diff --git a/Demo NonBlocking Form.py b/Demo NonBlocking Form.py deleted file mode 100644 index 8e43d6dd8..000000000 --- a/Demo NonBlocking Form.py +++ /dev/null @@ -1,59 +0,0 @@ -import PySimpleGUI as sg -import time - -def main(): - StatusOutputExample() - -# form that doen't block -def StatusOutputExample_context_manager(): - with sg.FlexForm('Running Timer', auto_size_text=True) as form: - output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) - form_rows = [[sg.Text('Non-blocking GUI with updates')], - [output_element], - [sg.SimpleButton('Quit')]] - - form.LayoutAndRead(form_rows, non_blocking=True) - - for i in range(1, 1000): - output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i/100), 60), i%100)) - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': - break - time.sleep(.01) - else: - form.CloseNonBlockingForm() - - -# form that doen't block -def StatusOutputExample(): - # Make a form, but don't use context manager - form = sg.FlexForm('Running Timer', auto_size_text=True) - # Create a text element that will be updated with status information on the GUI itself - output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) - # Create the rows - form_rows = [[sg.Text('Non-blocking GUI with updates')], - [output_element], - [sg.SimpleButton('Quit')]] - # Layout the rows of the form and perform a read. Indicate the form is non-blocking! - form.LayoutAndRead(form_rows, non_blocking=True) - - # - # Some place later in your code... - # You need to perform a ReadNonBlocking on your form every now and then or - # else it won't refresh - # - - for i in range(1, 1000): - output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': - break - time.sleep(.01) - else: - form.CloseNonBlockingForm() - - - -if __name__ == '__main__': - - main() diff --git a/Demo Recipes.py b/Demo Recipes.py deleted file mode 100644 index 6f2a76cd2..000000000 --- a/Demo Recipes.py +++ /dev/null @@ -1,167 +0,0 @@ -import time -from random import randint -import PySimpleGUI as sg - -# A simple blocking form. Your best starter-form -def SourceDestFolders(): - with sg.FlexForm('Demo Source / Destination Folders', auto_size_text=True) as form: - form_rows = [[sg.Text('Enter the Source and Destination folders')], - [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source')], - [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), sg.FolderBrowse()], - [sg.Submit(), sg.Cancel()]] - - button, (source, dest) = form.LayoutAndRead(form_rows) - if button == 'Submit': - sg.MsgBox('Submitted', 'The user entered source:', source, 'Destination folder:', dest, 'Using button', button) - else: - sg.MsgBoxError('Cancelled', 'User Cancelled') - -# YOUR BEST STARTING POINT -# This is a form showing you all of the basic Elements (widgets) -# Some have a few of the optional parameters set, but there are more to choose from -# You want to use the context manager because it will free up resources when you are finished -# Use this especially if you are runningm multi-threaded -# Where you free up resources is really important to tkinter -def Everything(): - with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: - layout = [ - [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [sg.Text('Here is some text.... and a place to enter text')], - [sg.InputText()], - [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], - [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], - [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', - scale=(2, 10))], - [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [sg.Text('_' * 100, size=(70, 1))], - [sg.Text('Choose Source and Destination Folders', size=(35, 1))], - [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], - [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), - sg.FolderBrowse()], - [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] - ] - - button, values = form.LayoutAndRead(layout) - - sg.MsgBox('Title', 'Typical message box', 'The results of the form are a lot of data! Get ready... ', 'The button clicked was "{}"'.format(button), 'The values are', values) - -# Should you decide not to use a context manager, then try this form as your starting point -# Be aware that tkinter, which this is based on, is picky about who frees up resources, especially if -# you are running multithreaded -def Everything_NoContextManager(): - form = sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) - layout = [[sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [sg.Text('Here is some text.... and a place to enter text')], - [sg.InputText()], - [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], - [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], - [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', scale=(2, 10))], - [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [sg.Text('_' * 100, size=(70, 1))], - [sg.Text('Choose Source and Destination Folders', size=(35, 1), text_color='red')], - [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], - [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), sg.FolderBrowse()], - [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))]] - - button, values = form.LayoutAndRead(layout) - del(form) - - sg.MsgBox('Title', 'Typical message box', 'Here are the restults! There is one entry per input field ', 'The button clicked was "{}"'.format(button), 'The values are', values) - -def ProgressMeter(): - for i in range(1,10000): - if not sg.EasyProgressMeter('My Meter', i + 1, 10000): break - # SG.Print(i) - -# Blocking form that doesn't close -def ChatBot(): - with sg.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: - layout = [[(sg.Text('This is where standard out is being routed', size=[40, 1]))], - [sg.Output(size=(80, 20))], - [sg.Multiline(size=(70, 5), enter_submits=True), sg.ReadFormButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0])), sg.SimpleButton('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]] - # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form - # if you call LayoutAndRead from here, then you will miss the first button click - form.Layout(layout) - # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # - while True: - button, value = form.Read() - if button == 'SEND': - print(value) - else: - break - -# Shows a form that's a running counter -# this is the basic design pattern if you can keep your reading of the -# form within the 'with' block. If your read occurs far away in your code from the form creation -# then you will want to use the NonBlockingPeriodicUpdateForm example -def NonBlockingPeriodicUpdateForm_ContextManager(): - with sg.FlexForm('Running Timer', auto_size_text=True) as form: - text_element = sg.Text('', size=(10, 2), font=('Helvetica', 20), text_color='red', justification='center') - layout = [[sg.Text('Non blocking GUI with updates', justification='center')], - [text_element], - [sg.T(' ' * 15), sg.Quit()]] - form.LayoutAndRead(layout, non_blocking=True) - - for i in range(1,500): - text_element.Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100)) - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': # if user closed the window using X - break - time.sleep(.01) - else: - # if the loop finished then need to close the form for the user - form.CloseNonBlockingForm() - -# Use this context-manager-free version if your read of the form occurs far away in your code -# from the form creation (call to LayoutAndRead) -def NonBlockingPeriodicUpdateForm(): - # Show a form that's a running counter - form = sg.FlexForm('Running Timer', auto_size_text=True) - text_element = sg.Text('', size=(10, 2), font=('Helvetica', 20), justification='center') - form_rows = [[sg.Text('Non blocking GUI with updates')], - [text_element], - [sg.T(' ' * 15), sg.Quit()]] - form.LayoutAndRead(form_rows, non_blocking=True) - - for i in range(1,50000): - text_element.Update('{:02d}:{:02d}.{:02d}'.format((i//100)//60, (i//100)%60, i%100)) - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': # if user closed the window using X or clicked Quit button - break - time.sleep(.01) - else: - # if the loop finished then need to close the form for the user - form.CloseNonBlockingForm() - del(form) - -def DebugTest(): - # SG.Print('How about we print a bunch of random numbers?', , size=(90,40)) - for i in range (1,300): - sg.Print(i, randint(1, 1000), end='', sep='-') - - -def main(): - # SG.SetOptions(border_width=1, font=("Helvetica", 10), button_color=('white', SG.BLUES[0]), slider_border_width=1) - NonBlockingPeriodicUpdateForm_ContextManager() - NonBlockingPeriodicUpdateForm() - Everything_NoContextManager() - Everything() - ChatBot() - ProgressMeter() - SourceDestFolders() - ChatBot() - DebugTest() - sg.MsgBox('Done with all recipes') - -if __name__ == '__main__': - main() - exit(69) diff --git a/Demo Tabbed Form.py b/Demo Tabbed Form.py deleted file mode 100644 index 305202ebb..000000000 --- a/Demo Tabbed Form.py +++ /dev/null @@ -1,89 +0,0 @@ -import PySimpleGUI as sg - -MAX_NUMBER_OF_THREADS = 12 - -def eBaySuperSearcherGUI(): - # Drop Down list of options - configs = ('0 - Gruen - Started 2 days ago in Watches', - '1 - Gruen - Currently Active in Watches', - '2 - Alpina - Currently Active in Jewelry', - '3 - Gruen - Ends in 1 day in Watches', - '4 - Gruen - Completed in Watches', - '5 - Gruen - Advertising', - '6 - Gruen - Currently Active in Jewelry', - '7 - Gruen - Price Test', - '8 - Gruen - No brand name specified') - - us_categories = ('Use Default with no change', - 'All - 1', - 'Jewelry - 281', - ' Watches - 14324', - ' Wristwatches - 31387', - ' Pocket Watches - 3937', - 'Advertising - 34', - ' Watch Ads - 165254' - ) - - german_categories =('Use Default with no change', - 'All - 1', - 'Jewelry - 281', - ' Watches - 14324', - ' Wristwatches - 31387', - ' Pocket Watches - 3937', - 'Advertising - 1', - ' Watch Ads - 19823' - ) - - - # the form layout - with sg.FlexForm('EBay Super Searcher', auto_size_text=True) as form: - with sg.FlexForm('EBay Super Searcher') as form2: - layout_tab_1 = [[sg.Text('eBay Super Searcher!', size=(60,1), font=('helvetica', 15))], - [sg.Text('Choose base configuration to run')], - [sg.InputCombo(configs)], - [sg.Text('_'*100, size=(80,1))], - [sg.InputText(),sg.Text('Choose Destination Folder'), sg.FolderBrowse(target=(sg.ThisRow,0))], - [sg.InputText(),sg.Text('Custom text to add to folder name')], - [sg.Text('_'*100, size=(80,1))], - [sg.Checkbox('US', default=True, size=(15, 1)), sg.Checkbox('German', size=(15, 1), default=True, )], - [sg.Radio('Active Listings','ActiveComplete', default = True,size=(15, 1)), sg.Radio('Completed Listings', 'ActiveComplete', size=(15, 1))], - [sg.Text('_'*100, size=(80,1))], - [sg.Checkbox('Save Images', size=(15,1)),sg.Checkbox('Save PDFs', size=(15,1)), sg.Checkbox('Extract PDFs', size=(15,1))], - [sg.Text('_'*100, size=(80,1))], - [sg.Text('Time Filters')], - [sg.Radio('No change','time', default=True),sg.Radio('ALL listings','time'),sg.Radio('Started 1 day ago','time', size=(15,1)),sg.Radio('Started 2 days ago','time', size=(15,1)), sg.Radio('Ends in 1 day','time', size=(15,1))], - [sg.Text('_'*100, size=(80,1))], - [sg.Text('Price Range'), sg.InputText(size=(10,1)),sg.Text('To'), sg.InputText(size=(10,1))], - [sg.Text('_'*100, size=(80,1))], - [sg.Submit(button_color=('red', 'yellow')), sg.Cancel(button_color=('white', 'blue')), sg.Text(f'{MAX_NUMBER_OF_THREADS} Threads will be started')]] - - - # First category is default (need to special case this) - layout_tab_2 = [[sg.Text('Choose Category')], - [sg.Text('US Categories'),sg.Text('German Categories')], - [sg.Radio(us_categories[0],'CATUS', default=True), sg.Radio(german_categories[0], 'CATDE', default=True)]] - - for i,cat in enumerate(us_categories): - if i == 0: continue # skip first one - layout_tab_2.append([sg.Radio(cat,'CATUS'), sg.Radio(german_categories[i],'CATDE')]) - - - layout_tab_2.append([sg.Text('_' * 100, size=(75, 1))]) - layout_tab_2.append([sg.Text('US Search String Override')]) - layout_tab_2.append([sg.InputText(size=(100,1))]) - layout_tab_2.append([sg.Text('German Search String Override')]) - layout_tab_2.append([sg.InputText(size=(100,1))]) - layout_tab_2.append([sg.Text('Typical US Search String')]) - layout_tab_2.append([sg.InputText(size=(100,1), default_text='gruen -sara -quarz -quartz -embassy -bob -robert -elephants -adidas -LED ')]) - layout_tab_2.append([sg.Text('_' * 100, size=(75, 1))]) - layout_tab_2.append([sg.Submit(button_color=('red', 'yellow'),auto_size_text=True), sg.Cancel(button_color=('white', 'blue'), auto_size_text=True)]) - - results =sg.ShowTabbedForm('eBay Super Searcher', (form,layout_tab_1,'Where To Save'), (form2, layout_tab_2, 'Categories & Search String')) - - return results - - -if __name__ == '__main__': - results = eBaySuperSearcherGUI() - print(results) - sg.MsgBox('Results', results) \ No newline at end of file From 60173f9b6c6846e213f7f0f535867c1823355efb Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 26 Jul 2018 19:53:17 -0400 Subject: [PATCH 072/209] RELEASE 2.5 Background colors. Readme for 2.5 --- PySimpleGUI.py | 273 +++++++++++++++++++++++++++++++++++-------------- readme.md | 111 +++++++++++++++----- 2 files changed, 279 insertions(+), 105 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index ab01ba2cf..006a04dcd 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -29,16 +29,23 @@ TANS = ("#FFF9D5","#F4EFCF","#DDD8BA") NICE_BUTTON_COLORS = ((GREENS[3], TANS[0]), ('#000000','#FFFFFF'),('#FFFFFF', '#000000'), (YELLOWS[0], PURPLES[1]), (YELLOWS[0], GREENS[3]), (YELLOWS[0], BLUES[2])) + +COLOR_SYSTEM_DEFAULT = '1234567890' # Colors should never be this long +DEFAULT_BUTTON_COLOR = ('white', BLUES[0]) # Foreground, Background (None, None) == System Default +DEFAULT_ERROR_BUTTON_COLOR =("#FFFFFF", "#FF0000") +DEFAULT_CANCEL_BUTTON_COLOR = (GREENS[3], TANS[0]) +DEFAULT_BACKGROUND_COLOR = None +DEFAULT_ELEMENT_BACKGROUND_COLOR = None +DEFAULT_TEXT_ELEMENT_BACKGROUND_COLOR = None +DEFAULT_TEXT_COLOR = 'black' +DEFAULT_INPUT_ELEMENTS_COLOR = COLOR_SYSTEM_DEFAULT +DEFAULT_SCROLLBAR_COLOR = None # DEFAULT_BUTTON_COLOR = (YELLOWS[0], PURPLES[0]) # (Text, Background) or (Color "on", Color) as a way to remember # DEFAULT_BUTTON_COLOR = (GREENS[3], TANS[0]) # Foreground, Background (None, None) == System Default # DEFAULT_BUTTON_COLOR = (YELLOWS[0], GREENS[4]) # Foreground, Background (None, None) == System Default -DEFAULT_BUTTON_COLOR = ('white', BLUES[0]) # Foreground, Background (None, None) == System Default # DEFAULT_BUTTON_COLOR = ('white', 'black') # Foreground, Background (None, None) == System Default # DEFAULT_BUTTON_COLOR = (YELLOWS[0], PURPLES[2]) # Foreground, Background (None, None) == System Default -DEFAULT_ERROR_BUTTON_COLOR =("#FFFFFF", "#FF0000") -DEFAULT_CANCEL_BUTTON_COLOR = (GREENS[3], TANS[0]) # DEFAULT_PROGRESS_BAR_COLOR = (GREENS[2], GREENS[0]) # a nice green progress bar -DEFAULT_PROGRESS_BAR_COLOR = (GREENS[3], GREENS[3]) # a nice green progress bar # DEFAULT_PROGRESS_BAR_COLOR = (BLUES[1], BLUES[1]) # a nice green progress bar # DEFAULT_PROGRESS_BAR_COLOR = (BLUES[0], BLUES[0]) # a nice green progress bar # DEFAULT_PROGRESS_BAR_COLOR = (PURPLES[1],PURPLES[0]) # a nice purple progress bar @@ -46,10 +53,19 @@ # A transparent button is simply one that matches the background TRANSPARENT_BUTTON = ('#F0F0F0', '#F0F0F0') #-------------------------------------------------------------------------------- +# Progress Bar Relief Choices +RELIEF_RAISED= 'raised' +RELIEF_SUNKEN= 'sunken' +RELIEF_FLAT= 'flat' +RELIEF_RIDGE= 'ridge' +RELIEF_GROOVE= 'groove' +RELIEF_SOLID = 'solid' -DEFAULT_PROGRESS_BAR_SIZE = (35,25) # Size of Progress Bar (characters for length, pixels for width) +DEFAULT_PROGRESS_BAR_COLOR = (GREENS[0], '#D0D0D0') # a nice green progress bar +DEFAULT_PROGRESS_BAR_SIZE = (35,20) # Size of Progress Bar (characters for length, pixels for width) DEFAULT_PROGRESS_BAR_BORDER_WIDTH=1 -DEFAULT_PROGRESS_BAR_RELIEF = tk.SUNKEN +DEFAULT_PROGRESS_BAR_RELIEF = RELIEF_GROOVE +PROGRESS_BAR_STYLES = ('default','winnative', 'clam', 'alt', 'classic', 'vista', 'xpnative') DEFAULT_PROGRESS_BAR_STYLE = 'default' DEFAULT_METER_ORIENTATION = 'Horizontal' DEFAULT_SLIDER_ORIENTATION = 'vertical' @@ -69,16 +85,8 @@ # DEFAULT_METER_ORIENTATION = 'Vertical' # ----====----====----==== Constants the user should NOT f-with ====----====----====----# ThisRow = 555666777 # magic number -# Progress Bar Relief Choices -# -relief -RELIEF_RAISED= 'raised' -RELIEF_SUNKEN= 'sunken' -RELIEF_FLAT= 'flat' -RELIEF_RIDGE= 'ridge' -RELIEF_GROOVE= 'groove' -RELIEF_SOLID = 'solid' -PROGRESS_BAR_STYLES = ('default','winnative', 'clam', 'alt', 'classic', 'vista', 'xpnative') + # DEFAULT_WINDOW_ICON = '' MESSAGE_BOX_LINE_WIDTH = 60 @@ -142,7 +150,7 @@ def RGB(red,green,blue): return '#%02x%02x%02x' % (red,green,blue) # Element CLASS # # ------------------------------------------------------------------------- # class Element(): - def __init__(self, type, scale=(None, None), size=(None, None), auto_size_text=None, font=None): + def __init__(self, type, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None): self.Size = size self.Type = type self.AutoSizeText = auto_size_text @@ -159,6 +167,7 @@ def __init__(self, type, scale=(None, None), size=(None, None), auto_size_text=N self.ParentForm=None self.TextInputDefault = None self.Position = (0,0) # Default position Row 0, Col 0 + self.BackgroundColor = background_color if background_color is not None else DEFAULT_ELEMENT_BACKGROUND_COLOR return def __del__(self): @@ -184,10 +193,11 @@ def __del__(self): # ---------------------------------------------------------------------- # class InputText(Element): - def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char=''): + def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None): self.DefaultText = default_text self.PasswordCharacter = password_char - super().__init__(ELEM_TYPE_INPUT_TEXT, scale, size, auto_size_text) + bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR + super().__init__(ELEM_TYPE_INPUT_TEXT, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg) return def ReturnKeyHandler(self, event): @@ -208,10 +218,11 @@ def __del__(self): # ---------------------------------------------------------------------- # class InputCombo(Element): - def __init__(self, values, scale=(None, None), size=(None, None), auto_size_text=None): + def __init__(self, values, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None): self.Values = values self.TKComboBox = None - super().__init__(ELEM_TYPE_INPUT_COMBO, scale, size, auto_size_text) + bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR + super().__init__(ELEM_TYPE_INPUT_COMBO, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg) return def __del__(self): @@ -227,7 +238,7 @@ def __del__(self): # ---------------------------------------------------------------------- # class Listbox(Element): - def __init__(self, values, select_mode=None, scale=(None, None), size=(None, None), auto_size_text=None, font=None): + def __init__(self, values, select_mode=None, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None): self.Values = values self.TKListBox = None if select_mode == LISTBOX_SELECT_MODE_BROWSE: @@ -240,7 +251,8 @@ def __init__(self, values, select_mode=None, scale=(None, None), size=(None, Non self.SelectMode = SELECT_MODE_SINGLE else: self.SelectMode = DEFAULT_LISTBOX_SELECT_MODE - super().__init__(ELEM_TYPE_INPUT_LISTBOX, scale=scale, size=size, auto_size_text=auto_size_text, font=font) + bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR + super().__init__(ELEM_TYPE_INPUT_LISTBOX, scale=scale, size=size, auto_size_text=auto_size_text, font=font, background_color=bg) return def __del__(self): @@ -256,13 +268,13 @@ def __del__(self): # Radio # # ---------------------------------------------------------------------- # class Radio(Element): - def __init__(self, text, group_id, default=False, scale=(None, None), size=(None, None), auto_size_text=None, font=None): + def __init__(self, text, group_id, default=False, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, font=None): self.InitialState = default self.Text = text self.TKRadio = None self.GroupID = group_id self.Value = None - super().__init__(ELEM_TYPE_INPUT_RADIO, scale, size, auto_size_text, font) + super().__init__(ELEM_TYPE_INPUT_RADIO, scale=scale , size=size, auto_size_text=auto_size_text, font=font, background_color=background_color) return def __del__(self): @@ -276,13 +288,13 @@ def __del__(self): # Checkbox # # ---------------------------------------------------------------------- # class Checkbox(Element): - def __init__(self, text, default=False, scale=(None, None), size=(None, None), auto_size_text=None, font=None): + def __init__(self, text, default=False, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None): self.Text = text self.InitialState = default self.Value = None self.TKCheckbox = None - super().__init__(ELEM_TYPE_INPUT_CHECKBOX, scale, size, auto_size_text, font) + super().__init__(ELEM_TYPE_INPUT_CHECKBOX, scale=scale, size=size, auto_size_text=auto_size_text, font=font, background_color=background_color) return def __del__(self): @@ -299,11 +311,12 @@ def __del__(self): class Spin(Element): # Values = None # TKSpinBox = None - def __init__(self, values, initial_value=None, scale=(None, None), size=(None, None), auto_size_text=None, font=None): + def __init__(self, values, initial_value=None, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None): self.Values = values self.DefaultValue = initial_value self.TKSpinBox = None - super().__init__(ELEM_TYPE_INPUT_SPIN, scale, size, auto_size_text, font=font) + bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR + super().__init__(ELEM_TYPE_INPUT_SPIN, scale, size, auto_size_text, font=font,background_color=bg) return def __del__(self): @@ -317,10 +330,11 @@ def __del__(self): # Multiline # # ---------------------------------------------------------------------- # class Multiline(Element): - def __init__(self, default_text='', enter_submits = False, scale=(None, None), size=(None, None), auto_size_text=None): + def __init__(self, default_text='', enter_submits = False, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None): self.DefaultText = default_text self.EnterSubmits = enter_submits - super().__init__(ELEM_TYPE_INPUT_MULTILINE, scale, size, auto_size_text) + bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR + super().__init__(ELEM_TYPE_INPUT_MULTILINE, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg) return def ReturnKeyHandler(self, event): @@ -340,13 +354,17 @@ def __del__(self): # Text # # ---------------------------------------------------------------------- # class Text(Element): - def __init__(self, text, scale=(None, None), size=(None, None), auto_size_text=None, font=None, text_color=None, justification=None): + def __init__(self, text, scale=(None, None), size=(None, None), auto_size_text=None, font=None, text_color=None, background_color=None,justification=None): self.DisplayText = text - self.TextColor = text_color if text_color else 'black' + self.TextColor = text_color if text_color else DEFAULT_TEXT_COLOR self.Justification = justification if justification else DEFAULT_TEXT_JUSTIFICATION + if background_color is None: + bg = DEFAULT_TEXT_ELEMENT_BACKGROUND_COLOR + else: + bg = background_color # self.Font = Font if Font else DEFAULT_FONT # i=1/0 - super().__init__(ELEM_TYPE_TEXT, scale, size, auto_size_text, font=font if font else DEFAULT_FONT) + super().__init__(ELEM_TYPE_TEXT, scale, size, auto_size_text, background_color=bg, font=font if font else DEFAULT_FONT) return def Update(self, NewValue): @@ -364,7 +382,7 @@ def __del__(self): # ---------------------------------------------------------------------- # class TKProgressBar(): - def __init__(self, root, max, length=400, width=20, highlightt=0, relief='sunken', border_width=4, orientation='horizontal', BarColor=DEFAULT_PROGRESS_BAR_COLOR): + def __init__(self, root, max, length=400, width=DEFAULT_PROGRESS_BAR_SIZE[1], style=DEFAULT_PROGRESS_BAR_STYLE, relief=DEFAULT_PROGRESS_BAR_RELIEF, border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH, orientation='horizontal', BarColor=DEFAULT_PROGRESS_BAR_COLOR): self.Length = length self.Width = width self.Max = max @@ -372,39 +390,35 @@ def __init__(self, root, max, length=400, width=20, highlightt=0, relief='sunken self.Count = None self.PriorCount = 0 if orientation[0].lower() == 'h': - self.TKCanvas = tk.Canvas(root, width=length, height=width, highlightt=highlightt, relief=relief, borderwidth=border_width) - self.TKRect = self.TKCanvas.create_rectangle(0, 0, -(length * 1.5), width * 1.5, fill=BarColor[0], tags='bar') + s = ttk.Style() + s.theme_use(style) + s.configure("my.Horizontal.TProgressbar", background=BarColor[0], troughcolor=BarColor[1], troughrelief=relief, borderwidth=border_width, thickness=width) + self.TKProgressBarForReal = ttk.Progressbar(root, maximum=self.Max, style='my.Horizontal.TProgressbar', length=length, orient=tk.HORIZONTAL, mode='determinate') + # self.TKCanvas = tk.Canvas(root, width=length, height=width, highlightt=highlightt, relief=relief, borderwidth=border_width) + # self.TKRect = self.TKCanvas.create_rectangle(0, 0, -(length * 1.5), width * 1.5, fill=BarColor[0], tags='bar') # self.canvas.pack(padx='10') else: - self.TKCanvas = tk.Canvas(root, width=width, height=length, highlightt=highlightt, relief=relief, borderwidth=border_width) - self.TKRect = self.TKCanvas.create_rectangle(width * 1.5, 2 * length + 40, 0, length * .5, fill=BarColor[0], tags='bar') + # s = ttk.Style() + # s.theme_use('clam') + # s.configure('Vertical.mycolor.progbar', forground=BarColor[0], background=BarColor[1]) + s = ttk.Style() + s.theme_use(style) + s.configure("my.Vertical.TProgressbar", background=BarColor[0], troughcolor=BarColor[1], troughrelief=relief, borderwidth=border_width, thickness=width) + self.TKProgressBarForReal = ttk.Progressbar(root, maximum=self.Max, style='my.Vertical.TProgressbar', length=length, orient=tk.VERTICAL, mode='determinate') + # self.TKCanvas = tk.Canvas(root, width=width, height=length, highlightt=highlightt, relief=relief, borderwidth=border_width) + # self.TKRect = self.TKCanvas.create_rectangle(width * 1.5, 2 * length + 40, 0, length * .5, fill=BarColor[0], tags='bar') # self.canvas.pack() def Update(self, count): - if count > self.Max: return - if self.Orientation[0].lower() == 'h': - try: - if count != self.PriorCount: - delta = count - self.PriorCount - self.TKCanvas.move(self.TKRect, delta*(self.Length / self.Max), 0) - if 0: self.TKCanvas.update() - except: - return False # the window was closed by the user on us - else: - try: - if count != self.PriorCount: - delta = count - self.PriorCount - self.TKCanvas.move(self.TKRect, 0, delta*(-self.Length / self.Max)) - if 0: self.TKCanvas.update() - except: - return False # the window was closed by the user on us - self.PriorCount = count + if count > self.Max: return False + try: + self.TKProgressBarForReal['value'] = count + except: return False return True def __del__(self): try: - self.TKCanvas.__del__() - self.TKRect.__del__() + self.TKProgressBarForReal.__del__() except: pass @@ -413,14 +427,15 @@ def __del__(self): # New Type of Widget that's a Text Widget in disguise # # ---------------------------------------------------------------------- # class TKOutput(tk.Frame): - def __init__(self, parent, width, height, bd): + def __init__(self, parent, width, height, bd, background_color=None): tk.Frame.__init__(self, parent) self.output = tk.Text(parent, width=width, height=height, bd=bd) - + if background_color and background_color != COLOR_SYSTEM_DEFAULT: + self.output.configure(background=background_color) self.vsb = tk.Scrollbar(parent, orient="vertical", command=self.output.yview) - self.vsb.pack(side="right", fill="y") self.output.configure(yscrollcommand=self.vsb.set) self.output.pack(side="left", fill="both", expand=True) + self.vsb.pack(side="left", fill="y") self.previous_stdout = sys.stdout self.previous_stderr = sys.stderr @@ -448,9 +463,10 @@ def __del__(self): sys.stderr = self.previous_stderr class Output(Element): - def __init__(self, scale=(None, None), size=(None, None)): + def __init__(self, scale=(None, None), size=(None, None), background_color=None): self.TKOut = None - super().__init__(ELEM_TYPE_OUTPUT, scale, size) + bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR + super().__init__(ELEM_TYPE_OUTPUT, scale=scale, size=size, background_color=bg) def __del__(self): try: @@ -607,14 +623,14 @@ def __del__(self): # Slider # # ---------------------------------------------------------------------- # class Slider(Element): - def __init__(self, range=(None,None), default_value=None, orientation=None, border_width=None, relief=None, scale=(None, None), size=(None, None), font=None): + def __init__(self, range=(None,None), default_value=None, orientation=None, border_width=None, relief=None, scale=(None, None), size=(None, None), font=None, background_color=None): self.TKScale = None self.Range = (1,10) if range == (None, None) else range self.DefaultValue = 5 if default_value is None else default_value self.Orientation = orientation if orientation else DEFAULT_SLIDER_ORIENTATION self.BorderWidth = border_width if border_width else DEFAULT_SLIDER_BORDER_WIDTH self.Relief = relief if relief else DEFAULT_SLIDER_RELIEF - super().__init__(ELEM_TYPE_INPUT_SLIDER, scale=scale, size=size, font=font) + super().__init__(ELEM_TYPE_INPUT_SLIDER, scale=scale, size=size, font=font, background_color=background_color) return def __del__(self): @@ -651,7 +667,7 @@ class FlexForm: ''' Display a user defined for and return the filled in data ''' - def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=DEFAULT_AUTOSIZE_TEXT, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON): + def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=DEFAULT_AUTOSIZE_TEXT, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON): self.AutoSizeText = auto_size_text self.Title = title self.Rows = [] # a list of ELEMENTS for this row @@ -659,6 +675,7 @@ def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT self.Scale = scale self.Location = location self.ButtonColor = button_color if button_color else DEFAULT_BUTTON_COLOR + self.BackgroundColor = background_color if background_color else DEFAULT_BACKGROUND_COLOR self.IsTabbedForm = is_tabbed_form self.ParentWindow = None self.Font = font if font else DEFAULT_FONT @@ -1139,6 +1156,8 @@ def CharWidthInPixels(): # Set wrap-length for text (in PIXELS) == PAIN IN THE ASS wraplen = tktext_label.winfo_reqwidth() # width of widget in Pixels tktext_label.configure(anchor=anchor, font=font, wraplen=wraplen*2 ) # set wrap to width of widget + if element.BackgroundColor is not None: + tktext_label.configure(background=element.BackgroundColor) tktext_label.pack(side=tk.LEFT) # ------------------------- BUTTON element ------------------------- # elif element_type == ELEM_TYPE_BUTTON: @@ -1188,6 +1207,8 @@ def CharWidthInPixels(): show = element.PasswordCharacter if element.PasswordCharacter else "" element.TKEntry = tk.Entry(tk_row_frame, width=element_size[0], textvariable=element.TKStringVar, bd=border_depth, font=font, show=show) element.TKEntry.bind('', element.ReturnKeyHandler) + if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: + element.TKEntry.configure(background=element.BackgroundColor) element.TKEntry.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) if not focus_set: focus_set = True @@ -1198,11 +1219,27 @@ def CharWidthInPixels(): if auto_size_text is False: width=element_size[0] else: width = max_line_len element.TKStringVar = tk.StringVar() + if element.BackgroundColor and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: + combostyle = ttk.Style() + try: + combostyle.theme_create('combostyle', + settings={'TCombobox': + {'configure': + {'selectbackground': element.BackgroundColor, + 'fieldbackground': element.BackgroundColor, + 'background': element.BackgroundColor} + }}) + except: pass + # ATTENTION: this applies the new style 'combostyle' to all ttk.Combobox + combostyle.theme_use('combostyle') element.TKCombo = ttk.Combobox(tk_row_frame, width=width, textvariable=element.TKStringVar,font=font ) + # element.TKCombo['state']='readonly' element.TKCombo['values'] = element.Values + # if element.BackgroundColor is not None: + # element.TKCombo.configure(background=element.BackgroundColor) element.TKCombo.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) element.TKCombo.current(0) - # ------------------------- LISTBOX (Drop Down) element ------------------------- # + # ------------------------- LISTBOX element ------------------------- # elif element_type == ELEM_TYPE_INPUT_LISTBOX: max_line_len = max([len(str(l)) for l in element.Values]) if auto_size_text is False: width=element_size[0] @@ -1213,13 +1250,21 @@ def CharWidthInPixels(): for item in element.Values: element.TKListbox.insert(tk.END, item) element.TKListbox.selection_set(0,0) + if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: + element.TKListbox.configure(background=element.BackgroundColor) + # vsb = tk.Scrollbar(tk_row_frame, orient="vertical", command=element.TKListbox.yview) + # element.TKListbox.configure(yscrollcommand=vsb.set) element.TKListbox.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) + # vsb.pack(side=tk.LEFT, fill='y') # ------------------------- INPUT MULTI LINE element ------------------------- # elif element_type == ELEM_TYPE_INPUT_MULTILINE: default_text = element.DefaultText width, height = element_size element.TKText = tk.scrolledtext.ScrolledText(tk_row_frame, width=width, height=height, wrap='word', bd=border_depth,font=font) element.TKText.insert(1.0, default_text) # set the default text + if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: + element.TKText.configure(background=element.BackgroundColor) + element.TKText.vbar.config(troughcolor=DEFAULT_SCROLLBAR_COLOR) element.TKText.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) if element.EnterSubmits: element.TKText.bind('', element.ReturnKeyHandler) @@ -1233,6 +1278,8 @@ def CharWidthInPixels(): element.TKIntVar = tk.IntVar() element.TKIntVar.set(default_value) element.TKCheckbutton = tk.Checkbutton(tk_row_frame, anchor=tk.NW, text=element.Text, width=width, variable=element.TKIntVar, bd=border_depth, font=font) + if element.BackgroundColor is not None: + element.TKCheckbutton.configure(background=element.BackgroundColor) element.TKCheckbutton.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) # ------------------------- PROGRESS BAR element ------------------------- # elif element_type == ELEM_TYPE_PROGRESS_BAR: @@ -1249,9 +1296,9 @@ def CharWidthInPixels(): bar_color = element.BarColor else: bar_color = DEFAULT_PROGRESS_BAR_COLOR - element.TKProgressBar = TKProgressBar(tk_row_frame, element.MaxValue, progress_length, progress_width, orientation=direction, BarColor=bar_color, border_width=element.BorderWidth, relief=element.Relief) - s = ttk.Style() - element.TKProgressBar.TKCanvas.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) + element.TKProgressBar = TKProgressBar(tk_row_frame, element.MaxValue, progress_length, progress_width, orientation=direction, BarColor=bar_color, border_width=element.BorderWidth, relief=element.Relief, style=element.BarStyle ) + # element.TKProgressBar = TKProgressBar(tk_row_frame, element.MaxValue, progress_length, progress_width, orientation=direction, BarColor=bar_color, border_width=element.BorderWidth, relief=element.Relief) + element.TKProgressBar.TKProgressBarForReal.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) # ------------------------- INPUT RADIO BUTTON element ------------------------- # elif element_type == ELEM_TYPE_INPUT_RADIO: width = 0 if auto_size_text else element_size[0] @@ -1269,7 +1316,9 @@ def CharWidthInPixels(): element.TKIntVar.set(value) element.TKRadio = tk.Radiobutton(tk_row_frame, anchor=tk.NW, text=element.Text, width=width, variable=element.TKIntVar, value=value, bd=border_depth, font=font) - element.TKRadio.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) + if element.BackgroundColor is not None: + element.TKRadio.configure(background=element.BackgroundColor) + element.TKRadio.pack(side=tk.LEFT, padx=element.Pad[0],pady=element.Pad[1]) # ------------------------- INPUT SPIN Box element ------------------------- # elif element_type == ELEM_TYPE_INPUT_SPIN: width, height = element_size @@ -1278,11 +1327,13 @@ def CharWidthInPixels(): element.TKSpinBox = tk.Spinbox(tk_row_frame, values=element.Values, textvariable=element.TKStringVar, width=width, bd=border_depth) element.TKStringVar.set(element.DefaultValue) element.TKSpinBox.configure(font=font) # set wrap to width of widget + if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: + element.TKSpinBox.configure(background=element.BackgroundColor) element.TKSpinBox.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) # ------------------------- OUTPUT element ------------------------- # elif element_type == ELEM_TYPE_OUTPUT: width, height = element_size - element.TKOut = TKOutput(tk_row_frame, width=width, height=height, bd=border_depth) + element.TKOut = TKOutput(tk_row_frame, width=width, height=height, bd=border_depth, background_color=element.BackgroundColor) element.TKOut.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) # ------------------------- IMAGE Box element ------------------------- # elif element_type == ELEM_TYPE_IMAGE: @@ -1309,10 +1360,15 @@ def CharWidthInPixels(): range_to = element.Range[1] tkscale = tk.Scale(tk_row_frame, orient=element.Orientation, variable=element.TKIntVar, from_=range_from, to_=range_to, length=slider_length, width=slider_width , bd=element.BorderWidth, relief=element.Relief, font=font) # tktext_label.configure(anchor=tk.NW, image=photo) + if element.BackgroundColor is not None: + tkscale.configure(background=element.BackgroundColor) + tkscale.config(troughcolor=DEFAULT_SCROLLBAR_COLOR) tkscale.pack(side=tk.LEFT) #............................DONE WITH ROW pack the row of widgets ..........................# # done with row, pack the row of widgets tk_row_frame.grid(row=row_num+2, sticky=tk.W, padx=DEFAULT_MARGINS[0]) + if MyFlexForm.BackgroundColor is not None: + tk_row_frame.configure(background=MyFlexForm.BackgroundColor) if not MyFlexForm.IsTabbedForm: MyFlexForm.TKroot.configure(padx=DEFAULT_MARGINS[0], pady=DEFAULT_MARGINS[1]) else: MyFlexForm.ParentWindow.configure(padx=DEFAULT_MARGINS[0], pady=DEFAULT_MARGINS[1]) @@ -1351,11 +1407,26 @@ def ShowTabbedForm(title, *args, auto_close=False, auto_close_duration=DEFAULT_A if not len(args): ('******************* SHOW TABBED FORMS ERROR .... no arguments') return + if DEFAULT_BACKGROUND_COLOR: + framestyle = ttk.Style() + try: + framestyle.theme_create('framestyle', parent='alt', + settings={'TFrame': + {'configure': + {'background': DEFAULT_BACKGROUND_COLOR, + }}}) + except: pass + # ATTENTION: this applies the new style 'combostyle' to all ttk.Combobox + # framestyle.theme_use('framestyle') tab_control = ttk.Notebook(root) for num,x in enumerate(args): form, rows, tab_name = x form.AddRows(rows) + + if DEFAULT_BACKGROUND_COLOR: + framestyle.theme_use('framestyle') tab = ttk.Frame(tab_control) # Create tab 1 + # s.configure("my.Frame.TFrame", background=DEFAULT_BACKGROUND_COLOR) tab_control.add(tab, text=tab_name) # Add tab 1 # tab_control.configure(text='new text') tab_control.grid(row=0, sticky=tk.W) @@ -1386,6 +1457,8 @@ def StartupTK(my_flex_form): ow = _my_windows.NumOpenWindows root = tk.Tk() if not ow else tk.Toplevel() + if my_flex_form.BackgroundColor is not None: + root.configure(background=my_flex_form.BackgroundColor) _my_windows.NumOpenWindows += 1 my_flex_form.TKroot = root @@ -1604,7 +1677,7 @@ def ConvertArgsToSingleString(*args): # if not isinstance(message, str): message = str(message) message = str(message) longest_line_len = max([len(l) for l in message.split('\n')]) - width_used = min(longest_line_len, MESSAGE_BOX_LINE_WIDTH) + width_used = max(longest_line_len, width_used) max_line_total = max(max_line_total, width_used) lines_needed = _GetNumLinesNeeded(message, width_used) total_lines += lines_needed @@ -1631,7 +1704,7 @@ def ProgressMeter(title, max_value, *args, orientation=None, bar_color=DEFAULT_P local_orientation = DEFAULT_METER_ORIENTATION if orientation is None else orientation local_border_width = DEFAULT_PROGRESS_BAR_BORDER_WIDTH if border_width is None else border_width target = (0,0) if local_orientation[0].lower() == 'h' else (0,1) - bar2 = ProgressBar(max_value, orientation=local_orientation, size=size, bar_color=bar_color, scale=scale, target=target, border_width=local_border_width) + bar2 = ProgressBar(max_value, orientation=local_orientation, size=size, bar_color=bar_color, scale=scale, target=target, border_width=local_border_width, relief=DEFAULT_PROGRESS_BAR_RELIEF) form = FlexForm(title, auto_size_text=True) # Form using a horizontal bar @@ -1640,7 +1713,7 @@ def ProgressMeter(title, max_value, *args, orientation=None, bar_color=DEFAULT_P bar2.TextToDisplay = single_line_message bar2.MaxValue = max_value bar2.CurrentValue = 0 - form.AddRow(Text(single_line_message, size=(width + 20, height + 3), auto_size_text=True)) + form.AddRow(Text(single_line_message, size=(width, height + 3), auto_size_text=True)) form.AddRow((bar2)) form.AddRow((Cancel(button_color=button_color))) else: @@ -1648,7 +1721,7 @@ def ProgressMeter(title, max_value, *args, orientation=None, bar_color=DEFAULT_P bar2.TextToDisplay = single_line_message bar2.MaxValue = max_value bar2.CurrentValue = 0 - form.AddRow(bar2, Text(single_line_message, size=(width +20, height + 3), auto_size_text=True)) + form.AddRow(bar2, Text(single_line_message, size=(width, height + 3), auto_size_text=True)) form.AddRow((Cancel(button_color=button_color))) form.NonBlocking = True @@ -1993,7 +2066,11 @@ def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), ma element_padding=(None,None),auto_size_text=None, font=None, border_width=None, slider_border_width=None, slider_relief=None, slider_orientation=None, autoclose_time=None, message_box_line_width=None, - progress_meter_border_depth=None, text_justification=None, debug_win_size=(None,None)): + progress_meter_border_depth=None, progress_meter_style=None, + progress_meter_relief=None, progress_meter_color=None, progress_meter_size=None, + text_justification=None, background_color=None, element_background_color=None, + text_element_background_color=None, input_elements_background_color=None, + scrollbar_color=None, text_color=None, debug_win_size=(None,None)): global DEFAULT_ELEMENT_SIZE global DEFAULT_MARGINS # Margins for each LEFT/RIGHT margin is first term @@ -2005,11 +2082,21 @@ def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), ma global DEFAULT_BUTTON_COLOR global MESSAGE_BOX_LINE_WIDTH global DEFAULT_PROGRESS_BAR_BORDER_WIDTH + global DEFAULT_PROGRESS_BAR_STYLE + global DEFAULT_PROGRESS_BAR_RELIEF + global DEFAULT_PROGRESS_BAR_COLOR + global DEFAULT_PROGRESS_BAR_SIZE global DEFAULT_TEXT_JUSTIFICATION global DEFAULT_DEBUG_WINDOW_SIZE global DEFAULT_SLIDER_BORDER_WIDTH global DEFAULT_SLIDER_RELIEF global DEFAULT_SLIDER_ORIENTATION + global DEFAULT_BACKGROUND_COLOR + global DEFAULT_INPUT_ELEMENTS_COLOR + global DEFAULT_ELEMENT_BACKGROUND_COLOR + global DEFAULT_TEXT_ELEMENT_BACKGROUND_COLOR + global DEFAULT_SCROLLBAR_COLOR + global DEFAULT_TEXT_COLOR global _my_windows if icon: @@ -2050,6 +2137,18 @@ def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), ma if progress_meter_border_depth != None: DEFAULT_PROGRESS_BAR_BORDER_WIDTH = progress_meter_border_depth + if progress_meter_style != None: + DEFAULT_PROGRESS_BAR_STYLE = progress_meter_style + + if progress_meter_relief != None: + DEFAULT_PROGRESS_BAR_RELIEF = progress_meter_relief + + if progress_meter_color != None: + DEFAULT_PROGRESS_BAR_COLOR = progress_meter_color + + if progress_meter_size != None: + DEFAULT_PROGRESS_BAR_SIZE = progress_meter_size + if slider_border_width != None: DEFAULT_SLIDER_BORDER_WIDTH = slider_border_width @@ -2062,12 +2161,30 @@ def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), ma if text_justification != None: DEFAULT_TEXT_JUSTIFICATION = text_justification + if background_color != None: + DEFAULT_BACKGROUND_COLOR = background_color + + if text_element_background_color != None: + DEFAULT_TEXT_ELEMENT_BACKGROUND_COLOR = text_element_background_color + + if input_elements_background_color != None: + DEFAULT_INPUT_ELEMENTS_COLOR = input_elements_background_color + + if element_background_color != None: + DEFAULT_ELEMENT_BACKGROUND_COLOR = element_background_color + if debug_win_size != (None,None): DEFAULT_DEBUG_WINDOW_SIZE = debug_win_size + if text_color != None: + DEFAULT_TEXT_COLOR = text_color + + if scrollbar_color != None: + DEFAULT_SCROLLBAR_COLOR = scrollbar_color + return True -# ============================== sprint ======#fddddddddddddddddddddddd +# ============================== sprint ======# # Is identical to the Scrolled Text Box # # Provides a crude 'print' mechanism but in a # # GUI environment # diff --git a/readme.md b/readme.md index 6da141ebd..787fe6850 100644 --- a/readme.md +++ b/readme.md @@ -3,7 +3,7 @@ [![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 # PySimpleGUI - (Ver 2.4) + (Ver 2.5) Super-simple GUI to grasp... Powerfully customizable. @@ -16,13 +16,22 @@ Looking to take your Python code from the world of command lines and into the co ![snap0136](https://user-images.githubusercontent.com/13696193/43162494-33095ece-8f59-11e8-86de-b6d8bcc5a52f.jpg) -Add a Progress Meter to your code with ONE LINE of code + Build beautiful customized forms that fit your specific problem. Let PySimpleGUI solve your GUI problem while you solve the real problems. Do you really want to plod through the mountains of code required to program tkinter? + +![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) + +Perhaps you're looking for a way to interact with your Raspberry Pi in a more friendly way. The is the same form as above, except shown on a Pi. + +![snap0153](https://user-images.githubusercontent.com/13696193/43261051-5838b356-90a9-11e8-96cc-e8a4860d0464.jpg) + + +In addition to a primary GUI, you can add a Progress Meter to your code with ONE LINE of code. Slide this into any of your `for` loops and get a nice meter like this: EasyProgressMeter('My meter title', current_value, max value) ![progress meter 2](https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg) -Or how about a media player GUI with custom buttons... in 30 lines of code. +You can build an async media player GUI with custom buttons in 30 lines of code. ![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) @@ -112,9 +121,6 @@ You will see a number of different styles of buttons, data entry fields, etc, in - A row is a list of elements - Return values are a list - Each Elements is specified by names such as Text, Button, Checkbox, etc. - -Some elements have shortcuts, meant to make it easy on the programmer who will write less code using them. Rather than writing calling `Button`, with `button_name = "Submit"` will create a button with the text 'Submit' on it, Other examples include shortening the name of the function. `Text` is shorted to `Txt` or `T`. See each API call for the shortcuts. ----- ## Getting Started with PySimpleGUI @@ -1035,27 +1041,64 @@ Recall that values is a list as well. Multiple tabs in the form would return li ((button1, (values1)), (button2, (values2)) + ## Colors ## +Starting in version 2.5 you can change the background colors for the window and the Elements. + +Your forms can go from this: +![snap0155](https://user-images.githubusercontent.com/13696193/43273879-a9fdc10a-90cb-11e8-8c20-4f6a244ebe2f.jpg) + + +to this... with one function call... + +![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) + + + +While you can do it on an element by element or form level basis, the easiest way, by far, is a call to `SetOptions`. + +Be aware that once you change these options they are changed for the rest of your program's execution. All of your forms will have that look and feel, until you change it to something else (which could be the system default colors. + +This call sets all of the different color options. + + SetOptions(background_color='#9FB8AD', + text_element_background_color='#9FB8AD', + element_background_color='#9FB8AD', + scrollbar_color=None, + input_elements_background_color='#F7F3EC', + progress_meter_color = ('green', 'blue') + button_color=('white','#475841')) + + ## Global Settings **Global Settings** Let's have some fun customizing! Make PySimpleGUI look the way you want it to look. You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. - SetOptions(icon=None, - button_color=(None,None), - element_size=(None,None), - margins=(None,None), - element_padding=(None,None), - auto_size_text=None, - font=None, - border_width=None, - slider_border_width=None, - slider_relief=None, - slider_orientation=None, - autoclose_time=None, - message_box_line_width=None, - progress_meter_border_depth=None, - text_justification=None, - debug_win_size=(None,None): + SetOptions(icon=None + button_color=(None,None) + element_size=(None,None), + margins=(None,None), + element_padding=(None,None) + auto_size_text=None + font=None + border_width=None + slider_border_width=None + slider_relief=None + slider_orientation=None + autoclose_time=None + message_box_line_width=None + progress_meter_border_depth=None + progress_meter_style=None + progress_meter_relief=None + progress_meter_color=None + progress_meter_size=None + text_justification=None + background_color=None + element_background_color=None + text_element_background_color=None + input_elements_background_color=None + scrollbar_color=None, text_color=None + debug_win_size=(None,None) Explanation of parameters @@ -1073,6 +1116,16 @@ Explanation of parameters autoclose_time - time in seconds for autoclose boxes message_box_line_width - number of characers in a line of text in message boxes progress_meter_border_depth - amount of border around raised or lowered progress meters + progress_meter_style - style of progress meter as defined by tkinter + progress_meter_relief - relief style + progress_meter_color - color of the bar and background of progress meters + progress_meter_size - size in (characters, pixels) + background_color - Color of the main window's background + element_background_color - Background color of the elements + text_element_background_color - Text element background color + input_elements_background_color - Input fields background color + scrollbar_color - Color for scrollbars (may not always work) + text_color - Text element default text color text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' debug_win_size - size of the Print output window @@ -1083,7 +1136,7 @@ These settings apply to all forms `SetOptions`. The Row options and Element opt - Row level - Element level -Each lower level overrides the settings of the higher level +Each lower level overrides the settings of the higher level. Once settings have been changed, they remain changed for the duration of the program (unless changed again). ## Asynchronous (Non-Blocking) Forms So you want to be a wizard do ya? Well go boldly! While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. With asynchronous forms the form is shown, user input is read, but your code keeps right on chugging. YOUR responsibility is to call `PySimpleGUI.ReadNonBlocking` on a periodic basis. Once a second or more will produce a reasonably snappy GUI. @@ -1173,13 +1226,13 @@ That's it... this example follows the async design pattern well. ## Sample Applications Use the example programs as a starting basis for your GUI. Copy, paste, modify and run! The demo files are: +`Demo Recipes.py` - Sample forms for all major form types and situations. This is the place to get your code template from. Includes asynchronous forms, etc. + `Demo DisplayHash1and256.py` - Demonstrates using High Level API calls to get a filename `Demo DupliucateFileFinder.py` - Demonstrates High Level API to get a folder & Easy Progress Meter to show progress of the file scanning -`Demo Recipes.py` - Three sample forms including an asynchronous form - -`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. +`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. If anyone wants to help me package this application up, I could use a hand. ## Fun Stuff Here are some things to try if you're bored or want to further customize @@ -1253,6 +1306,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.2.0| July 20, 2018 - Image Elements, Print output | 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. | 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi +| 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. ### Release Notes 2.3 - Sliders, Listbox's and Image elements (oh my!) @@ -1261,12 +1315,15 @@ If using Progress Meters, avoid cancelling them when you have another window ope New debug printing capability. `sg.Print` +2.5 Discovered issue with scroll bar on `Output` elements. The bar will match size of ROW not the size of the element. Normally you never notice this due to where on a form the `Output` element goes. + +Listboxes are still without scrollwheels. The mouse can drag to see more items. The mouse scrollwheel will also scroll the list and will `page up` and `page down` keys. + ### Upcoming Make suggestions people! Future release features Columns. How multiple columns would be specified in the SDK interface are still being designed. -Progress Meters - Replace custom meter with tkinter meter. ## Code Condition From 4895ab61f2107f1bc8c892859ba640db584378d0 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 27 Jul 2018 15:45:38 -0400 Subject: [PATCH 073/209] RELEASE 2.6 New setting for Button Element sizing. System-wide DEFAULT_AUTO_SIZE_BUTTONS. Can also be set at the form level. This will greatly compact code. --- Demo_HowDoI.py | 3 +- Demo_Recipes.py | 146 +++++++++++++++++++++++++++++++++--------------- PySimpleGUI.py | 106 +++++++++++++++++++++++------------ 3 files changed, 172 insertions(+), 83 deletions(-) diff --git a/Demo_HowDoI.py b/Demo_HowDoI.py index e7385bfdc..257a06561 100644 --- a/Demo_HowDoI.py +++ b/Demo_HowDoI.py @@ -17,7 +17,8 @@ def HowDoI(): :return: never returns ''' # ------- Make a new FlexForm ------- # - SG.SetOptions(border_width=1) + # Set system-wide options that will affect all future forms. Give our form a spiffy look and feel + SG.SetOptions(background_color='#9FB8AD', text_element_background_color='#9FB8AD', element_background_color='#9FB8AD', scrollbar_color=None, input_elements_background_color='#F7F3EC', button_color=('white','#475841')) form = SG.FlexForm('How Do I ??', auto_size_text=True, default_element_size=(30, 2), icon=DEFAULT_ICON) form.AddRow(SG.Text('Ask and your answer will appear here....', size=(40, 1))) form.AddRow(SG.Output(size=(90, 20))) diff --git a/Demo_Recipes.py b/Demo_Recipes.py index 8b8e92936..68bc72a12 100644 --- a/Demo_Recipes.py +++ b/Demo_Recipes.py @@ -4,10 +4,10 @@ # A simple blocking form. Your best starter-form def SourceDestFolders(): - with sg.FlexForm('Demo Source / Destination Folders', auto_size_text=True) as form: + with sg.FlexForm('Demo Source / Destination Folders') as form: form_rows = [[sg.Text('Enter the Source and Destination folders')], - [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source')], - [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), sg.FolderBrowse()], + [sg.Text('Source Folder', size=(15, 1), justification='right'), sg.InputText('Source'), sg.FolderBrowse()], + [sg.Text('Destination Folder', size=(15, 1), justification='right'), sg.InputText('Dest'), sg.FolderBrowse()], [sg.Submit(), sg.Cancel()]] button, (source, dest) = form.LayoutAndRead(form_rows) @@ -16,6 +16,35 @@ def SourceDestFolders(): else: sg.MsgBoxError('Cancelled', 'User Cancelled') + +def MachineLearningGUI(): + sg.SetOptions(text_justification='right') + form = sg.FlexForm('Machine Learning Front End', font=("Helvetica", 12)) # begin with a blank form + + layout = [[sg.Text('Machine Learning Command Line Parameters', font=('Helvetica', 16))], + [sg.Text('Passes', size=(15, 1)), sg.Spin(values=[i for i in range(1, 1000)], initial_value=20, size=(6, 1)), + sg.Text('Steps', size=(18, 1)), sg.Spin(values=[i for i in range(1, 1000)], initial_value=20, size=(6, 1))], + [sg.Text('ooa', size=(15, 1)), sg.In(default_text='6', size=(10, 1)), sg.Text('nn', size=(15, 1)), sg.In(default_text='10', size=(10, 1))], + [sg.Text('q', size=(15, 1)), sg.In(default_text='ff', size=(10, 1)), sg.Text('ngram', size=(15, 1)), sg.In(default_text='5', size=(10, 1))], + [sg.Text('l', size=(15, 1)), sg.In(default_text='0.4', size=(10, 1)), sg.Text('Layers', size=(15, 1)), sg.Drop(values=('BatchNorm', 'other'),auto_size_text=True)], + [sg.Text('_' * 100, size=(65, 1))], + [sg.Text('Flags', font=('Helvetica', 13))], + [sg.Checkbox('Normalize', size=(12, 1), default=True), sg.Checkbox('Verbose', size=(20, 1))], + [sg.Checkbox('Cluster', size=(12, 1)), sg.Checkbox('Flush Output', size=(20, 1), default=True)], + [sg.Checkbox('Write Results', size=(12, 1)), sg.Checkbox('Keep Intermediate Data', size=(20, 1))], + [sg.Text('_' * 100, size=(65, 1))], + [sg.Text('Loss Functions', font=('Helvetica', 13))], + [sg.Radio('Cross-Entropy', 'loss', size=(12, 1)), sg.Radio('Logistic', 'loss', default=True, size=(12, 1))], + [sg.Radio('Hinge', 'loss', size=(12, 1)), sg.Radio('Huber', 'loss', size=(12, 1))], + [sg.Radio('Kullerback', 'loss', size=(12, 1)), sg.Radio('MAE(L1)', 'loss', size=(12, 1))], + [sg.Radio('MSE(L2)', 'loss', size=(12, 1)), sg.Radio('MB(L0)', 'loss', size=(12, 1))], + [sg.Submit(), sg.Cancel()]] + button, values = form.LayoutAndShow(layout) + del(form) + sg.SetOptions(text_justification='left') + + return button, values + # YOUR BEST STARTING POINT # This is a form showing you all of the basic Elements (widgets) # Some have a few of the optional parameters set, but there are more to choose from @@ -23,65 +52,70 @@ def SourceDestFolders(): # Use this especially if you are runningm multi-threaded # Where you free up resources is really important to tkinter def Everything(): + with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: layout = [ - [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25))], [sg.Text('Here is some text.... and a place to enter text')], [sg.InputText()], [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], - [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', - scale=(2, 10))], - [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10), + [sg.Multiline(default_text='This is the default Text should you decide not to type anything',size=(35,3)), + sg.Multiline(default_text='A second multi-line',size=(35,3))], + [sg.InputCombo(('Combobox 1', 'Combobox 2'), size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85)], + [sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3', 'Listbox 4'), size=(30, 3)), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10), sg.Spin(values=('Spin Box 1', '2','3'), initial_value='Spin Box 1')], - [sg.Text('_' * 100, size=(70, 1))], - [sg.Text('Choose Source and Destination Folders', size=(35, 1))], - [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], - [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), - sg.FolderBrowse()], - [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] + [sg.Text('_' * 80)], + [sg.Text('Choose A Folder', size=(35, 1))], + [sg.Text('Your Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Default Folder'), sg.FolderBrowse()], + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('black', '#EDE5B7'))] ] button, values = form.LayoutAndRead(layout) - sg.MsgBox('Title', 'Typical message box', 'The results of the form are a lot of data! Get ready... ', 'The button clicked was "{}"'.format(button), 'The values are', values) + sg.MsgBox('Title', 'The results of the form.', 'The button clicked was "{}"'.format(button), 'The values are', values) # Should you decide not to use a context manager, then try this form as your starting point # Be aware that tkinter, which this is based on, is picky about who frees up resources, especially if # you are running multithreaded def Everything_NoContextManager(): form = sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) - layout = [[sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [sg.Text('Here is some text.... and a place to enter text')], - [sg.InputText()], - [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], - [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], - [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', scale=(2, 10))], - [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [sg.Text('_' * 100, size=(70, 1))], - [sg.Text('Choose Source and Destination Folders', size=(35, 1), text_color='red')], - [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], - [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), sg.FolderBrowse()], - [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))]] + layout = [ + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25))], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText('This is my text')], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text should you decide not to type anything', size=(35, 3)), + sg.Multiline(default_text='A second multi-line', size=(35, 3))], + [sg.InputCombo(('Combobox 1', 'Combobox 2'), size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85)], + [sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(30, 3)), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10), + sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 1')], + [sg.Text('_' * 80)], + [sg.Text('Choose A Folder', size=(35, 1))], + [sg.Text('Your Folder', size=(15, 1), auto_size_text=False, justification='right'), + sg.InputText('Default Folder'), sg.FolderBrowse()], + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', '#7E6C92'))] + ] button, values = form.LayoutAndRead(layout) del(form) - sg.MsgBox('Title', 'Typical message box', 'Here are the restults! There is one entry per input field ', 'The button clicked was "{}"'.format(button), 'The values are', values) + sg.MsgBox('Title', 'The results of the form.', 'The button clicked was "{}"'.format(button), 'The values are', values) + def ProgressMeter(): - for i in range(1,10000): - if not sg.EasyProgressMeter('My Meter', i + 1, 10000): break - # SG.Print(i) + for i in range(1,100): + if not sg.EasyProgressMeter('My Meter', i + 1, 100, orientation='v'): break + time.sleep(.01) # Blocking form that doesn't close def ChatBot(): @@ -149,18 +183,40 @@ def DebugTest(): for i in range (1,300): sg.Print(i, randint(1, 1000), end='', sep='-') - +#=---------------------------------- main ------------------------------ def main(): - # SG.SetOptions(border_width=1, font=("Helvetica", 10), button_color=('white', SG.BLUES[0]), slider_border_width=1) - NonBlockingPeriodicUpdateForm_ContextManager() - NonBlockingPeriodicUpdateForm() + + # sg.MsgBox('Changing look and feel.', 'Done by calling SetOptions') + SourceDestFolders() + + sg.SetOptions(background_color='#9FB8AD', text_element_background_color='#9FB8AD', element_background_color='#9FB8AD', scrollbar_color=None, input_elements_background_color='#F7F3EC', button_color=('white','#475841'), border_width=0, slider_border_width=0, progress_meter_border_depth=0) + + MachineLearningGUI() Everything_NoContextManager() + + # sg.SetOptions(background_color='#B89FB6', text_element_background_color='#B89FB6', element_background_color='#B89FB6', button_color=('white','#7E6C92'), text_color='#3F403F',border_width=0, slider_border_width=0, progress_meter_border_depth=0) + + sg.SetOptions(background_color='#A5CADD', input_elements_background_color='#E0F5FF', text_element_background_color='#A5CADD', element_background_color='#A5CADD', button_color=('white','#303952'), text_color='#822E45',border_width=0, progress_meter_color=('#3D8255','white'), slider_border_width=0, progress_meter_border_depth=0) + + Everything_NoContextManager() + Everything() - ChatBot() + ProgressMeter() - SourceDestFolders() + + # Set system-wide options that will affect all future forms + + + NonBlockingPeriodicUpdateForm_ContextManager() + + + NonBlockingPeriodicUpdateForm() + + ChatBot() + DebugTest() + sg.MsgBox('Done with all recipes') if __name__ == '__main__': diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 006a04dcd..e18b401ee 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -15,6 +15,7 @@ DEFAULT_MARGINS = (10,5) # Margins for each LEFT/RIGHT margin is first term DEFAULT_ELEMENT_PADDING = (5,3) # Padding between elements (row, col) in pixels DEFAULT_AUTOSIZE_TEXT = False +DEFAULT_AUTOSIZE_BUTTONS = True DEFAULT_FONT = ("Helvetica", 10) DEFAULT_TEXT_JUSTIFICATION = 'left' DEFAULT_BORDER_WIDTH = 1 @@ -62,7 +63,7 @@ RELIEF_SOLID = 'solid' DEFAULT_PROGRESS_BAR_COLOR = (GREENS[0], '#D0D0D0') # a nice green progress bar -DEFAULT_PROGRESS_BAR_SIZE = (35,20) # Size of Progress Bar (characters for length, pixels for width) +DEFAULT_PROGRESS_BAR_SIZE = (25,20) # Size of Progress Bar (characters for length, pixels for width) DEFAULT_PROGRESS_BAR_BORDER_WIDTH=1 DEFAULT_PROGRESS_BAR_RELIEF = RELIEF_GROOVE PROGRESS_BAR_STYLES = ('default','winnative', 'clam', 'alt', 'classic', 'vista', 'xpnative') @@ -382,7 +383,7 @@ def __del__(self): # ---------------------------------------------------------------------- # class TKProgressBar(): - def __init__(self, root, max, length=400, width=DEFAULT_PROGRESS_BAR_SIZE[1], style=DEFAULT_PROGRESS_BAR_STYLE, relief=DEFAULT_PROGRESS_BAR_RELIEF, border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH, orientation='horizontal', BarColor=DEFAULT_PROGRESS_BAR_COLOR): + def __init__(self, root, max, length=400, width=DEFAULT_PROGRESS_BAR_SIZE[1], style=DEFAULT_PROGRESS_BAR_STYLE, relief=DEFAULT_PROGRESS_BAR_RELIEF, border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH, orientation='horizontal', BarColor=(None,None)): self.Length = length self.Width = width self.Max = max @@ -423,8 +424,10 @@ def __del__(self): pass # ---------------------------------------------------------------------- # -# Output # -# New Type of Widget that's a Text Widget in disguise # +# TKOutput # +# New Type of TK Widget that's a Text Widget in disguise # +# Note that it's inherited from the TKFrame class so that the # +# Scroll bar will span the length of the frame # ---------------------------------------------------------------------- # class TKOutput(tk.Frame): def __init__(self, parent, width, height, bd, background_color=None): @@ -462,6 +465,10 @@ def __del__(self): sys.stdout = self.previous_stdout sys.stderr = self.previous_stderr +# ---------------------------------------------------------------------- # +# Output # +# Routes stdout, stderr to a scrolled window # +# ---------------------------------------------------------------------- # class Output(Element): def __init__(self, scale=(None, None), size=(None, None), background_color=None): self.TKOut = None @@ -479,7 +486,8 @@ def __del__(self): # Button Class # # ---------------------------------------------------------------------- # class Button(Element): - def __init__(self, button_type=CLOSES_WIN, target=(None, None), button_text='', file_types=(("ALL Files", "*.*"),), image_filename=None, image_size=(None,None), image_subsample=None, border_width=None, scale=(None, None), size=(None, None), auto_size_text=None, button_color=None, font=None): + def __init__(self, button_type=CLOSES_WIN, target=(None, None), button_text='', file_types=(("ALL Files", "*.*"),), image_filename=None, image_size=(None,None), image_subsample=None, border_width=None, scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): + self.AutoSizeButton = auto_size_button self.BType = button_type self.FileTypes = file_types self.TKButton = None @@ -491,7 +499,7 @@ def __init__(self, button_type=CLOSES_WIN, target=(None, None), button_text='', self.ImageSubsample = image_subsample self.UserData = None self.BorderWidth = border_width if border_width is not None else DEFAULT_BORDER_WIDTH - super().__init__(ELEM_TYPE_BUTTON, scale, size, auto_size_text, font=font) + super().__init__(ELEM_TYPE_BUTTON, scale, size, font=font) return # ------- Button Callback ------- # @@ -667,8 +675,9 @@ class FlexForm: ''' Display a user defined for and return the filled in data ''' - def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=DEFAULT_AUTOSIZE_TEXT, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON): - self.AutoSizeText = auto_size_text + def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=None, auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON): + self.AutoSizeText = auto_size_text if auto_size_text is not None else DEFAULT_AUTOSIZE_TEXT + self.AutoSizeButtons = auto_size_buttons if auto_size_buttons is not None else DEFAULT_AUTOSIZE_BUTTONS self.Title = title self.Rows = [] # a list of ELEMENTS for this row self.DefaultElementSize = default_element_size @@ -901,50 +910,50 @@ def T(display_text, scale=(None, None), size=(None, None), auto_size_text=None, return Text(display_text, scale=scale, size=size, auto_size_text=auto_size_text, font=font, text_color=text_color, justification=justification) # ------------------------- FOLDER BROWSE Element lazy function ------------------------- # -def FolderBrowse(target=(ThisRow, -1), button_text='Browse', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None): - return Button(BROWSE_FOLDER, target=target, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color) +def FolderBrowse(target=(ThisRow, -1), button_text='Browse', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): + return Button(BROWSE_FOLDER, target=target, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) # ------------------------- FILE BROWSE Element lazy function ------------------------- # -def FileBrowse(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Browse', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None): - return Button(BROWSE_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color) +def FileBrowse(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Browse', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): + return Button(BROWSE_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) # ------------------------- SUBMIT BUTTON Element lazy function ------------------------- # -def Submit(button_text='Submit', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None): - return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color) +def Submit(button_text='Submit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): + return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) # ------------------------- OK BUTTON Element lazy function ------------------------- # -def OK(button_text='OK', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None): - return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color) +def OK(button_text='OK', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): + return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) # ------------------------- YES BUTTON Element lazy function ------------------------- # -def Ok(button_text='Ok', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None): - return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color) +def Ok(button_text='Ok', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): + return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) # ------------------------- CANCEL BUTTON Element lazy function ------------------------- # -def Cancel(button_text='Cancel', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None, font=None): - return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color, font=font) +def Cancel(button_text='Cancel', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): + return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) # ------------------------- QUIT BUTTON Element lazy function ------------------------- # -def Quit(button_text='Quit', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None, font=None): - return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color, font=font) +def Quit(button_text='Quit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): + return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) # ------------------------- YES BUTTON Element lazy function ------------------------- # -def Yes(button_text='Yes', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None): - return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color) +def Yes(button_text='Yes', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): + return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) # ------------------------- NO BUTTON Element lazy function ------------------------- # -def No(button_text='No', scale=(None, None), size=(None, None), auto_size_text=None, button_color=None): - return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color) +def No(button_text='No', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): + return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) # ------------------------- GENERIC BUTTON Element lazy function ------------------------- # # this is the only button that REQUIRES button text field -def SimpleButton(button_text, image_filename=None, image_size=(None, None), image_subsample=None, border_width=None, scale=(None, None), size=(None, None), auto_size_text=None, button_color=None, font=None): - return Button(CLOSES_WIN, image_filename=image_filename, image_size=image_size,image_subsample=image_subsample, button_text=button_text,border_width=border_width, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color, font=font) +def SimpleButton(button_text, image_filename=None, image_size=(None, None), image_subsample=None, border_width=None, scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): + return Button(CLOSES_WIN, image_filename=image_filename, image_size=image_size,image_subsample=image_subsample, button_text=button_text,border_width=border_width, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) # ------------------------- GENERIC BUTTON Element lazy function ------------------------- # # this is the only button that REQUIRES button text field -def ReadFormButton(button_text, image_filename=None, image_size=(None, None),image_subsample=None,border_width=None,scale=(None, None), size=(None, None), auto_size_text=None, button_color=None, font=None): - return Button(READ_FORM, image_filename=image_filename, image_size=image_size,image_subsample=image_subsample,border_width=border_width, button_text=button_text, scale=scale, size=size, auto_size_text=auto_size_text, button_color=button_color, font=font) +def ReadFormButton(button_text, image_filename=None, image_size=(None, None),image_subsample=None,border_width=None,scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): + return Button(READ_FORM, image_filename=image_filename, image_size=image_size,image_subsample=image_subsample,border_width=border_width, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) #------------------------------------------------------------------------------------------------------# # ------- FUNCTION InitializeResults. Sets up form results matrix ------- # @@ -1164,7 +1173,10 @@ def CharWidthInPixels(): element.Location = (row_num, col_num) btext = element.ButtonText btype = element.BType - if auto_size_text is False: width=element_size[0] + if element.AutoSizeButton is not None: + auto_size = element.AutoSizeButton + else: auto_size = MyFlexForm.AutoSizeButtons + if auto_size is False: width=element_size[0] else: width = 0 height=element_size[1] lines = btext.split('\n') @@ -1334,7 +1346,7 @@ def CharWidthInPixels(): elif element_type == ELEM_TYPE_OUTPUT: width, height = element_size element.TKOut = TKOutput(tk_row_frame, width=width, height=height, bd=border_depth, background_color=element.BackgroundColor) - element.TKOut.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) + element.TKOut.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1], fill=tk.X) # ------------------------- IMAGE Box element ------------------------- # elif element_type == ELEM_TYPE_IMAGE: photo = tk.PhotoImage(file=element.Filename) @@ -1687,7 +1699,7 @@ def ConvertArgsToSingleString(*args): # ============================== ProgressMeter =====# # ===================================================# -def ProgressMeter(title, max_value, *args, orientation=None, bar_color=DEFAULT_PROGRESS_BAR_COLOR, button_color=None, size=DEFAULT_PROGRESS_BAR_SIZE, scale=(None, None), border_width=None): +def ProgressMeter(title, max_value, *args, orientation=None, bar_color=(None,None), button_color=None, size=DEFAULT_PROGRESS_BAR_SIZE, scale=(None, None), border_width=None): ''' Create and show a form on tbe caller's behalf. :param title: @@ -1801,7 +1813,7 @@ def ComputeProgressStats(self): # ============================== EasyProgressMeter =====# -def EasyProgressMeter(title, current_value, max_value, *args, orientation=None, bar_color=DEFAULT_PROGRESS_BAR_COLOR, button_color=None, size=DEFAULT_PROGRESS_BAR_SIZE, scale=(None, None), border_width=None): +def EasyProgressMeter(title, current_value, max_value, *args, orientation=None, bar_color=(None,None), button_color=None, size=DEFAULT_PROGRESS_BAR_SIZE, scale=(None, None), border_width=None): ''' A ONE-LINE progress meter. Add to your code where ever you need a meter. No need for a second function call before your loop. You've got enough code to write! @@ -2063,7 +2075,7 @@ def SetGlobalIcon(icon): # Sets the icon to be used by default # # ===================================================# def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), margins=(None,None), - element_padding=(None,None),auto_size_text=None, font=None, border_width=None, + element_padding=(None,None),auto_size_text=None, auto_size_buttons=None, font=None, border_width=None, slider_border_width=None, slider_relief=None, slider_orientation=None, autoclose_time=None, message_box_line_width=None, progress_meter_border_depth=None, progress_meter_style=None, @@ -2076,6 +2088,7 @@ def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), ma global DEFAULT_MARGINS # Margins for each LEFT/RIGHT margin is first term global DEFAULT_ELEMENT_PADDING # Padding between elements (row, col) in pixels global DEFAULT_AUTOSIZE_TEXT + global DEFAULT_AUTOSIZE_BUTTONS global DEFAULT_FONT global DEFAULT_BORDER_WIDTH global DEFAULT_AUTOCLOSE_TIME @@ -2119,9 +2132,12 @@ def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), ma if element_padding != (None,None): DEFAULT_ELEMENT_PADDING = element_padding - if auto_size_text: + if auto_size_text != None: DEFAULT_AUTOSIZE_TEXT = auto_size_text + if auto_size_buttons != None: + DEFAULT_AUTOSIZE_BUTTONS = auto_size_buttons + if font !=None: DEFAULT_FONT = font @@ -2201,4 +2217,20 @@ def ObjToString(obj, extra=' '): (extra + (str(item) + ' = ' + (ObjToString(obj.__dict__[item], extra + ' ') if hasattr(obj.__dict__[item], '__dict__') else str( obj.__dict__[item]))) - for item in sorted(obj.__dict__))) \ No newline at end of file + for item in sorted(obj.__dict__))) + + +def main(): + with FlexForm('Demo form..', auto_size_text=True) as form: + form_rows = [[Text('You are running the PySimpleGUI.py file itself')], + [Text('You should be importing it rather than running it\n')], + [Text('Here is your sample input form....')], + [Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), InputText('Source'),FolderBrowse()], + [Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), InputText('Dest'), FolderBrowse()], + [Submit(), Cancel()]] + + button, (source, dest) = form.LayoutAndRead(form_rows) + +if __name__ == '__main__': + main() + exit(69) From 2c0afe8fb871a4c1ba010190b1f0ef9bf1f24f23 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 27 Jul 2018 15:50:14 -0400 Subject: [PATCH 074/209] Small tweaks for 2.6 --- Demo_Recipes.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Demo_Recipes.py b/Demo_Recipes.py index 68bc72a12..9653247f7 100644 --- a/Demo_Recipes.py +++ b/Demo_Recipes.py @@ -28,12 +28,12 @@ def MachineLearningGUI(): [sg.Text('q', size=(15, 1)), sg.In(default_text='ff', size=(10, 1)), sg.Text('ngram', size=(15, 1)), sg.In(default_text='5', size=(10, 1))], [sg.Text('l', size=(15, 1)), sg.In(default_text='0.4', size=(10, 1)), sg.Text('Layers', size=(15, 1)), sg.Drop(values=('BatchNorm', 'other'),auto_size_text=True)], [sg.Text('_' * 100, size=(65, 1))], - [sg.Text('Flags', font=('Helvetica', 13))], + [sg.Text('Flags', font=('Helvetica', 15), justification='left')], [sg.Checkbox('Normalize', size=(12, 1), default=True), sg.Checkbox('Verbose', size=(20, 1))], [sg.Checkbox('Cluster', size=(12, 1)), sg.Checkbox('Flush Output', size=(20, 1), default=True)], [sg.Checkbox('Write Results', size=(12, 1)), sg.Checkbox('Keep Intermediate Data', size=(20, 1))], [sg.Text('_' * 100, size=(65, 1))], - [sg.Text('Loss Functions', font=('Helvetica', 13))], + [sg.Text('Loss Functions', font=('Helvetica', 15), justification='left')], [sg.Radio('Cross-Entropy', 'loss', size=(12, 1)), sg.Radio('Logistic', 'loss', default=True, size=(12, 1))], [sg.Radio('Hinge', 'loss', size=(12, 1)), sg.Radio('Huber', 'loss', size=(12, 1))], [sg.Radio('Kullerback', 'loss', size=(12, 1)), sg.Radio('MAE(L1)', 'loss', size=(12, 1))], @@ -192,14 +192,13 @@ def main(): sg.SetOptions(background_color='#9FB8AD', text_element_background_color='#9FB8AD', element_background_color='#9FB8AD', scrollbar_color=None, input_elements_background_color='#F7F3EC', button_color=('white','#475841'), border_width=0, slider_border_width=0, progress_meter_border_depth=0) MachineLearningGUI() + Everything_NoContextManager() # sg.SetOptions(background_color='#B89FB6', text_element_background_color='#B89FB6', element_background_color='#B89FB6', button_color=('white','#7E6C92'), text_color='#3F403F',border_width=0, slider_border_width=0, progress_meter_border_depth=0) sg.SetOptions(background_color='#A5CADD', input_elements_background_color='#E0F5FF', text_element_background_color='#A5CADD', element_background_color='#A5CADD', button_color=('white','#303952'), text_color='#822E45',border_width=0, progress_meter_color=('#3D8255','white'), slider_border_width=0, progress_meter_border_depth=0) - Everything_NoContextManager() - Everything() ProgressMeter() From 05caecc60009947319d2140ae2299fa70fe4c16c Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 27 Jul 2018 15:52:59 -0400 Subject: [PATCH 075/209] RELEASE 2.6 --- readme.md | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/readme.md b/readme.md index 787fe6850..e7f760405 100644 --- a/readme.md +++ b/readme.md @@ -3,7 +3,7 @@ [![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 # PySimpleGUI - (Ver 2.5) + (Ver 2.6) Super-simple GUI to grasp... Powerfully customizable. @@ -22,7 +22,7 @@ Looking to take your Python code from the world of command lines and into the co Perhaps you're looking for a way to interact with your Raspberry Pi in a more friendly way. The is the same form as above, except shown on a Pi. -![snap0153](https://user-images.githubusercontent.com/13696193/43261051-5838b356-90a9-11e8-96cc-e8a4860d0464.jpg) +![raspberry pi](https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg) In addition to a primary GUI, you can add a Progress Meter to your code with ONE LINE of code. Slide this into any of your `for` loops and get a nice meter like this: @@ -494,7 +494,8 @@ This is the definition of the FlexForm object: def FlexForm(title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), - auto_size_text=DEFAULT_AUTOSIZE_TEXT, + auto_size_text=None, + auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None,Font=None, @@ -508,7 +509,8 @@ This is the definition of the FlexForm object: Parameter Descriptions. You will find these same parameters specified for each `Element` and some of them in `Row` specifications. The `Element` specified value will take precedence over the `Row` and `Form` values. default_element_size - Size of elements in form in characters (width, height) - auto_size_text - Bool. True is elements should size themselves according to contents + auto_size_text - Bool. True if elements should size themselves according to contents + auto_size_buttons - Bool. True if button elements should size themselves according to their text label scale - Set size of element to be a multiple of the Element size location - Location to place window in pixels button_color - Default color for buttons (foreground, background). Can be text or hex @@ -868,7 +870,7 @@ While it's possible to build forms using the Button Element directly, you should SimpleButton(text, scale=(None, None), size=(None, None), - auto_size_text=None, + auto_size_button=None, button_color=None, font=None) @@ -906,13 +908,13 @@ The code for the entire form could be: [SG.FolderBrowse(Target=(-1,0)), SG.OK()]] **Custom Buttons** -If you want to define your own button, you will generally do this with the Button Element `SimpleButton`. +Not all buttons are created equal. A button that closes a form is different that a button that returns from the form without closing it. If you want to define your own button, you will generally do this with the Button Element `SimpleButton`, which closes the form when clicked. layout = [[SG.SimpleButton('My Button')]] ![singlebutton](https://user-images.githubusercontent.com/13696193/42718281-9453deca-86d5-11e8-83c7-4b6d33720858.jpg) -All buttons can have their text changed by changing the `button_text` variable. +All buttons can have their text changed by changing the `button_text` variable in the button call. It is this text that is returned when a form is read. This text will be what tells you which button is called so make it unique. Most of the convenience buttons (Submit, Cancel, Yes, etc) are all SimpleButtons. The two that are not are `FileBrowse` and `FolderBrowse`. They clearly do not close the form. Instead they bring up a file or folder browser dialog box. **Button Images** Now this is an exciting feature not found in many simplified packages.... images on buttons! You can make a pretty spiffy user interface with the help of a few button images. @@ -932,6 +934,7 @@ Three parameters are used for button images. image_subsample - Amount to divide the size by. 2 means your image will be 1/2 the size. 3 means 1/3 Here's an example form made with button images. + ![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) You'll find the source code in the file Demo Media Player. Here is what the button calls look like to create media player form @@ -1080,6 +1083,7 @@ Let's have some fun customizing! Make PySimpleGUI look the way you want it to l margins=(None,None), element_padding=(None,None) auto_size_text=None + auto_size_buttons=None font=None border_width=None slider_border_width=None @@ -1108,6 +1112,7 @@ Explanation of parameters margins - tkinter margins around outsize element_padding - tkinter padding around each element auto_size_text - autosize the elements to fit their text + auto_size_buttons - autosize the buttons to fit their text font - font used for elements border_width - amount of bezel or border around sunken or raised elements slider_border_width - changes the way sliders look @@ -1307,6 +1312,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. | 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi | 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. +| 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ ### Release Notes 2.3 - Sliders, Listbox's and Image elements (oh my!) @@ -1322,6 +1328,8 @@ Listboxes are still without scrollwheels. The mouse can drag to see more items. ### Upcoming Make suggestions people! Future release features +Auto Sized Buttons - Rather than using the default setting for TEXT fields, broke out button sizing into it's own setting. Makes much more sense. Reduces the amount of code. + Columns. How multiple columns would be specified in the SDK interface are still being designed. @@ -1338,12 +1346,30 @@ While the internals to PySimpleGUI are a tad sketchy, the public interfaces into Please log bugs and suggestions in the GitHub! It will only make the code stronger and better in the end, a good thing for us all, right? +## Design + +A moment about the design-spirit of `PySimpleGUI`. From the beginning, this package was meant to take advantage of Python's capabilities with the goal of programming ease. + +**Single File** +While not the best programming practice, the implementation resulted in a single file solution. Only one file is needed, PySimpleGUI.py. You can post this file, email it, and easily import it using one statement. + +**Functions as objects** +In Python, functions behave just like classes. When you're placing a Text Element into your form, you may be sometimes calling a function and other times declaring an object. If you use the word Text, then you're getting an object. If you're using `Txt`, then you're calling a function that returns a `Text` object. + +**Lists** +It seemed quite natural to use Python's powerful list constructs when possible. + + + + + + ## Authors MikeTheWatchGuy ## License -GNU Lesser General Public License (LGPL 3) +GNU Lesser General Public License (LGPL 3) + ## Acknowledgments From d1b14520797349f590d1a60f99383883ee057774 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 27 Jul 2018 15:58:59 -0400 Subject: [PATCH 076/209] Removed autosize text setting Required for 2.6. --- Demo_Tabbed_Form.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Demo_Tabbed_Form.py b/Demo_Tabbed_Form.py index e6bcede0c..4305a003d 100644 --- a/Demo_Tabbed_Form.py +++ b/Demo_Tabbed_Form.py @@ -76,7 +76,7 @@ def eBaySuperSearcherGUI(): layout_tab_2.append([sg.Text('Typical US Search String')]) layout_tab_2.append([sg.InputText(size=(100,1), default_text='gruen -sara -quarz -quartz -embassy -bob -robert -elephants -adidas -LED ')]) layout_tab_2.append([sg.Text('_' * 100, size=(75, 1))]) - layout_tab_2.append([sg.Submit(button_color=('red', 'yellow'),auto_size_text=True), sg.Cancel(button_color=('white', 'blue'), auto_size_text=True)]) + layout_tab_2.append([sg.Submit(button_color=('red', 'yellow')), sg.Cancel(button_color=('white', 'blue'))]) results = sg.ShowTabbedForm('eBay Super Searcher', (form,layout_tab_1,'Where To Save'), (form2, layout_tab_2, 'Categories & Search String')) From b51cf2b355d20eb6a629ba136fffb99e8adc1f01 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 28 Jul 2018 06:45:39 -0400 Subject: [PATCH 077/209] Fix for Pi Was using Python feature that caused errors on Pi running 3.4. --- Demo_NonBlocking_Form.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Demo_NonBlocking_Form.py b/Demo_NonBlocking_Form.py index 8e43d6dd8..29c5b9d8b 100644 --- a/Demo_NonBlocking_Form.py +++ b/Demo_NonBlocking_Form.py @@ -3,6 +3,7 @@ def main(): StatusOutputExample() + StatusOutputExample_context_manager() # form that doen't block def StatusOutputExample_context_manager(): @@ -15,7 +16,7 @@ def StatusOutputExample_context_manager(): form.LayoutAndRead(form_rows, non_blocking=True) for i in range(1, 1000): - output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i/100), 60), i%100)) + output_element.Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100)) button, values = form.ReadNonBlocking() if values is None or button == 'Quit': break @@ -44,7 +45,7 @@ def StatusOutputExample(): # for i in range(1, 1000): - output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) + output_element.Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100)) button, values = form.ReadNonBlocking() if values is None or button == 'Quit': break From e9ac588ab8edb7ae0019c5cd033797e7c66f6028 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 28 Jul 2018 14:41:56 -0400 Subject: [PATCH 078/209] Element Docstrings Added Docstrings to the elements... it's a start --- PySimpleGUI.py | 135 +++++++++++++++++++++++++++++++++++++++++++++++-- readme.md | 29 +++++++++-- 2 files changed, 156 insertions(+), 8 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index e18b401ee..c89c86406 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -193,8 +193,16 @@ def __del__(self): # Input Class # # ---------------------------------------------------------------------- # class InputText(Element): - def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None): + ''' + Input a line of text Element + :param default_text: Default value to display + :param scale: Adds multiplier to size (w,h) + :param size: Size of field in characters + :param auto_size_text: True if should shrink field to fit the default text + :param password_char: If non-blank, will display this character for every character typed + :param background_color: Color for Element. Text or RGB Hex + ''' self.DefaultText = default_text self.PasswordCharacter = password_char bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR @@ -220,6 +228,14 @@ def __del__(self): class InputCombo(Element): def __init__(self, values, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None): + ''' + Input Combo Box Element (also called Dropdown box) + :param values: + :param scale: Adds multiplier to size (w,h) + :param size: Size of field in characters + :param auto_size_text: True if should shrink field to fit the default text + :param background_color: Color for Element. Text or RGB Hex + ''' self.Values = values self.TKComboBox = None bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR @@ -240,6 +256,15 @@ def __del__(self): class Listbox(Element): def __init__(self, values, select_mode=None, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None): + ''' + Listbox Element + :param values: + :param select_mode: + :param font: + :param scale: Adds multiplier to size (w,h) + :param size: Size of field in characters + :param auto_size_text: True if should shrink field to fit the default text + :param background_color: Color for Element. Text or RGB Hex ''' self.Values = values self.TKListBox = None if select_mode == LISTBOX_SELECT_MODE_BROWSE: @@ -270,6 +295,17 @@ def __del__(self): # ---------------------------------------------------------------------- # class Radio(Element): def __init__(self, text, group_id, default=False, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, font=None): + ''' + Radio Button Element + :param text: + :param group_id: + :param default: + :param scale: Adds multiplier to size (w,h) + :param size: Size of field in characters + :param auto_size_text: True if should shrink field to fit the default text + :param background_color: Color for Element. Text or RGB Hex + :param font: + ''' self.InitialState = default self.Text = text self.TKRadio = None @@ -290,6 +326,16 @@ def __del__(self): # ---------------------------------------------------------------------- # class Checkbox(Element): def __init__(self, text, default=False, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None): + ''' + Check Box Element + :param text: + :param default: + :param scale: Adds multiplier to size (w,h) + :param size: Size of field in characters + :param auto_size_text: True if should shrink field to fit the default text + :param background_color: Color for Element. Text or RGB Hex + :param font: + ''' self.Text = text self.InitialState = default self.Value = None @@ -313,6 +359,16 @@ class Spin(Element): # Values = None # TKSpinBox = None def __init__(self, values, initial_value=None, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None): + ''' + Spin Box Element + :param values: + :param initial_value: + :param scale: Adds multiplier to size (w,h) + :param size: Size of field in characters + :param auto_size_text: True if should shrink field to fit the default text + :param background_color: Color for Element. Text or RGB Hex + :param font: + ''' self.Values = values self.DefaultValue = initial_value self.TKSpinBox = None @@ -332,6 +388,15 @@ def __del__(self): # ---------------------------------------------------------------------- # class Multiline(Element): def __init__(self, default_text='', enter_submits = False, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None): + ''' + Input Multi-line Element + :param default_text: + :param enter_submits: + :param scale: Adds multiplier to size (w,h) + :param size: Size of field in characters + :param auto_size_text: True if should shrink field to fit the default text + :param background_color: Color for Element. Text or RGB Hex + ''' self.DefaultText = default_text self.EnterSubmits = enter_submits bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR @@ -356,6 +421,17 @@ def __del__(self): # ---------------------------------------------------------------------- # class Text(Element): def __init__(self, text, scale=(None, None), size=(None, None), auto_size_text=None, font=None, text_color=None, background_color=None,justification=None): + ''' + Text Element - Displays text in your form. Can be updated in non-blocking forms + :param text: The text to display + :param scale: Scaling factor (w,h) (2,2)= 2 * Size + :param size: Size of Element in Characters + :param auto_size_text: True if the field should shrink to fit the text + :param font: Font name and size ("name", size) + :param text_color: Text Color name or RGB hex value '#RRGGBB' + :param background_color: Background color for text (name or RGB Hex) + :param justification: 'left', 'right', 'center' + ''' self.DisplayText = text self.TextColor = text_color if text_color else DEFAULT_TEXT_COLOR self.Justification = justification if justification else DEFAULT_TEXT_JUSTIFICATION @@ -471,6 +547,12 @@ def __del__(self): # ---------------------------------------------------------------------- # class Output(Element): def __init__(self, scale=(None, None), size=(None, None), background_color=None): + ''' + Output Element - reroutes stdout, stderr to this window + :param scale: Adds multiplier to size (w,h) + :param size: Size of field in characters + :param background_color: Color for Element. Text or RGB Hex + ''' self.TKOut = None bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR super().__init__(ELEM_TYPE_OUTPUT, scale=scale, size=size, background_color=bg) @@ -487,6 +569,22 @@ def __del__(self): # ---------------------------------------------------------------------- # class Button(Element): def __init__(self, button_type=CLOSES_WIN, target=(None, None), button_text='', file_types=(("ALL Files", "*.*"),), image_filename=None, image_size=(None,None), image_subsample=None, border_width=None, scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): + ''' + Button Element - Specifies all types of buttons + :param button_type: + :param target: + :param button_text: + :param file_types: + :param image_filename: + :param image_size: + :param image_subsample: + :param border_width: + :param scale: Adds multiplier to size (w,h) + :param size: Size of field in characters + :param auto_size_button: + :param button_color: + :param font: + ''' self.AutoSizeButton = auto_size_button self.BType = button_type self.FileTypes = file_types @@ -575,6 +673,19 @@ def __del__(self): # ---------------------------------------------------------------------- # class ProgressBar(Element): def __init__(self, max_value, orientation=None, target=(None, None), scale=(None, None), size=(None, None), auto_size_text=None, bar_color=(None, None), style=None, border_width=None, relief=None): + ''' + Progress Bar Element + :param max_value: + :param orientation: + :param target: + :param scale: Adds multiplier to size (w,h) + :param size: Size of field in characters + :param auto_size_text: True if should shrink field to fit the default text + :param bar_color: + :param style: + :param border_width: + :param relief: + ''' self.MaxValue = max_value self.TKProgressBar = None self.Cancelled = False @@ -619,7 +730,13 @@ def __del__(self): # Image # # ---------------------------------------------------------------------- # class Image(Element): - def __init__(self, filename, scale=(None, None), size=(None, None), auto_size_text=None): + def __init__(self, filename, scale=(None, None), size=(None, None)): + ''' + Image Element + :param filename: + :param scale: Adds multiplier to size (w,h) + :param size: Size of field in characters + ''' self.Filename = filename super().__init__(ELEM_TYPE_IMAGE, scale=scale, size=size, auto_size_text=auto_size_text) return @@ -632,6 +749,18 @@ def __del__(self): # ---------------------------------------------------------------------- # class Slider(Element): def __init__(self, range=(None,None), default_value=None, orientation=None, border_width=None, relief=None, scale=(None, None), size=(None, None), font=None, background_color=None): + ''' + Slider Element + :param range: + :param default_value: + :param orientation: + :param border_width: + :param relief: + :param scale: Adds multiplier to size (w,h) + :param size: Size of field in characters + :param background_color: Color for Element. Text or RGB Hex + :param font: + ''' self.TKScale = None self.Range = (1,10) if range == (None, None) else range self.DefaultValue = 5 if default_value is None else default_value @@ -1346,7 +1475,7 @@ def CharWidthInPixels(): elif element_type == ELEM_TYPE_OUTPUT: width, height = element_size element.TKOut = TKOutput(tk_row_frame, width=width, height=height, bd=border_depth, background_color=element.BackgroundColor) - element.TKOut.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1], fill=tk.X) + element.TKOut.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) # ------------------------- IMAGE Box element ------------------------- # elif element_type == ELEM_TYPE_IMAGE: photo = tk.PhotoImage(file=element.Filename) diff --git a/readme.md b/readme.md index e7f760405..8e24dcac9 100644 --- a/readme.md +++ b/readme.md @@ -336,7 +336,7 @@ A word of caution. There are known problems when multiple PySimpleGUI windows a You can change the size of the debug window using the `SetOptions` call with the `debug_win_size` parameter. --- -# Custom Form API Calls +# Custom Form API Calls (Your First Form) This is the FUN part of the programming of this GUI. In order to really get the most out of the API, you should be using an IDE that supports auto complete or will show you the definition of the function. This will make customizing go smoother. @@ -378,6 +378,27 @@ The second design pattern is not context manager based. If you are struggling w You will use these design patterns or code templates for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. This is the most basic / normal of the design patterns. +### Laying out your form +Your form is a 2 dimensional list in Python. The first dimension are rows, the second is a list of Elements for each row. The first thing you want to do is layout your form on paper. + + layout = [ [row 1], + [row 2], + [row 3] ] + +Simple enough... a list of lists. +A row is a list of Elements. For example this could be a row with a couple of elements on it. + + [ Input, Button] + +Turning back to our example. This GUI roughly looks like this: + + layout = [ [Text], + [InputText, FileBrowse] + [Submit, Cancel] ] + + Now let's put it all together into an entire program. + + ### Line by line explanation Going through each line of code in the above form will help explain how to use this design patter. Copy, modify and run it! @@ -396,12 +417,9 @@ Now we're on the second row of the form. On this row there are 2 elements. The The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its value to the caller. (button, (source_filename, )) = form.LayoutAndRead(form_rows) -This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field - +This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field. The result of the form is stored directly into the variable we wish to work with. ---- - ## Return values Return information from FlexForm, SG's primary form builder interface, is in this format: @@ -1398,3 +1416,4 @@ In the hands of a competent programmer, this tool is **amazing**. It's a must- The PySimpleGUI window that the results are shown in is an 'input' field which means you can copy and paste the results right into your code. + From 2629d23ac1f9cc243ed307a514b18f744e5d30d0 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sun, 29 Jul 2018 08:57:28 -0400 Subject: [PATCH 079/209] More/better comments A design recipe for Non-blocking forms --- Demo_NonBlocking_Form.py | 64 ++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/Demo_NonBlocking_Form.py b/Demo_NonBlocking_Form.py index 29c5b9d8b..d388a7a63 100644 --- a/Demo_NonBlocking_Form.py +++ b/Demo_NonBlocking_Form.py @@ -1,31 +1,11 @@ import PySimpleGUI as sg import time -def main(): - StatusOutputExample() - StatusOutputExample_context_manager() - -# form that doen't block -def StatusOutputExample_context_manager(): - with sg.FlexForm('Running Timer', auto_size_text=True) as form: - output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) - form_rows = [[sg.Text('Non-blocking GUI with updates')], - [output_element], - [sg.SimpleButton('Quit')]] - - form.LayoutAndRead(form_rows, non_blocking=True) - for i in range(1, 1000): - output_element.Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100)) - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': - break - time.sleep(.01) - else: - form.CloseNonBlockingForm() # form that doen't block +# good for applications with an loop that polls hardware def StatusOutputExample(): # Make a form, but don't use context manager form = sg.FlexForm('Running Timer', auto_size_text=True) @@ -41,18 +21,50 @@ def StatusOutputExample(): # # Some place later in your code... # You need to perform a ReadNonBlocking on your form every now and then or - # else it won't refresh + # else it won't refresh. # - - for i in range(1, 1000): + # your program's main loop + i=0 + while (True): + # This is the code that reads and updates your window output_element.Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100)) button, values = form.ReadNonBlocking() if values is None or button == 'Quit': break + i += 1 + # Your code begins here time.sleep(.01) - else: - form.CloseNonBlockingForm() + # Broke out of main loop. Close the window. + form.CloseNonBlockingForm() + + + +# This design pattern follows the uses a context manager to better control the resources +# It may not be realistic to use a context manager within an embedded (Pi) environment +# If on a Pi, then consider the above design patterns instead +def StatusOutputExample_context_manager(): + with sg.FlexForm('Running Timer', auto_size_text=True) as form: + output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) + form_rows = [[sg.Text('Non-blocking GUI with updates')], + [output_element], + [sg.SimpleButton('Quit')]] + + form.LayoutAndRead(form_rows, non_blocking=True) + + for i in range(1, 1000): + output_element.Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100)) + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + time.sleep(.01) + else: + form.CloseNonBlockingForm() + +def main(): + StatusOutputExample() + sg.MsgBox('End of non-blocking demonstration') + # StatusOutputExample_context_manager() if __name__ == '__main__': From 418027adfb9100465b4291fc3b2985c41e08fd26 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sun, 29 Jul 2018 09:11:51 -0400 Subject: [PATCH 080/209] Better poll loop --- Demo_NonBlocking_Form.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Demo_NonBlocking_Form.py b/Demo_NonBlocking_Form.py index d388a7a63..42a90be0b 100644 --- a/Demo_NonBlocking_Form.py +++ b/Demo_NonBlocking_Form.py @@ -10,11 +10,11 @@ def StatusOutputExample(): # Make a form, but don't use context manager form = sg.FlexForm('Running Timer', auto_size_text=True) # Create a text element that will be updated with status information on the GUI itself - output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) + output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20), justification='center') # Create the rows form_rows = [[sg.Text('Non-blocking GUI with updates')], [output_element], - [sg.SimpleButton('Quit')]] + [sg.ReadFormButton('LED On'), sg.ReadFormButton('LED Off'), sg.ReadFormButton('Quit')]] # Layout the rows of the form and perform a read. Indicate the form is non-blocking! form.LayoutAndRead(form_rows, non_blocking=True) @@ -29,8 +29,13 @@ def StatusOutputExample(): # This is the code that reads and updates your window output_element.Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100)) button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': + if button == 'Quit' or values is None: break + if button == 'LED On': + print('Turning on the LED') + elif button == 'LED Off': + print('Turning off the LED') + i += 1 # Your code begins here time.sleep(.01) From bbc6a555f97c7e136573e01993e4a09bcf552aec Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 30 Jul 2018 10:12:12 -0400 Subject: [PATCH 081/209] Readme updates Python3 requirement spelled out --- Demo_NonBlocking_Form.py | 2 -- readme.md | 12 +++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Demo_NonBlocking_Form.py b/Demo_NonBlocking_Form.py index 42a90be0b..8ea24f6e9 100644 --- a/Demo_NonBlocking_Form.py +++ b/Demo_NonBlocking_Form.py @@ -2,8 +2,6 @@ import time - - # form that doen't block # good for applications with an loop that polls hardware def StatusOutputExample(): diff --git a/readme.md b/readme.md index 8e24dcac9..683cbb053 100644 --- a/readme.md +++ b/readme.md @@ -7,6 +7,8 @@ Super-simple GUI to grasp... Powerfully customizable. +Note - *Python3* is required to run PySimpleGUI. It takes advantage of some Python3 features that do not translate well into Python2. + Looking to take your Python code from the world of command lines and into the convenience of a GUI? Have a Raspberry Pi with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK? Look no further, you've found your GUI package. import PySimpleGUI as sg @@ -70,9 +72,11 @@ The `PySimpleGUI` package is focused on the ***developer***. How can the desire Redirect Python Output/Errors to scrolling window 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) Single-Line-Of-Coide Proress Bar & Debug Print + Complete control of colors, look and feel + Button images -An example of many widgets used on a single form. A little further down you'll find the TWENTY lines of code required to create this complex form. Try it if you don't believe it. Copy and paste into a temp file and it'll run, presenting you with the screen you see. +An example of many widgets used on a single form. A little further down you'll find the TWENTY lines of code required to create this complex form. Try it if you don't believe it. Start Python, copy and paste the code below into the >>> prompt and hit enter. This will pop up... ![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) @@ -115,11 +119,13 @@ You will see a number of different styles of buttons, data entry fields, etc, in `PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the SDK to visually match what's on the screen. - Be Pythonic... Python's lists in particular worked out really well: + > Be Pythonic + + Be Pythonic... Attempted to use language constructs in a natural way and to exploit some of Python's interesting features. Python's lists and optional parameters make PySimpleGUI work. - Forms are represented as Python lists. - A form is a list of rows - A row is a list of elements -- Return values are a list +- Return values are a list of button presses and input values. ----- From 499433badd837ba294e843a1ab32b287fc801f96 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 30 Jul 2018 15:18:36 -0400 Subject: [PATCH 082/209] Design description --- readme.md | 68 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 20 deletions(-) diff --git a/readme.md b/readme.md index 683cbb053..70ee46b77 100644 --- a/readme.md +++ b/readme.md @@ -384,6 +384,45 @@ The second design pattern is not context manager based. If you are struggling w You will use these design patterns or code templates for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. This is the most basic / normal of the design patterns. +### How GUI Programming in Python Should Look + +GUI programming in Python is a mess. tkinter kinda sucks. Why is Python such a great teaching language and yet no GUI framework exists that lends itself to the basic building blocks of Python, the list? + +The key to custom forms in PySimpleGUI is to view forms as ROWS of Widgets (Elements). Each row is specified as a list of these widgets. Put the rows together and you've got a form. + +Let's look at this one. + + +![snap0131](https://user-images.githubusercontent.com/13696193/43417007-df6d8408-9407-11e8-9986-30f0415f08a5.jpg) + +Let's agree the form has 4 rows. + +The first row only has **text** that reads `Rename files or folders` + +The second row has 3 elements in it. First the **text** `Source for Folders`, then an **input** field, then a **browse** button. + +Now let's look at how those 2 rows and the other two row from Python code: + + layout = [[sg.Text('Rename files or folders')], + [sg.Text('Source for Folders', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], + [sg.Text('Source for Files ', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], + [sg.Submit(), sg.Cancel()]] + +See how the source code mirrors the layout? You simply make lists for each row, then submit that table to PySimpleGUI to show and get values from. + +And what about those return values? Most people simply want to show a form, get the input values and do something with them. So why break up the code into button callbacks, etc, when I simply want my form's input values to be given to me. + +The same "row" concept applies to return values. The form is scanned from top to bottom, left to right. Each field that's an input field will occupy a spot in the return values. + +In our example form, there are 2 fields, so the return values from this form will be a list with 2 values in it. + + button, (folder_path, file_path) = form.LayoutAndRead(layout) + +In the statement that shows and reads the form, the two input fields are directly assigned to the caller's variables `folder_path` and `file_path`, ready to use. No parsing no callbacks. + +Isn't this what almost every Python programmer looking for a GUI wants?? Something easy to work with to get the values and move on to the rest of the program, where the real action is taking place. Why write pages of tkinter code when the same layout can be achieved with PySimpleGUI in 3 or 4 lines of code. 4 lines or 40? I chose 4. + + ### Laying out your form Your form is a 2 dimensional list in Python. The first dimension are rows, the second is a list of Elements for each row. The first thing you want to do is layout your form on paper. @@ -422,7 +461,7 @@ Now we're on the second row of the form. On this row there are 2 elements. The The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its value to the caller. - (button, (source_filename, )) = form.LayoutAndRead(form_rows) + button, (source_filename, ) = form.LayoutAndRead(form_rows) This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field. The result of the form is stored directly into the variable we wish to work with. @@ -557,9 +596,6 @@ In addition to `size` there is a `scale` option. `scale` will take the Element' There are a couple of widgets where one of the size values is in pixels rather than characters. This is true for Progress Meters and Sliders. The second parameter is the 'height' in pixels. - - - #### FlexForm - form-level variables overview A summary of the variables that can be changed when a FlexForm is created @@ -1266,20 +1302,19 @@ Use the example programs as a starting basis for your GUI. Copy, paste, modify ## Fun Stuff Here are some things to try if you're bored or want to further customize -**Random colors** +**Colors - Random and predefined** To set a button or text to a random color, use the string `'random'` as the color value. You can also call `PySimpleGUI.GetRandomColor`. -To get a random color pair call `PySimpleGUI.GetRandomColorPair`. This returns a tuple containing a random color and -that color's compliment. -sprint +To get a random color pair call `PySimpleGUI.GetRandomColorPair`. This returns a tuple containing a random color and that color's compliment. **Debug Output** Be sure and check out the EasyPrint (Print) function described in the high-level API section. Leave your code the way it is, route your stdout and stderror to a scrolling window. -For a fun time, add this line to the top of your script +For a fun time, add these lines to the top of your script import PySimpleGUI as sg print = sg.Print +This will turn all of your print statements into prints that display in a window on your screen rather than to the terminal. **Look and Feel** Dial in the look and feel that you like with the `SetOptions` function. You can change all of the defaults in one function call. One line of code to customize the entire GUI. @@ -1306,9 +1341,6 @@ And this was the output You'll quickly wonder how you ever coded without it. - - - --- # Known Issues While not an "issue" this is a ***stern warning*** @@ -1352,10 +1384,10 @@ Listboxes are still without scrollwheels. The mouse can drag to see more items. ### Upcoming Make suggestions people! Future release features -Auto Sized Buttons - Rather than using the default setting for TEXT fields, broke out button sizing into it's own setting. Makes much more sense. Reduces the amount of code. - Columns. How multiple columns would be specified in the SDK interface are still being designed. +Port to other graphic engines. Hook up the front-end interface to a backend other than tkinter. Qt, WxPython, etc. + ## Code Condition @@ -1378,14 +1410,10 @@ A moment about the design-spirit of `PySimpleGUI`. From the beginning, this pac While not the best programming practice, the implementation resulted in a single file solution. Only one file is needed, PySimpleGUI.py. You can post this file, email it, and easily import it using one statement. **Functions as objects** -In Python, functions behave just like classes. When you're placing a Text Element into your form, you may be sometimes calling a function and other times declaring an object. If you use the word Text, then you're getting an object. If you're using `Txt`, then you're calling a function that returns a `Text` object. +In Python, functions behave just like object. When you're placing a Text Element into your form, you may be sometimes calling a function and other times declaring an object. If you use the word Text, then you're getting an object. If you're using `Txt`, then you're calling a function that returns a `Text` object. **Lists** -It seemed quite natural to use Python's powerful list constructs when possible. - - - - +It seemed quite natural to use Python's powerful list constructs when possible. The form is specified as a series of lists. Each "row" of the GUI is represented as a list of Elements. When the form read returns the results to the user, all of the results are presented as a single list. This makes reading a form's values super-simple to do in a single line of Python code. ## Authors From 9386ec8fc1fea191b09907fb4773051ee42abc9b Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 30 Jul 2018 17:00:42 -0400 Subject: [PATCH 083/209] Window location global setting Added ability to change the default location of the window from centered to any value. --- PySimpleGUI.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index c89c86406..75182dc6c 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -21,6 +21,7 @@ DEFAULT_BORDER_WIDTH = 1 DEFAULT_AUTOCLOSE_TIME = 3 # time in seconds to show an autoclose form DEFAULT_DEBUG_WINDOW_SIZE = (80,20) +DEFAULT_WINDOW_LOCATION = (None,None) MAX_SCROLLED_TEXT_BOX_HEIGHT = 50 #################### COLOR STUFF #################### BLUES = ("#082567","#0A37A3","#00345B") @@ -738,7 +739,7 @@ def __init__(self, filename, scale=(None, None), size=(None, None)): :param size: Size of field in characters ''' self.Filename = filename - super().__init__(ELEM_TYPE_IMAGE, scale=scale, size=size, auto_size_text=auto_size_text) + super().__init__(ELEM_TYPE_IMAGE, scale=scale, size=size) return def __del__(self): @@ -1520,6 +1521,8 @@ def CharWidthInPixels(): screen_height = master.winfo_screenheight() if MyFlexForm.Location != (None, None): x,y = MyFlexForm.Location + elif DEFAULT_WINDOW_LOCATION != (None, None): + x,y = DEFAULT_WINDOW_LOCATION else: master.update_idletasks() # don't forget win_width = master.winfo_width() @@ -1546,7 +1549,7 @@ def ShowTabbedForm(title, *args, auto_close=False, auto_close_duration=DEFAULT_A if title is not None: root.title(title) if not len(args): - ('******************* SHOW TABBED FORMS ERROR .... no arguments') + print('******************* SHOW TABBED FORMS ERROR .... no arguments') return if DEFAULT_BACKGROUND_COLOR: framestyle = ttk.Style() @@ -2211,7 +2214,7 @@ def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), ma progress_meter_relief=None, progress_meter_color=None, progress_meter_size=None, text_justification=None, background_color=None, element_background_color=None, text_element_background_color=None, input_elements_background_color=None, - scrollbar_color=None, text_color=None, debug_win_size=(None,None)): + scrollbar_color=None, text_color=None, debug_win_size=(None,None), window_location=(None,None)): global DEFAULT_ELEMENT_SIZE global DEFAULT_MARGINS # Margins for each LEFT/RIGHT margin is first term @@ -2239,6 +2242,7 @@ def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), ma global DEFAULT_TEXT_ELEMENT_BACKGROUND_COLOR global DEFAULT_SCROLLBAR_COLOR global DEFAULT_TEXT_COLOR + global DEFAULT_WINDOW_LOCATION global _my_windows if icon: @@ -2318,6 +2322,9 @@ def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), ma if element_background_color != None: DEFAULT_ELEMENT_BACKGROUND_COLOR = element_background_color + if window_location != (None,None): + DEFAULT_WINDOW_LOCATION = window_location + if debug_win_size != (None,None): DEFAULT_DEBUG_WINDOW_SIZE = debug_win_size From e4a9f8048995e0d808c1cb6c6d2c7536b6f0d4b4 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 30 Jul 2018 23:50:52 -0400 Subject: [PATCH 084/209] Realtime Buttons New type of button, the realtime button, allows buttons to be 'polled'. They register as pushed as soon as the button goes down versus click which happens when you release the button. --- PySimpleGUI.py | 72 +++++++++++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 75182dc6c..b6c0d7380 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -112,10 +112,11 @@ def RGB(red,green,blue): return '#%02x%02x%02x' % (red,green,blue) #todo Consider removing the Submit, Cancel types... they are just 'RETURN' type in reality #uncomment this line and indent to go back to using Enums # class ButtonType(Enum): -BROWSE_FOLDER = 1 -BROWSE_FILE = 2 -CLOSES_WIN = 5 -READ_FORM = 7 +BUTTON_TYPE_BROWSE_FOLDER = 1 +BUTTON_TYPE_BROWSE_FILE = 2 +BUTTON_TYPE_CLOSES_WIN = 5 +BUTTON_TYPE_READ_FORM = 7 +BUTTON_TYPE_REALTIME = 9 # ------------------------- Element types ------------------------- # # class ElementType(Enum): @@ -216,7 +217,7 @@ def ReturnKeyHandler(self, event): for row in MyForm.Rows: for element in row.Elements: if element.Type == ELEM_TYPE_BUTTON: - if element.BType == CLOSES_WIN or element.BType == READ_FORM: + if element.BType == BUTTON_TYPE_CLOSES_WIN or element.BType == BUTTON_TYPE_READ_FORM: element.ButtonCallBack() return @@ -410,7 +411,7 @@ def ReturnKeyHandler(self, event): for row in MyForm.Rows: for element in row.Elements: if element.Type == ELEM_TYPE_BUTTON: - if element.BType == CLOSES_WIN or element.BType == READ_FORM: + if element.BType == BUTTON_TYPE_CLOSES_WIN or element.BType == BUTTON_TYPE_READ_FORM: element.ButtonCallBack() return @@ -569,7 +570,7 @@ def __del__(self): # Button Class # # ---------------------------------------------------------------------- # class Button(Element): - def __init__(self, button_type=CLOSES_WIN, target=(None, None), button_text='', file_types=(("ALL Files", "*.*"),), image_filename=None, image_size=(None,None), image_subsample=None, border_width=None, scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): + def __init__(self, button_type=BUTTON_TYPE_CLOSES_WIN, target=(None, None), button_text='', file_types=(("ALL Files", "*.*"),), image_filename=None, image_size=(None, None), image_subsample=None, border_width=None, scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): ''' Button Element - Specifies all types of buttons :param button_type: @@ -601,6 +602,14 @@ def __init__(self, button_type=CLOSES_WIN, target=(None, None), button_text='', super().__init__(ELEM_TYPE_BUTTON, scale, size, font=font) return + def ButtonReleaseCallBack(self, parm): + r, c = self.Position + self.ParentForm.Results[r][c] = False # mark this button's location in results + + def ButtonPressCallBack(self, parm): + r, c = self.Position + self.ParentForm.Results[r][c] = True # mark this button's location in results + # ------- Button Callback ------- # def ButtonCallBack(self): global _my_windows @@ -622,15 +631,15 @@ def ButtonCallBack(self): else: strvar = None filetypes = [] if self.FileTypes is None else self.FileTypes - if self.BType == BROWSE_FOLDER: + if self.BType == BUTTON_TYPE_BROWSE_FOLDER: folder_name = tk.filedialog.askdirectory() # show the 'get folder' dialog box try: strvar.set(folder_name) except: pass - elif self.BType == BROWSE_FILE: + elif self.BType == BUTTON_TYPE_BROWSE_FILE: file_name = tk.filedialog.askopenfilename(filetypes=filetypes) # show the 'get file' dialog box strvar.set(file_name) - elif self.BType == CLOSES_WIN: # this is a return type button so GET RESULTS and destroy window + elif self.BType == BUTTON_TYPE_CLOSES_WIN: # this is a return type button so GET RESULTS and destroy window # first, get the results table built # modify the Results table in the parent FlexForm object r,c = self.Position @@ -644,7 +653,7 @@ def ButtonCallBack(self): if self.ParentForm.NonBlocking: self.ParentForm.TKroot.destroy() _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 - elif self.BType == READ_FORM: # LEAVE THE WINDOW OPEN!! DO NOT CLOSE + elif self.BType == BUTTON_TYPE_READ_FORM: # LEAVE THE WINDOW OPEN!! DO NOT CLOSE # first, get the results table built # modify the Results table in the parent FlexForm object r,c = self.Position @@ -658,7 +667,7 @@ def ReturnKeyHandler(self, event): for row in MyForm.Rows: for element in row.Elements: if element.Type == ELEM_TYPE_BUTTON: - if element.BType == CLOSES_WIN or element.BType == READ_FORM: + if element.BType == BUTTON_TYPE_CLOSES_WIN or element.BType == BUTTON_TYPE_READ_FORM: element.ButtonCallBack() return @@ -1041,49 +1050,52 @@ def T(display_text, scale=(None, None), size=(None, None), auto_size_text=None, # ------------------------- FOLDER BROWSE Element lazy function ------------------------- # def FolderBrowse(target=(ThisRow, -1), button_text='Browse', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): - return Button(BROWSE_FOLDER, target=target, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) + return Button(BUTTON_TYPE_BROWSE_FOLDER, target=target, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) # ------------------------- FILE BROWSE Element lazy function ------------------------- # def FileBrowse(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Browse', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): - return Button(BROWSE_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) + return Button(BUTTON_TYPE_BROWSE_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) # ------------------------- SUBMIT BUTTON Element lazy function ------------------------- # def Submit(button_text='Submit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): - return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) # ------------------------- OK BUTTON Element lazy function ------------------------- # def OK(button_text='OK', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): - return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) # ------------------------- YES BUTTON Element lazy function ------------------------- # def Ok(button_text='Ok', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): - return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) # ------------------------- CANCEL BUTTON Element lazy function ------------------------- # def Cancel(button_text='Cancel', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): - return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) # ------------------------- QUIT BUTTON Element lazy function ------------------------- # def Quit(button_text='Quit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): - return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) # ------------------------- YES BUTTON Element lazy function ------------------------- # def Yes(button_text='Yes', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): - return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) # ------------------------- NO BUTTON Element lazy function ------------------------- # def No(button_text='No', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): - return Button(CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) # ------------------------- GENERIC BUTTON Element lazy function ------------------------- # # this is the only button that REQUIRES button text field def SimpleButton(button_text, image_filename=None, image_size=(None, None), image_subsample=None, border_width=None, scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): - return Button(CLOSES_WIN, image_filename=image_filename, image_size=image_size,image_subsample=image_subsample, button_text=button_text,border_width=border_width, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) + return Button(BUTTON_TYPE_CLOSES_WIN, image_filename=image_filename, image_size=image_size, image_subsample=image_subsample, button_text=button_text, border_width=border_width, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) # ------------------------- GENERIC BUTTON Element lazy function ------------------------- # # this is the only button that REQUIRES button text field def ReadFormButton(button_text, image_filename=None, image_size=(None, None),image_subsample=None,border_width=None,scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): - return Button(READ_FORM, image_filename=image_filename, image_size=image_size,image_subsample=image_subsample,border_width=border_width, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) + return Button(BUTTON_TYPE_READ_FORM, image_filename=image_filename, image_size=image_size, image_subsample=image_subsample, border_width=border_width, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) + +def RealtimeButton(button_text, image_filename=None, image_size=(None, None),image_subsample=None,border_width=None,scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): + return Button(BUTTON_TYPE_REALTIME, image_filename=image_filename, image_size=image_size, image_subsample=image_subsample, border_width=border_width, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) #------------------------------------------------------------------------------------------------------# # ------- FUNCTION InitializeResults. Sets up form results matrix ------- # @@ -1177,7 +1189,8 @@ def BuildResults(form): elif element.Type == ELEM_TYPE_BUTTON: if results[row_num][col_num] is True: button_pressed_text = element.ButtonText - results[row_num][col_num] = False + if element.BType != BUTTON_TYPE_REALTIME: # Do not clear realtime buttons + results[row_num][col_num] = False elif element.Type == ELEM_TYPE_INPUT_COMBO: value=element.TKStringVar.get() results[row_num][col_num] = value @@ -1321,10 +1334,15 @@ def CharWidthInPixels(): if bc == 'Random' or bc == 'random': bc = GetRandomColorPair() border_depth = element.BorderWidth - tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height,command=element.ButtonCallBack, justify=tk.LEFT, foreground=bc[0], background=bc[1], bd=border_depth) + if btype != BUTTON_TYPE_REALTIME: + tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height,command=element.ButtonCallBack, justify=tk.LEFT, foreground=bc[0], background=bc[1], bd=border_depth) + else: + tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height, justify=tk.LEFT, foreground=bc[0], background=bc[1], bd=border_depth) + tkbutton.bind('', element.ButtonReleaseCallBack) + tkbutton.bind('', element.ButtonPressCallBack) element.TKButton = tkbutton # not used yet but save the TK button in case wraplen = tkbutton.winfo_reqwidth() # width of widget in Pixels - if element.ImageFilename: + if element.ImageFilename: # if button has an image on it photo = tk.PhotoImage(file=element.ImageFilename) if element.ImageSize != (None, None): width, height = element.ImageSize @@ -1336,7 +1354,7 @@ def CharWidthInPixels(): tkbutton.image = photo tkbutton.configure(wraplength=wraplen+10, font=font) # set wrap to width of widget tkbutton.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) - if not focus_set and btype == CLOSES_WIN: + if not focus_set and btype == BUTTON_TYPE_CLOSES_WIN: focus_set = True element.TKButton.bind('', element.ReturnKeyHandler) element.TKButton.focus_set() From bf0c09ac055a7ec6fef4a10e8ceb1ad56caaf244 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 31 Jul 2018 00:01:07 -0400 Subject: [PATCH 085/209] Demo of Realtime Buttons Remote control demo using Realtime Buttons --- Demo_NonBlocking_Form.py | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/Demo_NonBlocking_Form.py b/Demo_NonBlocking_Form.py index 8ea24f6e9..6121e7254 100644 --- a/Demo_NonBlocking_Form.py +++ b/Demo_NonBlocking_Form.py @@ -42,6 +42,53 @@ def StatusOutputExample(): form.CloseNonBlockingForm() +def RemoteControlExample(): + # Make a form, but don't use context manager + form = sg.FlexForm('Running Timer', auto_size_text=True) + # Create a text element that will be updated with status information on the GUI itself + output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20), justification='center') + + + form_rows = [[sg.Text('Robotics Remote Control')], + [output_element], + [sg.T(' '*10), sg.RealtimeButton('Forward')], + [ sg.RealtimeButton('Left'), sg.T(' '*15), sg.RealtimeButton('Right')], + [sg.T(' '*10), sg.RealtimeButton('Reverse')], + [sg.T('')], + [sg.Quit()] + ] + + form.LayoutAndRead(form_rows, non_blocking=True) + + # + # Some place later in your code... + # You need to perform a ReadNonBlocking on your form every now and then or + # else it won't refresh. + # + # your program's main loop + i=0 + while (True): + # This is the code that reads and updates your window + output_element.Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100)) + button, values = form.ReadNonBlocking() + if button is not None: + print(button) + if button == 'Quit' or values is None: + break + if button == 'LED On': + print('Turning on the LED') + elif button == 'LED Off': + print('Turning off the LED') + + i += 1 + # Your code begins here + time.sleep(.01) + + # Broke out of main loop. Close the window. + form.CloseNonBlockingForm() + + + # This design pattern follows the uses a context manager to better control the resources # It may not be realistic to use a context manager within an embedded (Pi) environment @@ -65,6 +112,7 @@ def StatusOutputExample_context_manager(): form.CloseNonBlockingForm() def main(): + RemoteControlExample() StatusOutputExample() sg.MsgBox('End of non-blocking demonstration') # StatusOutputExample_context_manager() From b41f65dc658338048491eea7a6141c4ce1382aac Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 31 Jul 2018 09:28:12 -0400 Subject: [PATCH 086/209] Realtime Button addition --- readme.md | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 70ee46b77..84b0d2e62 100644 --- a/readme.md +++ b/readme.md @@ -57,6 +57,7 @@ The `PySimpleGUI` package is focused on the ***developer***. How can the desire Folder Browse Non-closing return Close form + Realtime Checkboxes Radio Buttons Listbox @@ -622,6 +623,7 @@ A summary of the variables that can be changed when a FlexForm is created Folder Browse Non-closing return Close form + Realtime Checkboxes Radio Buttons Listbox @@ -915,6 +917,7 @@ The Types of buttons include: * File Browse * Close Form * Read Form +* Realtime Close Form - Normal buttons like Submit, Cancel, Yes, No, etc, are "Close Form" buttons. They cause the input values to be read and then the form is closed, returning the values to the caller. @@ -925,6 +928,8 @@ File Browse - Same as the Folder Browse except rather than choosing a folder, a Read Form - This is an async form button that will read a snapshot of all of the input fields, but does not close the form after it's clicked. +Realtime - This is another async form button. Normal button clicks occur after a button's click is released. Realtime buttons report a click the entire time the button is held down. + While it's possible to build forms using the Button Element directly, you should never need to do that. There are pre-made buttons and shortcuts that will make life much easier. The most basic Button element call to use is `SimpleButton` SimpleButton(text, @@ -979,7 +984,7 @@ All buttons can have their text changed by changing the `button_text` variable i **Button Images** Now this is an exciting feature not found in many simplified packages.... images on buttons! You can make a pretty spiffy user interface with the help of a few button images. -Your button images need to be in PNG or GIF format. When you make a button with an image, set the button background to the same color as the background. There's a button color TRANSPARENT_BUTTON that you can set your button color to. +Your button images need to be in PNG or GIF format. When you make a button with an image, set the button background to the same color as the background. There's a button color TRANSPARENT_BUTTON that you can set your button color to in order for it to blend into the background. Note that this value is currently the same as the color as the default system background on Windows. This example comes from the `Demo Media Player.py` example program. Because it's a non-blocking button, it's defined as `ReadFormButton`. You also put images on blocking buttons by using `SimpleButton`. @@ -1004,6 +1009,40 @@ You'll find the source code in the file Demo Media Player. Here is what the but This is one you'll have to experiment with at this point. Not up for an exhaustive explanation. + **Realtime Buttons** + + Normally buttons are considered "clicked" when the mouse button is let UP after a downward click on the button. What about times when you need to read the raw up/down button values. A classic example for this is a robotic remote control. Building a remote control using a GUI is easy enough. One button for each of the directions is a start. Perhaps something like this: + +![snap0135](https://user-images.githubusercontent.com/13696193/43440841-bcf8d184-9466-11e8-9f7b-30a1d5ce32d3.jpg) + +This form has 2 button types. There's the normal "Simple Button" (Quit) and 4 "Realtime Buttons". + +Here is the code to make, show and get results from this form: + + form = sg.FlexForm('Robotics Remote Control', auto_size_text=True) + + form_rows = [[sg.Text('Robotics Remote Control')], + [sg.T(' '*10), sg.RealtimeButton('Forward')], + [ sg.RealtimeButton('Left'), sg.T(' '*15), sg.RealtimeButton('Right')], + [sg.T(' '*10), sg.RealtimeButton('Reverse')], + [sg.T('')], + [sg.Quit(button_color=('black', 'orange'))] + ] + + form.LayoutAndRead(form_rows, non_blocking=True) + +Somewhere later in your code will be your main event loop. This is where you do your polling of devices, do input/output, etc. It's here that you will read your form's buttons. + + while (True): + # This is the code that reads and updates your window + button, values = form.ReadNonBlocking() + if button is not None: + sg.Print(button) + if button == 'Quit' or values is None: + break + time.sleep(.01) + +This loop will read button values and print them. When one of the Realtime buttons is clicked, the call to `form.ReadNonBlocking` will return a button name matching the name on the button that was depressed. It will continue to return values as long as the button remains depressed. Once released, the ReadNonBlocking will return None for buttons ules anutton was clicked. **File Types** The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is @@ -1163,6 +1202,7 @@ Let's have some fun customizing! Make PySimpleGUI look the way you want it to l input_elements_background_color=None scrollbar_color=None, text_color=None debug_win_size=(None,None) + window_location=(None,None) Explanation of parameters @@ -1193,6 +1233,7 @@ Explanation of parameters text_color - Text element default text color text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' debug_win_size - size of the Print output window + window_location - location on the screen (x,y) of window's top left cornder These settings apply to all forms `SetOptions`. The Row options and Element options will take precedence over these settings. Settings can be thought of as levels of settings with the Form-level being the highest and the Element-level the lowest. Thus the levels are: @@ -1369,6 +1410,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi | 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. | 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ +| 2.6.5 | Aug XX, 2018 - window_location default setting ### Release Notes 2.3 - Sliders, Listbox's and Image elements (oh my!) From 3066a1c099735ef9b36106ffc6260ce5179af94d Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 31 Jul 2018 10:53:55 -0400 Subject: [PATCH 087/209] Pi Robotics Demo / Design Pattern --- ButtonGraphics/RobotBack.png | Bin 0 -> 1000 bytes ButtonGraphics/RobotForward.png | Bin 0 -> 1483 bytes ButtonGraphics/RobotLeft.png | Bin 0 -> 1454 bytes ButtonGraphics/RobotRight.png | Bin 0 -> 1472 bytes Demo_Pi_Robotics.py | 96 ++++++++++++++++++++++++++++++++ 5 files changed, 96 insertions(+) create mode 100644 ButtonGraphics/RobotBack.png create mode 100644 ButtonGraphics/RobotForward.png create mode 100644 ButtonGraphics/RobotLeft.png create mode 100644 ButtonGraphics/RobotRight.png create mode 100644 Demo_Pi_Robotics.py diff --git a/ButtonGraphics/RobotBack.png b/ButtonGraphics/RobotBack.png new file mode 100644 index 0000000000000000000000000000000000000000..dfb51e5a245f66a1449d35f72e6afe0788e19cd6 GIT binary patch literal 1000 zcmV>P)!;Y~V z*duI_U2WIcO1sqVXlK}-WP}{f;wIkad;a8aef-SlJV-4&FqpI%$l=@{r1d@CW)-tY zgF|?Uzmt4?OAX^mf%)7Vk>V$w<64?o!7{43nEUxGLh(KaktF-`g%kK4mvbP~=}nlC zY(+J1g-qJ$PeO{FfNxmMOneOH5T14-?qw`qRypEJ{K=JmoW|E0^%N6`OOeWc;3!gI zA&+S6BMc=b`>EtZHXv07afQZTNq3@{!`GTVi*)G4C2Da75p?Gc`RjW&AYJ-$rw;4I zgg8*W5BH9lBI;R4e8%&>{v;b8Is6*v{veltEdG%0ot~sY7Jjai3a=sHY#qI1#z6bwdD9Ev zCi!__#teq>Nud1Q%*T%6ZP}xyWz0Yu$sB;)kRO8|&(Sl32Iq^xGVGDEDP9X1G}uE7 zF2u?TN>kJ#yqw!PA)!GQS92?y6J{eZxC6Ud3|0{4WGOH88stlNe#i)1a`+=Kco@4@ z5-lT4l}`DRxCZ%rESle#f=d>^2L_K|D@9U8n1y_*7DX`)3J7X1(cN$<7&LR-iKVla)xeC(u;<^(aQ!%mkZ zp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mBG%R(SACP`~Kl*Jmc;W@Qxba zpI5w^z(G8OWd>n>@lN|`!J0V70hp}BxSjUHEAO;Pue?*@2z(7)S22E%c(|n}yCHd* zJK?nP?gq?1X4|mIMZh;X(q7nk7gMj!n~@FTa!k*dFrBPy^us$GurD(mKzys+flLE? zVYqu%`{_7g+8DQ#24*+_uX?~yh1;FOV?16+Rjz!>B^_f- zUHg&tZHa#{aS5z|{SpULNl(Q`@qRoQ>vTTgUGR>&=&!&*F@L(Y7CQj1VvM)4A5Y>z zXi{!*swp?)0eC*9QzT{6&Z8{BMGhdnZQFMqmo-+zE!$5Ee#iL^;H~221a)Kg$;RzI zE+!a`EHIQXY4GF?N3^?2(|U~6HFvbo=Cjz86EL)=4`Z>a7vg+hbTDPJn6<3onu~e5 z^H|^s8IR6Gr3u5n17?PcF|=o(*i}Qd#2rVE9%j2@U3S4?4!{g7w59XV+0(@n7{AGV zzAi?%aa&bR=@fUKG_kizz7&UG{3cE3U0JMf#5wj&SQm@Dai9EMqUT}z2*z(V_pDo7 zH88UzZxPtgw+_Zeaevg^s3$vOnmswS>K3P(us6mFR}DFqn)@kfeMqfUR!K9P;tul} z#(l6(wH*$`5$5WW_h45kW0LU7r=8d1urw}0bK|rT|28P;Xu@e|$ew<$>!>nDe&)w% zW8O;3eXHQG*cx*sb@iv%+W54q%*Ct7Xo*1)5V^x3uDB&B-fmNMHrr l#OdA9(b2S!P?KrX{sV=|NrAHH+KB)F002ovPDHLkV1grQ)`|cC literal 0 HcmV?d00001 diff --git a/ButtonGraphics/RobotLeft.png b/ButtonGraphics/RobotLeft.png new file mode 100644 index 0000000000000000000000000000000000000000..2b3d89e6fb4914639ffd5e4a426af68e6977eea2 GIT binary patch literal 1454 zcmV;f1yTBmP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D1w%VPsF%dBI=_D1W}`8cu>Mcf*{5i zjL{jrjnRLZ9A|590o_hL14o-gf$^9+m8GWU&BIp4xWTJ!Fw|*8#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SL@}!ntrMtn3##`U0Mt34-|;4{c8TZi8VYH1@Fhr9>e z55CR1S{p8c?;w4KJ$MvU()#csq=ouseB(_^^Lhx<=luakLn*BS3n4Ack!M2~rY?ZL zAU^jO*cS@x7KjDNov;#2ha8F0dF2Dx1P1DOh&ReTpyN%aPK2}``dwdX9@==kNhe+% zsz?Xj6sm?Snp3QcoCG~}J;aM08McQi+7CVfo$y+y+KBlO>+~Mv4%r4{23PUobD*jo zgILzhP({}38;E7KU@2V*@uHWY*Q{Ga_dzUAY($lwxDaAFZ^3HN)f(_V#ETpW>S!)} z4zWzR3Ce06FnW#U7{zvV2*e+a4sBFj?FM|C(4?W z0bsm;f`!z~kyfjPBXxTQ}=!vu$SSi}yrWG~euB%vI48CyE(duskTf0BORfNIe5M%|XltVUuAf}%4ol7% z{c=UtZHlk>g?1S=D7E37p}p#q&y>XB`bqc|QaSqByT7&1^5tL?dvCEma0&<7W@cMP zf5Vi4Sl5mxu~)V4K{9;k-iHs|W)Hjx(eAZxCyimq=wwL#~wt=Hh4&S57(6&?9U(3I-x63EKTFa=rW&1Xs% zNG`yp=qZR7r1n}?XF)7a%9>3kqgjKwtQ=pqsr@NB8REmfhdRCRIK=X*zIm1AW-WUu zIZ3<@@j{bXRdoeq<mbhLg>)>WH`|Em=n2!9c^fKs zL#dpSn+|CqcA=xyuw?JMeomk3gjZ$$ctmd zhdJ4~vr<(K-LAr>q)P&ZIPMhH)-jN`hb5YoHfsQAub5}*C2iQ0yP0b@_|kM{u+lx3|w4meH$k+BiJ# zt<}N##{G$Yi~7c7*Sb^UI=AlM4V-E9CG%6IRcc(#kv-zy4-SI8!7Sgp;4GT0H8NRQ zBT7SccUepd__qb4;54yNSalmPMXgp#+tye78-a@tCnX!AZ Date: Thu, 2 Aug 2018 12:59:54 -0400 Subject: [PATCH 088/209] Credit to Fredrik Lundhl For his work on tkinter --- readme.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 84b0d2e62..9b29f3d3d 100644 --- a/readme.md +++ b/readme.md @@ -3,7 +3,7 @@ [![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 # PySimpleGUI - (Ver 2.6) + (Ver 2.7) Super-simple GUI to grasp... Powerfully customizable. @@ -118,7 +118,7 @@ You will see a number of different styles of buttons, data entry fields, etc, in ### Design Goals > Copy, Paste, Run. -`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the SDK to visually match what's on the screen. +`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the code to visually match what's on the screen. > Be Pythonic @@ -128,6 +128,7 @@ You will see a number of different styles of buttons, data entry fields, etc, in - A row is a list of elements - Return values are a list of button presses and input values. +It's stunning that after so many years Python still hasn't put forth a GUI framework that truly fits the language's basic data structures, especially lists. It's hard to argue with the success to be had in quickly building GUI applications using this package's syntax. ----- ## Getting Started with PySimpleGUI @@ -1468,6 +1469,8 @@ GNU Lesser General Public License (LGPL 3) + ## Acknowledgments * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence +* [Fredrik Lundh](https://wiki.python.org/moin/FredrikLundh) for his work on `tkinter` + ## How Do I Finally, I must thank the fine folks at How Do I. From 3848284f7ddc76a5b5a39652bf185789e42f264c Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 2 Aug 2018 20:54:10 -0400 Subject: [PATCH 089/209] Added readme.rst to docs --- Docs/readme.rst | 1174 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1174 insertions(+) create mode 100644 Docs/readme.rst diff --git a/Docs/readme.rst b/Docs/readme.rst new file mode 100644 index 000000000..d7260a069 --- /dev/null +++ b/Docs/readme.rst @@ -0,0 +1,1174 @@ +.. figure:: https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png + :alt: pysimplegui\_logo + + pysimplegui\_logo +|Downloads| since Jul 11, 2018 # PySimpleGUI (Ver 2.7) + +Super-simple GUI to grasp... Powerfully customizable. + +Note - *Python3* is required to run PySimpleGUI. It takes advantage of +some Python3 features that do not translate well into Python2. + +Looking to take your Python code from the world of command lines and +into the convenience of a GUI? Have a Raspberry Pi with a touchscreen +that's going to waste because you don't have the time to learn a GUI +SDK? Look no further, you've found your GUI package. + +:: + + import PySimpleGUI as sg + + sg.MsgBox('Hello From PySimpleGUI!', 'This is the shortest GUI program ever!') + +.. figure:: https://user-images.githubusercontent.com/13696193/43162494-33095ece-8f59-11e8-86de-b6d8bcc5a52f.jpg + :alt: snap0136 + + snap0136 +Build beautiful customized forms that fit your specific problem. Let +PySimpleGUI solve your GUI problem while you solve the real problems. Do +you really want to plod through the mountains of code required to +program tkinter? + +.. figure:: https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg + :alt: snap0156 + + snap0156 +Perhaps you're looking for a way to interact with your Raspberry Pi in a +more friendly way. The is the same form as above, except shown on a Pi. + +.. figure:: https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg + :alt: raspberry pi + + raspberry pi +In addition to a primary GUI, you can add a Progress Meter to your code +with ONE LINE of code. Slide this into any of your ``for`` loops and get +a nice meter like this: + +:: + + EasyProgressMeter('My meter title', current_value, max value) + +.. figure:: https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg + :alt: progress meter 2 + + progress meter 2 +You can build an async media player GUI with custom buttons in 30 lines +of code. + +.. figure:: https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg + :alt: media file player + + media file player +I was frustrated by having to deal with the dos prompt when I had a +powerful Windows machine right in front of me. Why is it SO difficult to +do even the simplest of input/output to a window in Python?? + +There are a number of 'easy to use' Python GUIs, but they're **very** +limiting. PySimpleGUI takes the best of packages like ``EasyGUI``\ and +``WxSimpleGUI`` , both really handy but limited. The primary difference +between these and PySimpleGUI is that in addition to getting the simple +Message Boxes you also get the ability to make your own forms that are +highly customizeable. Don't like the standard Message Box? Then make +your own! + +Every call has optional parameters so that you can change the look and +feel. Don't like the button color? It's easy to change by adding a +button\_color parameter to your widget. + +GUI Packages with more functionality, like QT and WxPython, require +configuring and can take a ***week*** to get *reasonably familiar* with +the interfaces. Clearly there needs to be a middle ground between forms +with 1 or two input fields and a full-blown GUI. You'll be making your +own custom forms with PySimpleGUI within minutes, even Async forms. + +With a simple GUI, it becomes practical to "associate" .py files with +the python interpreter on Windows. Double click a py file and up pops a +GUI window, a more pleasant experience than opening a dos Window and +typing a command line. + +The ``PySimpleGUI`` package is focused on the ***developer***. How can +the desired result be achieved in as little and as simple code as +possible? This was the mantra used to create PySimpleGUI. How can it be +done is a Python-like way? + +:: + + Features of PySimpleGUI include: + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Realtime + Checkboxes + Radio Buttons + Listbox + Slider + Icons + Multi-line Text Input + Scroll-able Output + Images + Progress Bar + Async/Non-Blocking Windows + Tabbed forms + Persistent Windows + Redirect Python Output/Errors to scrolling window + 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + Single-Line-Of-Coide Proress Bar & Debug Print + Complete control of colors, look and feel + Button images + +An example of many widgets used on a single form. A little further down +you'll find the TWENTY lines of code required to create this complex +form. Try it if you don't believe it. Start Python, copy and paste the +code below into the >>> prompt and hit enter. This will pop up... + +.. figure:: https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg + :alt: everything example + + everything example +Here is the code that produced the above screenshot. + +:: + + import PySimpleGUI as SG + + with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [SG.Text('Here is some text.... and a place to enter text')], + [SG.InputText()], + [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], + [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], + [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [SG.Text('_' * 100, size=(70, 1))], + [SG.Text('Choose Source and Destination Folders', size=(35, 1))], + [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], + [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), + SG.FolderBrowse()], + [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + +**A note on screen shots** You will see a number of different styles of +buttons, data entry fields, etc, in this readme. They were all made with +the same SDK, the only difference is in the settings that are specified +on a per-element, row, form, or global basis. One setting in particular, +border\_width, can make a big difference on the look of the form. Some +of the screenshots had a border\_width of 6, others a value of 1. + +APIs +---- + +PySimpleGUI can be broken down into 2 types of API's: \* High Level +single call functions \* Custom form functions + +Python Language Features +~~~~~~~~~~~~~~~~~~~~~~~~ + +There are a couple of Python language features that PySimpleGUI utilizes +heavily that should be understood first... \* Variable number of +arguments to a function call \* Optional parameters to a function call + +Variable Number of Arguments +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The "High Level" API calls that *output* values take a variable number +of arguments so that they match a "print" statement as much as possible. +The idea is to make it simple for the programmer to output as many items +as desired and in any format. The user need not convert the variables to +be output into the strings. The PySimpleGUI functions do that for the +user. + +:: + + SG.MsgBox('Variable number of parameters example', var1, var2, "etc") + +Each new item begins on a new line in the Message Box + +.. figure:: https://user-images.githubusercontent.com/13696193/42844739-ebea22ac-89e1-11e8-8dd1-e61441325701.jpg + :alt: snap0104 + + snap0104 +Optional Parameters to a Function Call +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This feature of the Python language is utilized ***heavily*** as a +method of customizing forms and form Elements. Rather than requiring the +programmer to specify every possible option for a widget, instead only +the options the caller wants to override are specified. + +Here is the function definition for the MsgBox function. The details +aren't important. What is important is seeing that there is a long list +of potential tweaks that a caller can make. However, they don't *have* +to be specified on each and every call. + +:: + + def MsgBox(*args, + button_color=None, + button_type=MSG_BOX_OK, + auto_close=False, + auto_close_duration=None, + icon=DEFAULT_WINDOW_ICON, + line_width=MESSAGE_BOX_LINE_WIDTH, + font=None): + +If the caller wanted to change the button color to be black on yellow, +the call would look something like this: + +:: + + SG.MsgBox('This box has a custom button color', + button_color=('black', 'yellow')) + +.. figure:: https://user-images.githubusercontent.com/13696193/42844830-2d7e8b9a-89e2-11e8-8ef4-5af9e36f30f3.jpg + :alt: snap0105 + + snap0105 + +-------------- + +High Level API Calls +~~~~~~~~~~~~~~~~~~~~ + +The classic "input a value, print result" example. Often command line +programs simply take some value as input on the command line, do +something with it and then display the results. Moving from the command +line to a GUI is very simple. This code prompts user to input a line of +text and then displays that text in a messages box: + +:: + + import PySimpleGUI_local as SG + + rc = SG.GetTextBox('Title', 'Please input something') + SG.MsgBox('Results', 'The value returned from GetTextBox', rc) + +.. figure:: https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg + :alt: GetTextBox + + GetTextBox +.. figure:: https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg + :alt: MsgBox + + MsgBox +Message Boxes +^^^^^^^^^^^^^ + +In addition to MsgBox, you'll find a several API calls that are +shortcuts to common messages boxes. You can achieve similar results by +calling MsgBox with the correct parameters. + +The differences tend to be the number and types of buttons. Here are the +calls and the windows that are created. + +:: + + import PySimpleGUI as SG + +``SG.MsgBoxOK('This is an OK MsgBox')`` + +.. figure:: https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg + :alt: msgboxok + + msgboxok +:: + + SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') + +.. figure:: https://user-images.githubusercontent.com/13696193/42599858-8e8eff22-852e-11e8-8d5c-3fe99237eb7f.jpg + :alt: msgboxokcancel + + msgboxokcancel +:: + + SG.MsgBoxCancel('This is a Cancel MsgBox') + +.. figure:: https://user-images.githubusercontent.com/13696193/42599857-8e53dc4e-852e-11e8-8e83-6a8cccf8e706.jpg + :alt: msgboxcancel + + msgboxcancel +:: + + SG.MsgBoxYesNo('This is a Yes No MsgBox') + +.. figure:: https://user-images.githubusercontent.com/13696193/42599856-8e304540-852e-11e8-975d-fb2b62e94300.jpg + :alt: msgboxyesno + + msgboxyesno +:: + + SG.MsgBoxError('This is an error MsgBox') + +.. figure:: https://user-images.githubusercontent.com/13696193/42599853-8df8e078-852e-11e8-90dc-7815d69bff7e.jpg + :alt: msgbox error + + msgbox error +:: + + SG.MsgBoxAutoClose('This is an autoclose MsgBox') + +.. figure:: https://user-images.githubusercontent.com/13696193/42599855-8e147572-852e-11e8-8c23-7ec771909062.jpg + :alt: msgbox autoclose + + msgbox autoclose +:: + + SG.ScrolledTextBox(my_text, height=10) + +.. figure:: https://user-images.githubusercontent.com/13696193/42600800-a44f4562-8531-11e8-8c21-51dd70316879.jpg + :alt: scrolledtextbox + + scrolledtextbox +Take a moment to look at that last one. It's such a simple API call and +yet the result is awesome. Rather than seeing text scrolling past on +your display, you can capture that text and present it in a scrolled +interface. It's handy enough of an API call that it can also be called +using the name ``sprint`` which is easier to remember than +``ScrollectTextBox``. Your code could contain a line like: + +:: + + sprint(f'My variables values include x={x}', f'y={y}') + +This becomes a debug print of sorts that will route to a scrolled +window. + +High Level User Input +^^^^^^^^^^^^^^^^^^^^^ + +There are 3 very basic user input high-level function calls. It's +expected that for most applications, a custom input form will be +created. If you need only 1 value, then perhaps one of these high level +functions will work. - GetTextBox - GetFileBox - GetFolderBox + +``submit_clicked, value = SG.GetTextBox('Title', 'Please enter anything')`` + +.. figure:: https://user-images.githubusercontent.com/13696193/42600399-1ef66a5e-8530-11e8-9bc4-78ea839213cd.jpg + :alt: gettextbox + + gettextbox +:: + + submit_clicked, value = SG.GetFileBox('Title', 'Choose a file') + +.. figure:: https://user-images.githubusercontent.com/13696193/42600398-1ed8a122-8530-11e8-9f74-88b101efcea4.jpg + :alt: getfilebox + + getfilebox +:: + + submit_clicked, value = SG.GetPathBox('Title', 'Choose a folder') + +.. figure:: https://user-images.githubusercontent.com/13696193/42600397-1ea7cef8-8530-11e8-8d43-e1000c0933cd.jpg + :alt: getfolderbox + + getfolderbox +Progress Meter! +^^^^^^^^^^^^^^^ + +We all have loops in our code. 'Isn't it joyful waiting, watching a +counter scrolling past in a text window? How about one line of code to +get a progress meter, that contains statistics about your code? + +.. figure:: https://user-images.githubusercontent.com/13696193/42696332-dca3ca6e-8685-11e8-846b-6bee8362ee5f.jpg + :alt: progress meter 3 + + progress meter 3 +:: + + EasyProgressMeter(title, + current_value, + max_value, + *args, + orientation=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): + +Here's the one-line Progress Meter in action! + +:: + + for i in range(1,10000): + SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') + +That line of code resulted in this window popping up and updating. + +.. figure:: https://user-images.githubusercontent.com/13696193/42696912-a5c958b8-8687-11e8-9a7d-a390a465407a.jpg + :alt: progress meter 5 + + progress meter 5 +A meter AND fun statistics to watch while your machine grinds away, all +for the price of 1 line of code. With a little trickery you can provide +a way to break out of your loop using the Progress Meter form. The +cancel button results in a ``False`` return value from +``EasyProgressMeter``. It normally returns ``True``. + +:: + + if not SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message'): + break + +***Be sure and add one to your loop counter*** so that your counter goes +from 1 to the max value. If you do not add one, your counter will never +hit the max value. Instead it will go from 0 to max-1. #### Debug Output +Another call in the 'Easy' families of APIs is ``EasyPrint``. It will +output to a debug window. If the debug window isn't open, then the first +call will open it. No need to do anything but stick a 'print' call in +your code. You can even replace your 'print' calls with calls to +EasyPrint by simply sticking the statement + +:: + + print = SG.EasyPrint + +at the top of your code. There are a number of names for the same +EasyPrint function. ``Print`` is one of the better ones to use as it's +easy to remember. It is simply ``print`` with a capital P. + +:: + + import PySimpleGUI as SG + + for i in range(100): + SG.Print(i) + +|snap0125| Or if you didn't want to change your code: + +:: + + import PySimpleGUI as SG + + print=SG.Print + for i in range(100): + print(i) + +Just like the standard print call, ``EasyPrint`` supports the ``sep`` +and ``end`` keyword arguments. Other names that can be used to call +``EasyPrint`` include Print, ``eprint``, If you want to close the +window, call the function ``EasyPrintClose``. + +A word of caution. There are known problems when multiple PySimpleGUI +windows are opened, particularly if the user closes them in an unusual +way. Not a reason to stay away from using it. Just something to keep in +mind if you encounter a problem. + +You can change the size of the debug window using the ``SetOptions`` +call with the ``debug_win_size`` parameter. + +All Widgets / Elements +---------------------- + +This code utilizes as many of the elements in one form as possible. + +:: + + with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [SG.Text('Here is some text.... and a place to enter text')], + [SG.InputText()], + [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], + [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], + [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [SG.Text('_' * 100, size=(70, 1))], + [SG.Text('Choose Source and Destination Folders', size=(35, 1))], + [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], + [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), + SG.FolderBrowse()], + [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + +This is a somewhat complex form with quite a bit of custom sizing to +make things line up well. This is code you only have to write once. When +looking at the code, remember that what you're seeing is a list of +lists. Each row contains a list of Graphical Elements that are used to +create the form. + +.. figure:: https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg + :alt: everything example + + everything example +Clicking the Submit button caused the form call to return. The call to +MsgBox resulted in this dialog box. |results 2| + +**``Note, button value can be None``**. The value for ``button`` will be +the text that is displayed on the button element when it was created. If +the user closed the form using something other than a button, then +``button`` will be ``None``. + +You can see in the MsgBox that the values returned are a list. Each +input field in the form generates one item in the return values list. +All input fields return a ``string`` except for Check Boxes and Radio +Buttons. These return ``bool``. + +ProgressBar +^^^^^^^^^^^ + +The ``ProgressBar`` element is used to build custom Progress Bar forms. +It is HIGHLY recommended that you use the functions that provide a +complete progress meter solution for you. Progress Meters are not easy +to work with because the forms have to be non-blocking and they are +tricky to debug. + +The **easiest** way to get progress meters into your code is to use the +``EasyProgessMeter`` API. This consists of a pair of functions, +``EasyProgessMeter`` and ``EasyProgressMeterCancel``. You can easily +cancel any progress meter by calling it with the current value = max +value. This will mark the meter as expired and close the window. You've +already seen EasyProgressMeter calls presented earlier in this readme. + +:: + + SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') + +The return value for ``EasyProgressMeter`` is: ``True`` if meter updated +correctly ``False`` if user clicked the Cancel button, closed the form, +or vale reached the max value. **Customized Progress Bar** If you want a +bit more customization of your meter, then you can go up 1 level and use +the calls to ``ProgressMeter`` and ``ProgressMeterUpdate``. These APIs +behave like an object we're all used to. First you create the +``ProgressMeter`` object, then you call the ``Update`` method to update +it. + +You setup the progress meter by calling + +:: + + my_meter = ProgressMeter(title, + max_value, + *args, + orientantion=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) + +Then to update the bar within your loop + +:: + + return_code = ProgressMeterUpdate(my_meter, + value, + *args): + +Putting it all together you get this design pattern + +:: + + my_meter = SG.ProgressMeter('Meter Title', 100000, orentation='Vert') + + for i in range(0, 100000): + SG.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') + +The final way of using a Progress Meter with PySimpleGUI is to build a +custom form with a ``ProgressBar`` Element in the form. You will need to +run your form as a non-blocking form. When you are ready to update your +progress bar, you call the ``UpdateBar`` method for the ``ProgressBar`` +element itself. + +Output +^^^^^^ + +The Output Element is a re-direction of Stdout. Anything "printed" will +be displayed in this element. + +:: + + Output(scale=(None, None), + size=(None, None)) + +Here's a complete solution for a chat-window using an Async form with an +Output Element + +:: + + import PySimpleGUI as SG + # Blocking form that doesn't close + def ChatBot(): + with SG.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + layout = [[(SG.Text('This is where standard out is being routed', size=[40, 1]))], + [SG.Output(size=(80, 20))], + [SG.Multiline(size=(70, 5), enter_submits=True), SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))]] + # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form + # if you call LayoutAndRead from here, then you will miss the first button click + form.Layout(layout) + # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # + while True: + button, value = form.Read() + if button == 'SEND': + print(value) + else: + break + +Tabbed Forms +------------ + +Tabbed forms are shown using the ``ShowTabbedForm`` call. The call has +the format + +:: + + results = ShowTabbedForm('Title for the form', + (form,layout,'Tab 1 label'), + (form2,layout2, 'Tab 2 label'), ...) + +Each of the tabs of the form is in fact a form. The same steps are taken +to create the form as before. A ``FlexForm`` is created, then rows are +filled with Elements, and finally the form is shown. When calling +``ShowTabbedForm``, each form is passed in as a tuple. The tuple has the +format: ``(the form, the rows, a string shown on the tab)`` + +Results are returned as a list of lists. For each form you'll get a list +that's in the same format as a normal form. A single tab's values would +be: + +:: + + (button, (values)) + +Recall that values is a list as well. Multiple tabs in the form would +return like this: + +:: + + ((button1, (values1)), (button2, (values2)) + +## Colors ## Starting in version 2.5 you can change the background +colors for the window and the Elements. + +Your forms can go from this: |snap0155| + +to this... with one function call... + +.. figure:: https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg + :alt: snap0156 + + snap0156 +While you can do it on an element by element or form level basis, the +easiest way, by far, is a call to ``SetOptions``. + +Be aware that once you change these options they are changed for the +rest of your program's execution. All of your forms will have that look +and feel, until you change it to something else (which could be the +system default colors. + +This call sets all of the different color options. + +:: + + SetOptions(background_color='#9FB8AD', + text_element_background_color='#9FB8AD', + element_background_color='#9FB8AD', + scrollbar_color=None, + input_elements_background_color='#F7F3EC', + progress_meter_color = ('green', 'blue') + button_color=('white','#475841')) + +Global Settings +--------------- + +**Global Settings** Let's have some fun customizing! Make PySimpleGUI +look the way you want it to look. You can set the global settings using +the function ``PySimpleGUI.SetOptions``. Each option has an optional +parameter that's used to set it. + +:: + + SetOptions(icon=None + button_color=(None,None) + element_size=(None,None), + margins=(None,None), + element_padding=(None,None) + auto_size_text=None + auto_size_buttons=None + font=None + border_width=None + slider_border_width=None + slider_relief=None + slider_orientation=None + autoclose_time=None + message_box_line_width=None + progress_meter_border_depth=None + progress_meter_style=None + progress_meter_relief=None + progress_meter_color=None + progress_meter_size=None + text_justification=None + background_color=None + element_background_color=None + text_element_background_color=None + input_elements_background_color=None + scrollbar_color=None, text_color=None + debug_win_size=(None,None) + window_location=(None,None) + +Explanation of parameters + +:: + + icon - filename of icon used for taskbar and title bar + button_color - button color (foreground, background) + element_size - element size (width, height) in characters + margins - tkinter margins around outsize + element_padding - tkinter padding around each element + auto_size_text - autosize the elements to fit their text + auto_size_buttons - autosize the buttons to fit their text + font - font used for elements + border_width - amount of bezel or border around sunken or raised elements + slider_border_width - changes the way sliders look + slider_relief - changes the way sliders look + slider_orientation - changes orientation of slider + autoclose_time - time in seconds for autoclose boxes + message_box_line_width - number of characers in a line of text in message boxes + progress_meter_border_depth - amount of border around raised or lowered progress meters + progress_meter_style - style of progress meter as defined by tkinter + progress_meter_relief - relief style + progress_meter_color - color of the bar and background of progress meters + progress_meter_size - size in (characters, pixels) + background_color - Color of the main window's background + element_background_color - Background color of the elements + text_element_background_color - Text element background color + input_elements_background_color - Input fields background color + scrollbar_color - Color for scrollbars (may not always work) + text_color - Text element default text color + text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' + debug_win_size - size of the Print output window + window_location - location on the screen (x,y) of window's top left cornder + +These settings apply to all forms ``SetOptions``. The Row options and +Element options will take precedence over these settings. Settings can +be thought of as levels of settings with the Form-level being the +highest and the Element-level the lowest. Thus the levels are: + +- Form level +- Row level +- Element level + +Each lower level overrides the settings of the higher level. Once +settings have been changed, they remain changed for the duration of the +program (unless changed again). + +Asynchronous (Non-Blocking) Forms +--------------------------------- + +So you want to be a wizard do ya? Well go boldly! While the majority of +GUIs are a simple exercise to "collect input values and return with +them", there are instances where we want to continue executing while the +form is open. These are "asynchronous" forms and require special +options, new SDK calls, and **great care**. With asynchronous forms the +form is shown, user input is read, but your code keeps right on +chugging. YOUR responsibility is to call ``PySimpleGUI.ReadNonBlocking`` +on a periodic basis. Once a second or more will produce a reasonably +snappy GUI. + +When do you use a non-blocking form? A couple of examples are \* A media +file player like an MP3 player \* A status dashboard that's periodically +updated \* Progress Meters - when you want to make your own progress +meters \* Output using print to a scrolled text element. Good for +debugging. + +Word of warning... version 2.2, the currently released, and upcoming +version 2.3 differ in the return code for the ``ReadNonBlocking`` call. +Previously the function returned 2 values, except when the form is +closed using the "X" which returned a single value of ``None``. The +*new* way is that ``ReadNonBlocking`` always returns 2 values. If the +user closed the form with the "X" then the return values will be None, +None. You will want to key off the second value to catch this case. The +proper code to check if the user has exited the form will be a +polling-loop that looks something like this: + +:: + + while True: + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + +We're going to build an app that does the latter. It's going to update +our form with a running clock. + +The basic flow and functions you will be calling are: Setup + +:: + + form = FlexForm() + form_rows = ..... + form.LayoutAndRead(form_rows, non_blocking=True) + +Periodic refresh + +:: + + form.ReadNonBlocking() + +If you need to close the form + +:: + + form.CloseNonBlockingForm() + +Rather than the usual ``form.LayoutAndRead()`` call, we're manually +adding the rows (doing the layout) and then showing the form. After the +form is shown, you simply call ``form.ReadNonBlocking()`` every now and +then. + +When you are ready to close the form (assuming the form wasn't closed by +the user or a button click) you simply call +``form.CloseNonBlockingForm()`` + +**Example - Running timer that updates** See the sample code on the +GitHub named Demo Media Player for another example of Async Forms. We're +going to make a form and update one of the elements of that form every +.01 seconds. Here's the entire code to do that. + +:: + + import PySimpleGUI as sg + import time + + # form that doesn't block + # Make a form, but don't use context manager + form = sg.FlexForm('Running Timer', auto_size_text=True) + # Create a text element that will be updated with status information on the GUI itself + output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) + # Create the rows + form_rows = [[sg.Text('Non-blocking GUI with updates')], + [output_element], + [sg.SimpleButton('Quit')]] + # Layout the rows of the form and perform a read. Indicate the form is non-blocking! + form.LayoutAndRead(form_rows, non_blocking=True) + + # + # Some place later in your code... + # You need to perform a ReadNonBlocking on your form every now and then or + # else it won't refresh + # + + for i in range(1, 1000): + output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + time.sleep(.01) + else: + form.CloseNonBlockingForm() + +What we have here is the same sequence of function calls as in the +description. Get a form, add rows to it, show the form, and then refresh +it every now and then. + +The new thing in this example is the call use of the Update method for +the Text Element. The first thing we do inside the loop is "update" the +text element that we made earlier. This changes the value of the text +field on the form. The new value will be displayed when +``form.ReadNonBlocking()`` is called. + +Note the ``else`` statement on the for loop. This is needed because +we're about to exit the loop while the form is still open. The user has +not closed the form using the X nor a button so it's up to the caller to +close the form using ``CloseNonBlockingForm``. + +That's it... this example follows the async design pattern well. + +Sample Applications +------------------- + +Use the example programs as a starting basis for your GUI. Copy, paste, +modify and run! The demo files are: + +``Demo Recipes.py`` - Sample forms for all major form types and +situations. This is the place to get your code template from. Includes +asynchronous forms, etc. + +``Demo DisplayHash1and256.py`` - Demonstrates using High Level API calls +to get a filename + +``Demo DupliucateFileFinder.py`` - Demonstrates High Level API to get a +folder & Easy Progress Meter to show progress of the file scanning + +``Demo HowDoI.py`` - An amazing little application. Acts as a front-end +to HowDoI. This one program could forever change how you code. It does +searches on Stack Overflow and returns the CODE found in the best answer +for your query. If anyone wants to help me package this application up, +I could use a hand. + +Fun Stuff +--------- + +Here are some things to try if you're bored or want to further customize + +**Colors - Random and predefined** To set a button or text to a random +color, use the string ``'random'`` as the color value. You can also call +``PySimpleGUI.GetRandomColor``. To get a random color pair call +``PySimpleGUI.GetRandomColorPair``. This returns a tuple containing a +random color and that color's compliment. + +**Debug Output** Be sure and check out the EasyPrint (Print) function +described in the high-level API section. Leave your code the way it is, +route your stdout and stderror to a scrolling window. + +For a fun time, add these lines to the top of your script + +:: + + import PySimpleGUI as sg + print = sg.Print + +This will turn all of your print statements into prints that display in +a window on your screen rather than to the terminal. + +**Look and Feel** Dial in the look and feel that you like with the +``SetOptions`` function. You can change all of the defaults in one +function call. One line of code to customize the entire GUI. + +**ObjToString** Ever wanted to easily display an objects contents +easily? Use ObjToString to get a nicely formatted recursive walk of your +objects. This statement: + +:: + + print(sg.ObjToSting(x)) + +And this was the output + +:: + + + abc = abc + attr12 = 12 + c = + b = + a = + attr1 = 1 + attr2 = 2 + attr3 = three + attr10 = 10 + attrx = x + +You'll quickly wonder how you ever coded without it. + +-------------- + +Known Issues +============ + +While not an "issue" this is a ***stern warning*** + +**Do not attempt** to call ``PySimpleGUI`` from multiple threads! It's ``tkinter`` based and ``tkinter`` has issues with multiple threads +----------------------------------------------------------------------------------------------------------------------------------------- + +**Progress Meters** - the visual graphic portion of the meter may be +off. May return to the native tkinter progress meter solution in the +future. Right now a "custom" progress meter is used. On the bright side, +the statistics shown are extremely accurate and can tell you something +about the performance of your code. + +**Async Forms** - these include the 'easy' forms (EasyProgressMeter and +EasyPrint/Print). If you start overlapping having Async forms open with +normal forms then things get a littler squirrelly. Still tracking down +the issues and am making it more solid every day possible. You'll know +there's an issue when you see blank form. + +**EasyPrint** - EasyPrint is a new feature that's pretty awesome. You +print and the output goes to a window, with a scroll bar, that you can +copy and paste from. Being a new feature, it's got some potential +problems. There are known interaction problems with other GUI windows. +For example, closing a Print window can also close other windows you +have open. For now, don't close your debug print window until other +windows are closed too. + +Contributing +------------ + +A MikeTheWatchGuy production... entirely responsible for this code.... +unless it causes you trouble in which case I'm not at all responsible. + +Versions +-------- + ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| Version | Description | ++===========+==================================================================================================================================================+ +| 1.0.9 | July 10, 2018 - Initial Release | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 1.0.21 | July 13, 2018 - Readme updates | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all\_lower\_case | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.1.1 | July 18, 2018 - Global settings exposed, fixes | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.2.0 | July 20, 2018 - Image Elements, Print output | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.6.0 | July 27, 2018 - auto\_size\_button setting. License changed to LGPL 3+ | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.6.5 | Aug XX, 2018 - window\_location default setting | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + +Release Notes +~~~~~~~~~~~~~ + +2.3 - Sliders, Listbox's and Image elements (oh my!) + +If using Progress Meters, avoid cancelling them when you have another +window open. It could lead to future windows being blank. It's being +worked on. + +New debug printing capability. ``sg.Print`` + +2.5 Discovered issue with scroll bar on ``Output`` elements. The bar +will match size of ROW not the size of the element. Normally you never +notice this due to where on a form the ``Output`` element goes. + +Listboxes are still without scrollwheels. The mouse can drag to see more +items. The mouse scrollwheel will also scroll the list and will +``page up`` and ``page down`` keys. + +Upcoming +~~~~~~~~ + +Make suggestions people! Future release features + +Columns. How multiple columns would be specified in the SDK interface +are still being designed. + +Port to other graphic engines. Hook up the front-end interface to a +backend other than tkinter. Qt, WxPython, etc. + +Code Condition +-------------- + +:: + + Make it run + Make it right + Make it fast + +It's a recipe for success if done right. PySimpleGUI has completed the +"Make it run" phase. It's far from "right" in many ways. These are being +worked on. The module is particularly poor for PEP 8 compliance. It was +a learning exercise that turned into a somewhat complete GUI solution +for lightweight problems. + +While the internals to PySimpleGUI are a tad sketchy, the public +interfaces into the SDK are more strictly defined and comply with PEP 8 +for the most part. + +Please log bugs and suggestions in the GitHub! It will only make the +code stronger and better in the end, a good thing for us all, right? + +Design +------ + +A moment about the design-spirit of ``PySimpleGUI``. From the beginning, +this package was meant to take advantage of Python's capabilities with +the goal of programming ease. + +**Single File** While not the best programming practice, the +implementation resulted in a single file solution. Only one file is +needed, PySimpleGUI.py. You can post this file, email it, and easily +import it using one statement. + +**Functions as objects** In Python, functions behave just like object. +When you're placing a Text Element into your form, you may be sometimes +calling a function and other times declaring an object. If you use the +word Text, then you're getting an object. If you're using ``Txt``, then +you're calling a function that returns a ``Text`` object. + +**Lists** It seemed quite natural to use Python's powerful list +constructs when possible. The form is specified as a series of lists. +Each "row" of the GUI is represented as a list of Elements. When the +form read returns the results to the user, all of the results are +presented as a single list. This makes reading a form's values +super-simple to do in a single line of Python code. + +Authors +------- + +MikeTheWatchGuy + +License +------- + +GNU Lesser General Public License (LGPL 3) + + +Acknowledgments +--------------- + +- Jorj McKie was the motivator behind the entire project. His + wxsimpleGUI concepts sparked PySimpleGUI into existence +- `Fredrik Lundh `__ for his + work on ``tkinter`` + +How Do I +-------- + +Finally, I must thank the fine folks at How Do I. +https://github.com/gleitz/howdoi Their utility has forever changed the +way and pace in which I can program. I urge you to try the HowDoI.py +application here on GitHub. Trust me, **it's going to be worth the +effort!** Here are the steps to run that application + +:: + + Install howdoi: + pip install howdoi + Test your install: + python -m howdoi howdoi.py + To run it: + Python HowDoI.py + +The pip command is all there is to the setup. + +The way HowDoI works is that it uses your search term to look through +stack overflow posts. It finds the best answer, gets the code from the +answer, and presents it as a response. It gives you the correct answer +OFTEN. It's a miracle that it work SO well. For Python questions, I +simply start my query with 'Python'. Let's say you forgot how to reverse +a list in Python. When you run HowDoI and ask this question, this is +what you'll see. |snap0109| + +In the hands of a competent programmer, this tool is **amazing**. It's a +must-try kind of program that has completely changed my programming +process. I'm not afraid of asking for help! You just have to be smart +about using what you find. + +The PySimpleGUI window that the results are shown in is an 'input' field +which means you can copy and paste the results right into your code. + +.. |Downloads| image:: http://pepy.tech/badge/pysimplegui + :target: http://pepy.tech/project/pysimplegui +.. |snap0125| image:: https://user-images.githubusercontent.com/13696193/43114979-a696189e-8ecf-11e8-83c7-473fcf0ccc66.jpg +.. |results 2| image:: https://user-images.githubusercontent.com/13696193/43097502-44e3ed32-8e8a-11e8-9a51-2b8af0b1a682.jpg +.. |snap0155| image:: https://user-images.githubusercontent.com/13696193/43273879-a9fdc10a-90cb-11e8-8c20-4f6a244ebe2f.jpg +.. |snap0109| image:: https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg From e5b7fd4fc2b65269b17265aa45502d359e19c02d Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 2 Aug 2018 22:21:32 -0400 Subject: [PATCH 090/209] remove docs --- Docs/readme.rst | 1174 ----------------------------------------------- 1 file changed, 1174 deletions(-) delete mode 100644 Docs/readme.rst diff --git a/Docs/readme.rst b/Docs/readme.rst deleted file mode 100644 index d7260a069..000000000 --- a/Docs/readme.rst +++ /dev/null @@ -1,1174 +0,0 @@ -.. figure:: https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png - :alt: pysimplegui\_logo - - pysimplegui\_logo -|Downloads| since Jul 11, 2018 # PySimpleGUI (Ver 2.7) - -Super-simple GUI to grasp... Powerfully customizable. - -Note - *Python3* is required to run PySimpleGUI. It takes advantage of -some Python3 features that do not translate well into Python2. - -Looking to take your Python code from the world of command lines and -into the convenience of a GUI? Have a Raspberry Pi with a touchscreen -that's going to waste because you don't have the time to learn a GUI -SDK? Look no further, you've found your GUI package. - -:: - - import PySimpleGUI as sg - - sg.MsgBox('Hello From PySimpleGUI!', 'This is the shortest GUI program ever!') - -.. figure:: https://user-images.githubusercontent.com/13696193/43162494-33095ece-8f59-11e8-86de-b6d8bcc5a52f.jpg - :alt: snap0136 - - snap0136 -Build beautiful customized forms that fit your specific problem. Let -PySimpleGUI solve your GUI problem while you solve the real problems. Do -you really want to plod through the mountains of code required to -program tkinter? - -.. figure:: https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg - :alt: snap0156 - - snap0156 -Perhaps you're looking for a way to interact with your Raspberry Pi in a -more friendly way. The is the same form as above, except shown on a Pi. - -.. figure:: https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg - :alt: raspberry pi - - raspberry pi -In addition to a primary GUI, you can add a Progress Meter to your code -with ONE LINE of code. Slide this into any of your ``for`` loops and get -a nice meter like this: - -:: - - EasyProgressMeter('My meter title', current_value, max value) - -.. figure:: https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg - :alt: progress meter 2 - - progress meter 2 -You can build an async media player GUI with custom buttons in 30 lines -of code. - -.. figure:: https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg - :alt: media file player - - media file player -I was frustrated by having to deal with the dos prompt when I had a -powerful Windows machine right in front of me. Why is it SO difficult to -do even the simplest of input/output to a window in Python?? - -There are a number of 'easy to use' Python GUIs, but they're **very** -limiting. PySimpleGUI takes the best of packages like ``EasyGUI``\ and -``WxSimpleGUI`` , both really handy but limited. The primary difference -between these and PySimpleGUI is that in addition to getting the simple -Message Boxes you also get the ability to make your own forms that are -highly customizeable. Don't like the standard Message Box? Then make -your own! - -Every call has optional parameters so that you can change the look and -feel. Don't like the button color? It's easy to change by adding a -button\_color parameter to your widget. - -GUI Packages with more functionality, like QT and WxPython, require -configuring and can take a ***week*** to get *reasonably familiar* with -the interfaces. Clearly there needs to be a middle ground between forms -with 1 or two input fields and a full-blown GUI. You'll be making your -own custom forms with PySimpleGUI within minutes, even Async forms. - -With a simple GUI, it becomes practical to "associate" .py files with -the python interpreter on Windows. Double click a py file and up pops a -GUI window, a more pleasant experience than opening a dos Window and -typing a command line. - -The ``PySimpleGUI`` package is focused on the ***developer***. How can -the desired result be achieved in as little and as simple code as -possible? This was the mantra used to create PySimpleGUI. How can it be -done is a Python-like way? - -:: - - Features of PySimpleGUI include: - Text - Single Line Input - Buttons including these types: - File Browse - Folder Browse - Non-closing return - Close form - Realtime - Checkboxes - Radio Buttons - Listbox - Slider - Icons - Multi-line Text Input - Scroll-able Output - Images - Progress Bar - Async/Non-Blocking Windows - Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling window - 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) - Single-Line-Of-Coide Proress Bar & Debug Print - Complete control of colors, look and feel - Button images - -An example of many widgets used on a single form. A little further down -you'll find the TWENTY lines of code required to create this complex -form. Try it if you don't believe it. Start Python, copy and paste the -code below into the >>> prompt and hit enter. This will pop up... - -.. figure:: https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg - :alt: everything example - - everything example -Here is the code that produced the above screenshot. - -:: - - import PySimpleGUI as SG - - with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: - layout = [ - [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [SG.Text('Here is some text.... and a place to enter text')], - [SG.InputText()], - [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], - [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], - [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', - scale=(2, 10))], - [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [SG.Text('_' * 100, size=(70, 1))], - [SG.Text('Choose Source and Destination Folders', size=(35, 1))], - [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], - [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), - SG.FolderBrowse()], - [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] - ] - - button, values = form.LayoutAndRead(layout) - -**A note on screen shots** You will see a number of different styles of -buttons, data entry fields, etc, in this readme. They were all made with -the same SDK, the only difference is in the settings that are specified -on a per-element, row, form, or global basis. One setting in particular, -border\_width, can make a big difference on the look of the form. Some -of the screenshots had a border\_width of 6, others a value of 1. - -APIs ----- - -PySimpleGUI can be broken down into 2 types of API's: \* High Level -single call functions \* Custom form functions - -Python Language Features -~~~~~~~~~~~~~~~~~~~~~~~~ - -There are a couple of Python language features that PySimpleGUI utilizes -heavily that should be understood first... \* Variable number of -arguments to a function call \* Optional parameters to a function call - -Variable Number of Arguments -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The "High Level" API calls that *output* values take a variable number -of arguments so that they match a "print" statement as much as possible. -The idea is to make it simple for the programmer to output as many items -as desired and in any format. The user need not convert the variables to -be output into the strings. The PySimpleGUI functions do that for the -user. - -:: - - SG.MsgBox('Variable number of parameters example', var1, var2, "etc") - -Each new item begins on a new line in the Message Box - -.. figure:: https://user-images.githubusercontent.com/13696193/42844739-ebea22ac-89e1-11e8-8dd1-e61441325701.jpg - :alt: snap0104 - - snap0104 -Optional Parameters to a Function Call -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -This feature of the Python language is utilized ***heavily*** as a -method of customizing forms and form Elements. Rather than requiring the -programmer to specify every possible option for a widget, instead only -the options the caller wants to override are specified. - -Here is the function definition for the MsgBox function. The details -aren't important. What is important is seeing that there is a long list -of potential tweaks that a caller can make. However, they don't *have* -to be specified on each and every call. - -:: - - def MsgBox(*args, - button_color=None, - button_type=MSG_BOX_OK, - auto_close=False, - auto_close_duration=None, - icon=DEFAULT_WINDOW_ICON, - line_width=MESSAGE_BOX_LINE_WIDTH, - font=None): - -If the caller wanted to change the button color to be black on yellow, -the call would look something like this: - -:: - - SG.MsgBox('This box has a custom button color', - button_color=('black', 'yellow')) - -.. figure:: https://user-images.githubusercontent.com/13696193/42844830-2d7e8b9a-89e2-11e8-8ef4-5af9e36f30f3.jpg - :alt: snap0105 - - snap0105 - --------------- - -High Level API Calls -~~~~~~~~~~~~~~~~~~~~ - -The classic "input a value, print result" example. Often command line -programs simply take some value as input on the command line, do -something with it and then display the results. Moving from the command -line to a GUI is very simple. This code prompts user to input a line of -text and then displays that text in a messages box: - -:: - - import PySimpleGUI_local as SG - - rc = SG.GetTextBox('Title', 'Please input something') - SG.MsgBox('Results', 'The value returned from GetTextBox', rc) - -.. figure:: https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg - :alt: GetTextBox - - GetTextBox -.. figure:: https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg - :alt: MsgBox - - MsgBox -Message Boxes -^^^^^^^^^^^^^ - -In addition to MsgBox, you'll find a several API calls that are -shortcuts to common messages boxes. You can achieve similar results by -calling MsgBox with the correct parameters. - -The differences tend to be the number and types of buttons. Here are the -calls and the windows that are created. - -:: - - import PySimpleGUI as SG - -``SG.MsgBoxOK('This is an OK MsgBox')`` - -.. figure:: https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg - :alt: msgboxok - - msgboxok -:: - - SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') - -.. figure:: https://user-images.githubusercontent.com/13696193/42599858-8e8eff22-852e-11e8-8d5c-3fe99237eb7f.jpg - :alt: msgboxokcancel - - msgboxokcancel -:: - - SG.MsgBoxCancel('This is a Cancel MsgBox') - -.. figure:: https://user-images.githubusercontent.com/13696193/42599857-8e53dc4e-852e-11e8-8e83-6a8cccf8e706.jpg - :alt: msgboxcancel - - msgboxcancel -:: - - SG.MsgBoxYesNo('This is a Yes No MsgBox') - -.. figure:: https://user-images.githubusercontent.com/13696193/42599856-8e304540-852e-11e8-975d-fb2b62e94300.jpg - :alt: msgboxyesno - - msgboxyesno -:: - - SG.MsgBoxError('This is an error MsgBox') - -.. figure:: https://user-images.githubusercontent.com/13696193/42599853-8df8e078-852e-11e8-90dc-7815d69bff7e.jpg - :alt: msgbox error - - msgbox error -:: - - SG.MsgBoxAutoClose('This is an autoclose MsgBox') - -.. figure:: https://user-images.githubusercontent.com/13696193/42599855-8e147572-852e-11e8-8c23-7ec771909062.jpg - :alt: msgbox autoclose - - msgbox autoclose -:: - - SG.ScrolledTextBox(my_text, height=10) - -.. figure:: https://user-images.githubusercontent.com/13696193/42600800-a44f4562-8531-11e8-8c21-51dd70316879.jpg - :alt: scrolledtextbox - - scrolledtextbox -Take a moment to look at that last one. It's such a simple API call and -yet the result is awesome. Rather than seeing text scrolling past on -your display, you can capture that text and present it in a scrolled -interface. It's handy enough of an API call that it can also be called -using the name ``sprint`` which is easier to remember than -``ScrollectTextBox``. Your code could contain a line like: - -:: - - sprint(f'My variables values include x={x}', f'y={y}') - -This becomes a debug print of sorts that will route to a scrolled -window. - -High Level User Input -^^^^^^^^^^^^^^^^^^^^^ - -There are 3 very basic user input high-level function calls. It's -expected that for most applications, a custom input form will be -created. If you need only 1 value, then perhaps one of these high level -functions will work. - GetTextBox - GetFileBox - GetFolderBox - -``submit_clicked, value = SG.GetTextBox('Title', 'Please enter anything')`` - -.. figure:: https://user-images.githubusercontent.com/13696193/42600399-1ef66a5e-8530-11e8-9bc4-78ea839213cd.jpg - :alt: gettextbox - - gettextbox -:: - - submit_clicked, value = SG.GetFileBox('Title', 'Choose a file') - -.. figure:: https://user-images.githubusercontent.com/13696193/42600398-1ed8a122-8530-11e8-9f74-88b101efcea4.jpg - :alt: getfilebox - - getfilebox -:: - - submit_clicked, value = SG.GetPathBox('Title', 'Choose a folder') - -.. figure:: https://user-images.githubusercontent.com/13696193/42600397-1ea7cef8-8530-11e8-8d43-e1000c0933cd.jpg - :alt: getfolderbox - - getfolderbox -Progress Meter! -^^^^^^^^^^^^^^^ - -We all have loops in our code. 'Isn't it joyful waiting, watching a -counter scrolling past in a text window? How about one line of code to -get a progress meter, that contains statistics about your code? - -.. figure:: https://user-images.githubusercontent.com/13696193/42696332-dca3ca6e-8685-11e8-846b-6bee8362ee5f.jpg - :alt: progress meter 3 - - progress meter 3 -:: - - EasyProgressMeter(title, - current_value, - max_value, - *args, - orientation=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, - button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), - border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): - -Here's the one-line Progress Meter in action! - -:: - - for i in range(1,10000): - SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') - -That line of code resulted in this window popping up and updating. - -.. figure:: https://user-images.githubusercontent.com/13696193/42696912-a5c958b8-8687-11e8-9a7d-a390a465407a.jpg - :alt: progress meter 5 - - progress meter 5 -A meter AND fun statistics to watch while your machine grinds away, all -for the price of 1 line of code. With a little trickery you can provide -a way to break out of your loop using the Progress Meter form. The -cancel button results in a ``False`` return value from -``EasyProgressMeter``. It normally returns ``True``. - -:: - - if not SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message'): - break - -***Be sure and add one to your loop counter*** so that your counter goes -from 1 to the max value. If you do not add one, your counter will never -hit the max value. Instead it will go from 0 to max-1. #### Debug Output -Another call in the 'Easy' families of APIs is ``EasyPrint``. It will -output to a debug window. If the debug window isn't open, then the first -call will open it. No need to do anything but stick a 'print' call in -your code. You can even replace your 'print' calls with calls to -EasyPrint by simply sticking the statement - -:: - - print = SG.EasyPrint - -at the top of your code. There are a number of names for the same -EasyPrint function. ``Print`` is one of the better ones to use as it's -easy to remember. It is simply ``print`` with a capital P. - -:: - - import PySimpleGUI as SG - - for i in range(100): - SG.Print(i) - -|snap0125| Or if you didn't want to change your code: - -:: - - import PySimpleGUI as SG - - print=SG.Print - for i in range(100): - print(i) - -Just like the standard print call, ``EasyPrint`` supports the ``sep`` -and ``end`` keyword arguments. Other names that can be used to call -``EasyPrint`` include Print, ``eprint``, If you want to close the -window, call the function ``EasyPrintClose``. - -A word of caution. There are known problems when multiple PySimpleGUI -windows are opened, particularly if the user closes them in an unusual -way. Not a reason to stay away from using it. Just something to keep in -mind if you encounter a problem. - -You can change the size of the debug window using the ``SetOptions`` -call with the ``debug_win_size`` parameter. - -All Widgets / Elements ----------------------- - -This code utilizes as many of the elements in one form as possible. - -:: - - with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: - layout = [ - [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [SG.Text('Here is some text.... and a place to enter text')], - [SG.InputText()], - [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], - [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], - [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', - scale=(2, 10))], - [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [SG.Text('_' * 100, size=(70, 1))], - [SG.Text('Choose Source and Destination Folders', size=(35, 1))], - [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], - [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), - SG.FolderBrowse()], - [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] - ] - - button, values = form.LayoutAndRead(layout) - -This is a somewhat complex form with quite a bit of custom sizing to -make things line up well. This is code you only have to write once. When -looking at the code, remember that what you're seeing is a list of -lists. Each row contains a list of Graphical Elements that are used to -create the form. - -.. figure:: https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg - :alt: everything example - - everything example -Clicking the Submit button caused the form call to return. The call to -MsgBox resulted in this dialog box. |results 2| - -**``Note, button value can be None``**. The value for ``button`` will be -the text that is displayed on the button element when it was created. If -the user closed the form using something other than a button, then -``button`` will be ``None``. - -You can see in the MsgBox that the values returned are a list. Each -input field in the form generates one item in the return values list. -All input fields return a ``string`` except for Check Boxes and Radio -Buttons. These return ``bool``. - -ProgressBar -^^^^^^^^^^^ - -The ``ProgressBar`` element is used to build custom Progress Bar forms. -It is HIGHLY recommended that you use the functions that provide a -complete progress meter solution for you. Progress Meters are not easy -to work with because the forms have to be non-blocking and they are -tricky to debug. - -The **easiest** way to get progress meters into your code is to use the -``EasyProgessMeter`` API. This consists of a pair of functions, -``EasyProgessMeter`` and ``EasyProgressMeterCancel``. You can easily -cancel any progress meter by calling it with the current value = max -value. This will mark the meter as expired and close the window. You've -already seen EasyProgressMeter calls presented earlier in this readme. - -:: - - SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') - -The return value for ``EasyProgressMeter`` is: ``True`` if meter updated -correctly ``False`` if user clicked the Cancel button, closed the form, -or vale reached the max value. **Customized Progress Bar** If you want a -bit more customization of your meter, then you can go up 1 level and use -the calls to ``ProgressMeter`` and ``ProgressMeterUpdate``. These APIs -behave like an object we're all used to. First you create the -``ProgressMeter`` object, then you call the ``Update`` method to update -it. - -You setup the progress meter by calling - -:: - - my_meter = ProgressMeter(title, - max_value, - *args, - orientantion=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, - button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), - border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) - -Then to update the bar within your loop - -:: - - return_code = ProgressMeterUpdate(my_meter, - value, - *args): - -Putting it all together you get this design pattern - -:: - - my_meter = SG.ProgressMeter('Meter Title', 100000, orentation='Vert') - - for i in range(0, 100000): - SG.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') - -The final way of using a Progress Meter with PySimpleGUI is to build a -custom form with a ``ProgressBar`` Element in the form. You will need to -run your form as a non-blocking form. When you are ready to update your -progress bar, you call the ``UpdateBar`` method for the ``ProgressBar`` -element itself. - -Output -^^^^^^ - -The Output Element is a re-direction of Stdout. Anything "printed" will -be displayed in this element. - -:: - - Output(scale=(None, None), - size=(None, None)) - -Here's a complete solution for a chat-window using an Async form with an -Output Element - -:: - - import PySimpleGUI as SG - # Blocking form that doesn't close - def ChatBot(): - with SG.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: - layout = [[(SG.Text('This is where standard out is being routed', size=[40, 1]))], - [SG.Output(size=(80, 20))], - [SG.Multiline(size=(70, 5), enter_submits=True), SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))]] - # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form - # if you call LayoutAndRead from here, then you will miss the first button click - form.Layout(layout) - # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # - while True: - button, value = form.Read() - if button == 'SEND': - print(value) - else: - break - -Tabbed Forms ------------- - -Tabbed forms are shown using the ``ShowTabbedForm`` call. The call has -the format - -:: - - results = ShowTabbedForm('Title for the form', - (form,layout,'Tab 1 label'), - (form2,layout2, 'Tab 2 label'), ...) - -Each of the tabs of the form is in fact a form. The same steps are taken -to create the form as before. A ``FlexForm`` is created, then rows are -filled with Elements, and finally the form is shown. When calling -``ShowTabbedForm``, each form is passed in as a tuple. The tuple has the -format: ``(the form, the rows, a string shown on the tab)`` - -Results are returned as a list of lists. For each form you'll get a list -that's in the same format as a normal form. A single tab's values would -be: - -:: - - (button, (values)) - -Recall that values is a list as well. Multiple tabs in the form would -return like this: - -:: - - ((button1, (values1)), (button2, (values2)) - -## Colors ## Starting in version 2.5 you can change the background -colors for the window and the Elements. - -Your forms can go from this: |snap0155| - -to this... with one function call... - -.. figure:: https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg - :alt: snap0156 - - snap0156 -While you can do it on an element by element or form level basis, the -easiest way, by far, is a call to ``SetOptions``. - -Be aware that once you change these options they are changed for the -rest of your program's execution. All of your forms will have that look -and feel, until you change it to something else (which could be the -system default colors. - -This call sets all of the different color options. - -:: - - SetOptions(background_color='#9FB8AD', - text_element_background_color='#9FB8AD', - element_background_color='#9FB8AD', - scrollbar_color=None, - input_elements_background_color='#F7F3EC', - progress_meter_color = ('green', 'blue') - button_color=('white','#475841')) - -Global Settings ---------------- - -**Global Settings** Let's have some fun customizing! Make PySimpleGUI -look the way you want it to look. You can set the global settings using -the function ``PySimpleGUI.SetOptions``. Each option has an optional -parameter that's used to set it. - -:: - - SetOptions(icon=None - button_color=(None,None) - element_size=(None,None), - margins=(None,None), - element_padding=(None,None) - auto_size_text=None - auto_size_buttons=None - font=None - border_width=None - slider_border_width=None - slider_relief=None - slider_orientation=None - autoclose_time=None - message_box_line_width=None - progress_meter_border_depth=None - progress_meter_style=None - progress_meter_relief=None - progress_meter_color=None - progress_meter_size=None - text_justification=None - background_color=None - element_background_color=None - text_element_background_color=None - input_elements_background_color=None - scrollbar_color=None, text_color=None - debug_win_size=(None,None) - window_location=(None,None) - -Explanation of parameters - -:: - - icon - filename of icon used for taskbar and title bar - button_color - button color (foreground, background) - element_size - element size (width, height) in characters - margins - tkinter margins around outsize - element_padding - tkinter padding around each element - auto_size_text - autosize the elements to fit their text - auto_size_buttons - autosize the buttons to fit their text - font - font used for elements - border_width - amount of bezel or border around sunken or raised elements - slider_border_width - changes the way sliders look - slider_relief - changes the way sliders look - slider_orientation - changes orientation of slider - autoclose_time - time in seconds for autoclose boxes - message_box_line_width - number of characers in a line of text in message boxes - progress_meter_border_depth - amount of border around raised or lowered progress meters - progress_meter_style - style of progress meter as defined by tkinter - progress_meter_relief - relief style - progress_meter_color - color of the bar and background of progress meters - progress_meter_size - size in (characters, pixels) - background_color - Color of the main window's background - element_background_color - Background color of the elements - text_element_background_color - Text element background color - input_elements_background_color - Input fields background color - scrollbar_color - Color for scrollbars (may not always work) - text_color - Text element default text color - text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' - debug_win_size - size of the Print output window - window_location - location on the screen (x,y) of window's top left cornder - -These settings apply to all forms ``SetOptions``. The Row options and -Element options will take precedence over these settings. Settings can -be thought of as levels of settings with the Form-level being the -highest and the Element-level the lowest. Thus the levels are: - -- Form level -- Row level -- Element level - -Each lower level overrides the settings of the higher level. Once -settings have been changed, they remain changed for the duration of the -program (unless changed again). - -Asynchronous (Non-Blocking) Forms ---------------------------------- - -So you want to be a wizard do ya? Well go boldly! While the majority of -GUIs are a simple exercise to "collect input values and return with -them", there are instances where we want to continue executing while the -form is open. These are "asynchronous" forms and require special -options, new SDK calls, and **great care**. With asynchronous forms the -form is shown, user input is read, but your code keeps right on -chugging. YOUR responsibility is to call ``PySimpleGUI.ReadNonBlocking`` -on a periodic basis. Once a second or more will produce a reasonably -snappy GUI. - -When do you use a non-blocking form? A couple of examples are \* A media -file player like an MP3 player \* A status dashboard that's periodically -updated \* Progress Meters - when you want to make your own progress -meters \* Output using print to a scrolled text element. Good for -debugging. - -Word of warning... version 2.2, the currently released, and upcoming -version 2.3 differ in the return code for the ``ReadNonBlocking`` call. -Previously the function returned 2 values, except when the form is -closed using the "X" which returned a single value of ``None``. The -*new* way is that ``ReadNonBlocking`` always returns 2 values. If the -user closed the form with the "X" then the return values will be None, -None. You will want to key off the second value to catch this case. The -proper code to check if the user has exited the form will be a -polling-loop that looks something like this: - -:: - - while True: - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': - break - -We're going to build an app that does the latter. It's going to update -our form with a running clock. - -The basic flow and functions you will be calling are: Setup - -:: - - form = FlexForm() - form_rows = ..... - form.LayoutAndRead(form_rows, non_blocking=True) - -Periodic refresh - -:: - - form.ReadNonBlocking() - -If you need to close the form - -:: - - form.CloseNonBlockingForm() - -Rather than the usual ``form.LayoutAndRead()`` call, we're manually -adding the rows (doing the layout) and then showing the form. After the -form is shown, you simply call ``form.ReadNonBlocking()`` every now and -then. - -When you are ready to close the form (assuming the form wasn't closed by -the user or a button click) you simply call -``form.CloseNonBlockingForm()`` - -**Example - Running timer that updates** See the sample code on the -GitHub named Demo Media Player for another example of Async Forms. We're -going to make a form and update one of the elements of that form every -.01 seconds. Here's the entire code to do that. - -:: - - import PySimpleGUI as sg - import time - - # form that doesn't block - # Make a form, but don't use context manager - form = sg.FlexForm('Running Timer', auto_size_text=True) - # Create a text element that will be updated with status information on the GUI itself - output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) - # Create the rows - form_rows = [[sg.Text('Non-blocking GUI with updates')], - [output_element], - [sg.SimpleButton('Quit')]] - # Layout the rows of the form and perform a read. Indicate the form is non-blocking! - form.LayoutAndRead(form_rows, non_blocking=True) - - # - # Some place later in your code... - # You need to perform a ReadNonBlocking on your form every now and then or - # else it won't refresh - # - - for i in range(1, 1000): - output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': - break - time.sleep(.01) - else: - form.CloseNonBlockingForm() - -What we have here is the same sequence of function calls as in the -description. Get a form, add rows to it, show the form, and then refresh -it every now and then. - -The new thing in this example is the call use of the Update method for -the Text Element. The first thing we do inside the loop is "update" the -text element that we made earlier. This changes the value of the text -field on the form. The new value will be displayed when -``form.ReadNonBlocking()`` is called. - -Note the ``else`` statement on the for loop. This is needed because -we're about to exit the loop while the form is still open. The user has -not closed the form using the X nor a button so it's up to the caller to -close the form using ``CloseNonBlockingForm``. - -That's it... this example follows the async design pattern well. - -Sample Applications -------------------- - -Use the example programs as a starting basis for your GUI. Copy, paste, -modify and run! The demo files are: - -``Demo Recipes.py`` - Sample forms for all major form types and -situations. This is the place to get your code template from. Includes -asynchronous forms, etc. - -``Demo DisplayHash1and256.py`` - Demonstrates using High Level API calls -to get a filename - -``Demo DupliucateFileFinder.py`` - Demonstrates High Level API to get a -folder & Easy Progress Meter to show progress of the file scanning - -``Demo HowDoI.py`` - An amazing little application. Acts as a front-end -to HowDoI. This one program could forever change how you code. It does -searches on Stack Overflow and returns the CODE found in the best answer -for your query. If anyone wants to help me package this application up, -I could use a hand. - -Fun Stuff ---------- - -Here are some things to try if you're bored or want to further customize - -**Colors - Random and predefined** To set a button or text to a random -color, use the string ``'random'`` as the color value. You can also call -``PySimpleGUI.GetRandomColor``. To get a random color pair call -``PySimpleGUI.GetRandomColorPair``. This returns a tuple containing a -random color and that color's compliment. - -**Debug Output** Be sure and check out the EasyPrint (Print) function -described in the high-level API section. Leave your code the way it is, -route your stdout and stderror to a scrolling window. - -For a fun time, add these lines to the top of your script - -:: - - import PySimpleGUI as sg - print = sg.Print - -This will turn all of your print statements into prints that display in -a window on your screen rather than to the terminal. - -**Look and Feel** Dial in the look and feel that you like with the -``SetOptions`` function. You can change all of the defaults in one -function call. One line of code to customize the entire GUI. - -**ObjToString** Ever wanted to easily display an objects contents -easily? Use ObjToString to get a nicely formatted recursive walk of your -objects. This statement: - -:: - - print(sg.ObjToSting(x)) - -And this was the output - -:: - - - abc = abc - attr12 = 12 - c = - b = - a = - attr1 = 1 - attr2 = 2 - attr3 = three - attr10 = 10 - attrx = x - -You'll quickly wonder how you ever coded without it. - --------------- - -Known Issues -============ - -While not an "issue" this is a ***stern warning*** - -**Do not attempt** to call ``PySimpleGUI`` from multiple threads! It's ``tkinter`` based and ``tkinter`` has issues with multiple threads ------------------------------------------------------------------------------------------------------------------------------------------ - -**Progress Meters** - the visual graphic portion of the meter may be -off. May return to the native tkinter progress meter solution in the -future. Right now a "custom" progress meter is used. On the bright side, -the statistics shown are extremely accurate and can tell you something -about the performance of your code. - -**Async Forms** - these include the 'easy' forms (EasyProgressMeter and -EasyPrint/Print). If you start overlapping having Async forms open with -normal forms then things get a littler squirrelly. Still tracking down -the issues and am making it more solid every day possible. You'll know -there's an issue when you see blank form. - -**EasyPrint** - EasyPrint is a new feature that's pretty awesome. You -print and the output goes to a window, with a scroll bar, that you can -copy and paste from. Being a new feature, it's got some potential -problems. There are known interaction problems with other GUI windows. -For example, closing a Print window can also close other windows you -have open. For now, don't close your debug print window until other -windows are closed too. - -Contributing ------------- - -A MikeTheWatchGuy production... entirely responsible for this code.... -unless it causes you trouble in which case I'm not at all responsible. - -Versions --------- - -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| Version | Description | -+===========+==================================================================================================================================================+ -| 1.0.9 | July 10, 2018 - Initial Release | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1.0.21 | July 13, 2018 - Readme updates | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all\_lower\_case | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.1.1 | July 18, 2018 - Global settings exposed, fixes | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.2.0 | July 20, 2018 - Image Elements, Print output | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.6.0 | July 27, 2018 - auto\_size\_button setting. License changed to LGPL 3+ | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.6.5 | Aug XX, 2018 - window\_location default setting | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ - -Release Notes -~~~~~~~~~~~~~ - -2.3 - Sliders, Listbox's and Image elements (oh my!) - -If using Progress Meters, avoid cancelling them when you have another -window open. It could lead to future windows being blank. It's being -worked on. - -New debug printing capability. ``sg.Print`` - -2.5 Discovered issue with scroll bar on ``Output`` elements. The bar -will match size of ROW not the size of the element. Normally you never -notice this due to where on a form the ``Output`` element goes. - -Listboxes are still without scrollwheels. The mouse can drag to see more -items. The mouse scrollwheel will also scroll the list and will -``page up`` and ``page down`` keys. - -Upcoming -~~~~~~~~ - -Make suggestions people! Future release features - -Columns. How multiple columns would be specified in the SDK interface -are still being designed. - -Port to other graphic engines. Hook up the front-end interface to a -backend other than tkinter. Qt, WxPython, etc. - -Code Condition --------------- - -:: - - Make it run - Make it right - Make it fast - -It's a recipe for success if done right. PySimpleGUI has completed the -"Make it run" phase. It's far from "right" in many ways. These are being -worked on. The module is particularly poor for PEP 8 compliance. It was -a learning exercise that turned into a somewhat complete GUI solution -for lightweight problems. - -While the internals to PySimpleGUI are a tad sketchy, the public -interfaces into the SDK are more strictly defined and comply with PEP 8 -for the most part. - -Please log bugs and suggestions in the GitHub! It will only make the -code stronger and better in the end, a good thing for us all, right? - -Design ------- - -A moment about the design-spirit of ``PySimpleGUI``. From the beginning, -this package was meant to take advantage of Python's capabilities with -the goal of programming ease. - -**Single File** While not the best programming practice, the -implementation resulted in a single file solution. Only one file is -needed, PySimpleGUI.py. You can post this file, email it, and easily -import it using one statement. - -**Functions as objects** In Python, functions behave just like object. -When you're placing a Text Element into your form, you may be sometimes -calling a function and other times declaring an object. If you use the -word Text, then you're getting an object. If you're using ``Txt``, then -you're calling a function that returns a ``Text`` object. - -**Lists** It seemed quite natural to use Python's powerful list -constructs when possible. The form is specified as a series of lists. -Each "row" of the GUI is represented as a list of Elements. When the -form read returns the results to the user, all of the results are -presented as a single list. This makes reading a form's values -super-simple to do in a single line of Python code. - -Authors -------- - -MikeTheWatchGuy - -License -------- - -GNU Lesser General Public License (LGPL 3) + - -Acknowledgments ---------------- - -- Jorj McKie was the motivator behind the entire project. His - wxsimpleGUI concepts sparked PySimpleGUI into existence -- `Fredrik Lundh `__ for his - work on ``tkinter`` - -How Do I --------- - -Finally, I must thank the fine folks at How Do I. -https://github.com/gleitz/howdoi Their utility has forever changed the -way and pace in which I can program. I urge you to try the HowDoI.py -application here on GitHub. Trust me, **it's going to be worth the -effort!** Here are the steps to run that application - -:: - - Install howdoi: - pip install howdoi - Test your install: - python -m howdoi howdoi.py - To run it: - Python HowDoI.py - -The pip command is all there is to the setup. - -The way HowDoI works is that it uses your search term to look through -stack overflow posts. It finds the best answer, gets the code from the -answer, and presents it as a response. It gives you the correct answer -OFTEN. It's a miracle that it work SO well. For Python questions, I -simply start my query with 'Python'. Let's say you forgot how to reverse -a list in Python. When you run HowDoI and ask this question, this is -what you'll see. |snap0109| - -In the hands of a competent programmer, this tool is **amazing**. It's a -must-try kind of program that has completely changed my programming -process. I'm not afraid of asking for help! You just have to be smart -about using what you find. - -The PySimpleGUI window that the results are shown in is an 'input' field -which means you can copy and paste the results right into your code. - -.. |Downloads| image:: http://pepy.tech/badge/pysimplegui - :target: http://pepy.tech/project/pysimplegui -.. |snap0125| image:: https://user-images.githubusercontent.com/13696193/43114979-a696189e-8ecf-11e8-83c7-473fcf0ccc66.jpg -.. |results 2| image:: https://user-images.githubusercontent.com/13696193/43097502-44e3ed32-8e8a-11e8-9a51-2b8af0b1a682.jpg -.. |snap0155| image:: https://user-images.githubusercontent.com/13696193/43273879-a9fdc10a-90cb-11e8-8c20-4f6a244ebe2f.jpg -.. |snap0109| image:: https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg From 8cba6a865f40c157b1e7a1e59074de02e9e55fb8 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 2 Aug 2018 22:22:32 -0400 Subject: [PATCH 091/209] readme.rst addition --- docs/readme.rst | 1174 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1174 insertions(+) create mode 100644 docs/readme.rst diff --git a/docs/readme.rst b/docs/readme.rst new file mode 100644 index 000000000..d7260a069 --- /dev/null +++ b/docs/readme.rst @@ -0,0 +1,1174 @@ +.. figure:: https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png + :alt: pysimplegui\_logo + + pysimplegui\_logo +|Downloads| since Jul 11, 2018 # PySimpleGUI (Ver 2.7) + +Super-simple GUI to grasp... Powerfully customizable. + +Note - *Python3* is required to run PySimpleGUI. It takes advantage of +some Python3 features that do not translate well into Python2. + +Looking to take your Python code from the world of command lines and +into the convenience of a GUI? Have a Raspberry Pi with a touchscreen +that's going to waste because you don't have the time to learn a GUI +SDK? Look no further, you've found your GUI package. + +:: + + import PySimpleGUI as sg + + sg.MsgBox('Hello From PySimpleGUI!', 'This is the shortest GUI program ever!') + +.. figure:: https://user-images.githubusercontent.com/13696193/43162494-33095ece-8f59-11e8-86de-b6d8bcc5a52f.jpg + :alt: snap0136 + + snap0136 +Build beautiful customized forms that fit your specific problem. Let +PySimpleGUI solve your GUI problem while you solve the real problems. Do +you really want to plod through the mountains of code required to +program tkinter? + +.. figure:: https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg + :alt: snap0156 + + snap0156 +Perhaps you're looking for a way to interact with your Raspberry Pi in a +more friendly way. The is the same form as above, except shown on a Pi. + +.. figure:: https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg + :alt: raspberry pi + + raspberry pi +In addition to a primary GUI, you can add a Progress Meter to your code +with ONE LINE of code. Slide this into any of your ``for`` loops and get +a nice meter like this: + +:: + + EasyProgressMeter('My meter title', current_value, max value) + +.. figure:: https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg + :alt: progress meter 2 + + progress meter 2 +You can build an async media player GUI with custom buttons in 30 lines +of code. + +.. figure:: https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg + :alt: media file player + + media file player +I was frustrated by having to deal with the dos prompt when I had a +powerful Windows machine right in front of me. Why is it SO difficult to +do even the simplest of input/output to a window in Python?? + +There are a number of 'easy to use' Python GUIs, but they're **very** +limiting. PySimpleGUI takes the best of packages like ``EasyGUI``\ and +``WxSimpleGUI`` , both really handy but limited. The primary difference +between these and PySimpleGUI is that in addition to getting the simple +Message Boxes you also get the ability to make your own forms that are +highly customizeable. Don't like the standard Message Box? Then make +your own! + +Every call has optional parameters so that you can change the look and +feel. Don't like the button color? It's easy to change by adding a +button\_color parameter to your widget. + +GUI Packages with more functionality, like QT and WxPython, require +configuring and can take a ***week*** to get *reasonably familiar* with +the interfaces. Clearly there needs to be a middle ground between forms +with 1 or two input fields and a full-blown GUI. You'll be making your +own custom forms with PySimpleGUI within minutes, even Async forms. + +With a simple GUI, it becomes practical to "associate" .py files with +the python interpreter on Windows. Double click a py file and up pops a +GUI window, a more pleasant experience than opening a dos Window and +typing a command line. + +The ``PySimpleGUI`` package is focused on the ***developer***. How can +the desired result be achieved in as little and as simple code as +possible? This was the mantra used to create PySimpleGUI. How can it be +done is a Python-like way? + +:: + + Features of PySimpleGUI include: + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Realtime + Checkboxes + Radio Buttons + Listbox + Slider + Icons + Multi-line Text Input + Scroll-able Output + Images + Progress Bar + Async/Non-Blocking Windows + Tabbed forms + Persistent Windows + Redirect Python Output/Errors to scrolling window + 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + Single-Line-Of-Coide Proress Bar & Debug Print + Complete control of colors, look and feel + Button images + +An example of many widgets used on a single form. A little further down +you'll find the TWENTY lines of code required to create this complex +form. Try it if you don't believe it. Start Python, copy and paste the +code below into the >>> prompt and hit enter. This will pop up... + +.. figure:: https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg + :alt: everything example + + everything example +Here is the code that produced the above screenshot. + +:: + + import PySimpleGUI as SG + + with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [SG.Text('Here is some text.... and a place to enter text')], + [SG.InputText()], + [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], + [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], + [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [SG.Text('_' * 100, size=(70, 1))], + [SG.Text('Choose Source and Destination Folders', size=(35, 1))], + [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], + [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), + SG.FolderBrowse()], + [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + +**A note on screen shots** You will see a number of different styles of +buttons, data entry fields, etc, in this readme. They were all made with +the same SDK, the only difference is in the settings that are specified +on a per-element, row, form, or global basis. One setting in particular, +border\_width, can make a big difference on the look of the form. Some +of the screenshots had a border\_width of 6, others a value of 1. + +APIs +---- + +PySimpleGUI can be broken down into 2 types of API's: \* High Level +single call functions \* Custom form functions + +Python Language Features +~~~~~~~~~~~~~~~~~~~~~~~~ + +There are a couple of Python language features that PySimpleGUI utilizes +heavily that should be understood first... \* Variable number of +arguments to a function call \* Optional parameters to a function call + +Variable Number of Arguments +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The "High Level" API calls that *output* values take a variable number +of arguments so that they match a "print" statement as much as possible. +The idea is to make it simple for the programmer to output as many items +as desired and in any format. The user need not convert the variables to +be output into the strings. The PySimpleGUI functions do that for the +user. + +:: + + SG.MsgBox('Variable number of parameters example', var1, var2, "etc") + +Each new item begins on a new line in the Message Box + +.. figure:: https://user-images.githubusercontent.com/13696193/42844739-ebea22ac-89e1-11e8-8dd1-e61441325701.jpg + :alt: snap0104 + + snap0104 +Optional Parameters to a Function Call +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This feature of the Python language is utilized ***heavily*** as a +method of customizing forms and form Elements. Rather than requiring the +programmer to specify every possible option for a widget, instead only +the options the caller wants to override are specified. + +Here is the function definition for the MsgBox function. The details +aren't important. What is important is seeing that there is a long list +of potential tweaks that a caller can make. However, they don't *have* +to be specified on each and every call. + +:: + + def MsgBox(*args, + button_color=None, + button_type=MSG_BOX_OK, + auto_close=False, + auto_close_duration=None, + icon=DEFAULT_WINDOW_ICON, + line_width=MESSAGE_BOX_LINE_WIDTH, + font=None): + +If the caller wanted to change the button color to be black on yellow, +the call would look something like this: + +:: + + SG.MsgBox('This box has a custom button color', + button_color=('black', 'yellow')) + +.. figure:: https://user-images.githubusercontent.com/13696193/42844830-2d7e8b9a-89e2-11e8-8ef4-5af9e36f30f3.jpg + :alt: snap0105 + + snap0105 + +-------------- + +High Level API Calls +~~~~~~~~~~~~~~~~~~~~ + +The classic "input a value, print result" example. Often command line +programs simply take some value as input on the command line, do +something with it and then display the results. Moving from the command +line to a GUI is very simple. This code prompts user to input a line of +text and then displays that text in a messages box: + +:: + + import PySimpleGUI_local as SG + + rc = SG.GetTextBox('Title', 'Please input something') + SG.MsgBox('Results', 'The value returned from GetTextBox', rc) + +.. figure:: https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg + :alt: GetTextBox + + GetTextBox +.. figure:: https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg + :alt: MsgBox + + MsgBox +Message Boxes +^^^^^^^^^^^^^ + +In addition to MsgBox, you'll find a several API calls that are +shortcuts to common messages boxes. You can achieve similar results by +calling MsgBox with the correct parameters. + +The differences tend to be the number and types of buttons. Here are the +calls and the windows that are created. + +:: + + import PySimpleGUI as SG + +``SG.MsgBoxOK('This is an OK MsgBox')`` + +.. figure:: https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg + :alt: msgboxok + + msgboxok +:: + + SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') + +.. figure:: https://user-images.githubusercontent.com/13696193/42599858-8e8eff22-852e-11e8-8d5c-3fe99237eb7f.jpg + :alt: msgboxokcancel + + msgboxokcancel +:: + + SG.MsgBoxCancel('This is a Cancel MsgBox') + +.. figure:: https://user-images.githubusercontent.com/13696193/42599857-8e53dc4e-852e-11e8-8e83-6a8cccf8e706.jpg + :alt: msgboxcancel + + msgboxcancel +:: + + SG.MsgBoxYesNo('This is a Yes No MsgBox') + +.. figure:: https://user-images.githubusercontent.com/13696193/42599856-8e304540-852e-11e8-975d-fb2b62e94300.jpg + :alt: msgboxyesno + + msgboxyesno +:: + + SG.MsgBoxError('This is an error MsgBox') + +.. figure:: https://user-images.githubusercontent.com/13696193/42599853-8df8e078-852e-11e8-90dc-7815d69bff7e.jpg + :alt: msgbox error + + msgbox error +:: + + SG.MsgBoxAutoClose('This is an autoclose MsgBox') + +.. figure:: https://user-images.githubusercontent.com/13696193/42599855-8e147572-852e-11e8-8c23-7ec771909062.jpg + :alt: msgbox autoclose + + msgbox autoclose +:: + + SG.ScrolledTextBox(my_text, height=10) + +.. figure:: https://user-images.githubusercontent.com/13696193/42600800-a44f4562-8531-11e8-8c21-51dd70316879.jpg + :alt: scrolledtextbox + + scrolledtextbox +Take a moment to look at that last one. It's such a simple API call and +yet the result is awesome. Rather than seeing text scrolling past on +your display, you can capture that text and present it in a scrolled +interface. It's handy enough of an API call that it can also be called +using the name ``sprint`` which is easier to remember than +``ScrollectTextBox``. Your code could contain a line like: + +:: + + sprint(f'My variables values include x={x}', f'y={y}') + +This becomes a debug print of sorts that will route to a scrolled +window. + +High Level User Input +^^^^^^^^^^^^^^^^^^^^^ + +There are 3 very basic user input high-level function calls. It's +expected that for most applications, a custom input form will be +created. If you need only 1 value, then perhaps one of these high level +functions will work. - GetTextBox - GetFileBox - GetFolderBox + +``submit_clicked, value = SG.GetTextBox('Title', 'Please enter anything')`` + +.. figure:: https://user-images.githubusercontent.com/13696193/42600399-1ef66a5e-8530-11e8-9bc4-78ea839213cd.jpg + :alt: gettextbox + + gettextbox +:: + + submit_clicked, value = SG.GetFileBox('Title', 'Choose a file') + +.. figure:: https://user-images.githubusercontent.com/13696193/42600398-1ed8a122-8530-11e8-9f74-88b101efcea4.jpg + :alt: getfilebox + + getfilebox +:: + + submit_clicked, value = SG.GetPathBox('Title', 'Choose a folder') + +.. figure:: https://user-images.githubusercontent.com/13696193/42600397-1ea7cef8-8530-11e8-8d43-e1000c0933cd.jpg + :alt: getfolderbox + + getfolderbox +Progress Meter! +^^^^^^^^^^^^^^^ + +We all have loops in our code. 'Isn't it joyful waiting, watching a +counter scrolling past in a text window? How about one line of code to +get a progress meter, that contains statistics about your code? + +.. figure:: https://user-images.githubusercontent.com/13696193/42696332-dca3ca6e-8685-11e8-846b-6bee8362ee5f.jpg + :alt: progress meter 3 + + progress meter 3 +:: + + EasyProgressMeter(title, + current_value, + max_value, + *args, + orientation=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): + +Here's the one-line Progress Meter in action! + +:: + + for i in range(1,10000): + SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') + +That line of code resulted in this window popping up and updating. + +.. figure:: https://user-images.githubusercontent.com/13696193/42696912-a5c958b8-8687-11e8-9a7d-a390a465407a.jpg + :alt: progress meter 5 + + progress meter 5 +A meter AND fun statistics to watch while your machine grinds away, all +for the price of 1 line of code. With a little trickery you can provide +a way to break out of your loop using the Progress Meter form. The +cancel button results in a ``False`` return value from +``EasyProgressMeter``. It normally returns ``True``. + +:: + + if not SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message'): + break + +***Be sure and add one to your loop counter*** so that your counter goes +from 1 to the max value. If you do not add one, your counter will never +hit the max value. Instead it will go from 0 to max-1. #### Debug Output +Another call in the 'Easy' families of APIs is ``EasyPrint``. It will +output to a debug window. If the debug window isn't open, then the first +call will open it. No need to do anything but stick a 'print' call in +your code. You can even replace your 'print' calls with calls to +EasyPrint by simply sticking the statement + +:: + + print = SG.EasyPrint + +at the top of your code. There are a number of names for the same +EasyPrint function. ``Print`` is one of the better ones to use as it's +easy to remember. It is simply ``print`` with a capital P. + +:: + + import PySimpleGUI as SG + + for i in range(100): + SG.Print(i) + +|snap0125| Or if you didn't want to change your code: + +:: + + import PySimpleGUI as SG + + print=SG.Print + for i in range(100): + print(i) + +Just like the standard print call, ``EasyPrint`` supports the ``sep`` +and ``end`` keyword arguments. Other names that can be used to call +``EasyPrint`` include Print, ``eprint``, If you want to close the +window, call the function ``EasyPrintClose``. + +A word of caution. There are known problems when multiple PySimpleGUI +windows are opened, particularly if the user closes them in an unusual +way. Not a reason to stay away from using it. Just something to keep in +mind if you encounter a problem. + +You can change the size of the debug window using the ``SetOptions`` +call with the ``debug_win_size`` parameter. + +All Widgets / Elements +---------------------- + +This code utilizes as many of the elements in one form as possible. + +:: + + with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [SG.Text('Here is some text.... and a place to enter text')], + [SG.InputText()], + [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], + [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], + [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [SG.Text('_' * 100, size=(70, 1))], + [SG.Text('Choose Source and Destination Folders', size=(35, 1))], + [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], + [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), + SG.FolderBrowse()], + [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + +This is a somewhat complex form with quite a bit of custom sizing to +make things line up well. This is code you only have to write once. When +looking at the code, remember that what you're seeing is a list of +lists. Each row contains a list of Graphical Elements that are used to +create the form. + +.. figure:: https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg + :alt: everything example + + everything example +Clicking the Submit button caused the form call to return. The call to +MsgBox resulted in this dialog box. |results 2| + +**``Note, button value can be None``**. The value for ``button`` will be +the text that is displayed on the button element when it was created. If +the user closed the form using something other than a button, then +``button`` will be ``None``. + +You can see in the MsgBox that the values returned are a list. Each +input field in the form generates one item in the return values list. +All input fields return a ``string`` except for Check Boxes and Radio +Buttons. These return ``bool``. + +ProgressBar +^^^^^^^^^^^ + +The ``ProgressBar`` element is used to build custom Progress Bar forms. +It is HIGHLY recommended that you use the functions that provide a +complete progress meter solution for you. Progress Meters are not easy +to work with because the forms have to be non-blocking and they are +tricky to debug. + +The **easiest** way to get progress meters into your code is to use the +``EasyProgessMeter`` API. This consists of a pair of functions, +``EasyProgessMeter`` and ``EasyProgressMeterCancel``. You can easily +cancel any progress meter by calling it with the current value = max +value. This will mark the meter as expired and close the window. You've +already seen EasyProgressMeter calls presented earlier in this readme. + +:: + + SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') + +The return value for ``EasyProgressMeter`` is: ``True`` if meter updated +correctly ``False`` if user clicked the Cancel button, closed the form, +or vale reached the max value. **Customized Progress Bar** If you want a +bit more customization of your meter, then you can go up 1 level and use +the calls to ``ProgressMeter`` and ``ProgressMeterUpdate``. These APIs +behave like an object we're all used to. First you create the +``ProgressMeter`` object, then you call the ``Update`` method to update +it. + +You setup the progress meter by calling + +:: + + my_meter = ProgressMeter(title, + max_value, + *args, + orientantion=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) + +Then to update the bar within your loop + +:: + + return_code = ProgressMeterUpdate(my_meter, + value, + *args): + +Putting it all together you get this design pattern + +:: + + my_meter = SG.ProgressMeter('Meter Title', 100000, orentation='Vert') + + for i in range(0, 100000): + SG.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') + +The final way of using a Progress Meter with PySimpleGUI is to build a +custom form with a ``ProgressBar`` Element in the form. You will need to +run your form as a non-blocking form. When you are ready to update your +progress bar, you call the ``UpdateBar`` method for the ``ProgressBar`` +element itself. + +Output +^^^^^^ + +The Output Element is a re-direction of Stdout. Anything "printed" will +be displayed in this element. + +:: + + Output(scale=(None, None), + size=(None, None)) + +Here's a complete solution for a chat-window using an Async form with an +Output Element + +:: + + import PySimpleGUI as SG + # Blocking form that doesn't close + def ChatBot(): + with SG.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + layout = [[(SG.Text('This is where standard out is being routed', size=[40, 1]))], + [SG.Output(size=(80, 20))], + [SG.Multiline(size=(70, 5), enter_submits=True), SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))]] + # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form + # if you call LayoutAndRead from here, then you will miss the first button click + form.Layout(layout) + # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # + while True: + button, value = form.Read() + if button == 'SEND': + print(value) + else: + break + +Tabbed Forms +------------ + +Tabbed forms are shown using the ``ShowTabbedForm`` call. The call has +the format + +:: + + results = ShowTabbedForm('Title for the form', + (form,layout,'Tab 1 label'), + (form2,layout2, 'Tab 2 label'), ...) + +Each of the tabs of the form is in fact a form. The same steps are taken +to create the form as before. A ``FlexForm`` is created, then rows are +filled with Elements, and finally the form is shown. When calling +``ShowTabbedForm``, each form is passed in as a tuple. The tuple has the +format: ``(the form, the rows, a string shown on the tab)`` + +Results are returned as a list of lists. For each form you'll get a list +that's in the same format as a normal form. A single tab's values would +be: + +:: + + (button, (values)) + +Recall that values is a list as well. Multiple tabs in the form would +return like this: + +:: + + ((button1, (values1)), (button2, (values2)) + +## Colors ## Starting in version 2.5 you can change the background +colors for the window and the Elements. + +Your forms can go from this: |snap0155| + +to this... with one function call... + +.. figure:: https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg + :alt: snap0156 + + snap0156 +While you can do it on an element by element or form level basis, the +easiest way, by far, is a call to ``SetOptions``. + +Be aware that once you change these options they are changed for the +rest of your program's execution. All of your forms will have that look +and feel, until you change it to something else (which could be the +system default colors. + +This call sets all of the different color options. + +:: + + SetOptions(background_color='#9FB8AD', + text_element_background_color='#9FB8AD', + element_background_color='#9FB8AD', + scrollbar_color=None, + input_elements_background_color='#F7F3EC', + progress_meter_color = ('green', 'blue') + button_color=('white','#475841')) + +Global Settings +--------------- + +**Global Settings** Let's have some fun customizing! Make PySimpleGUI +look the way you want it to look. You can set the global settings using +the function ``PySimpleGUI.SetOptions``. Each option has an optional +parameter that's used to set it. + +:: + + SetOptions(icon=None + button_color=(None,None) + element_size=(None,None), + margins=(None,None), + element_padding=(None,None) + auto_size_text=None + auto_size_buttons=None + font=None + border_width=None + slider_border_width=None + slider_relief=None + slider_orientation=None + autoclose_time=None + message_box_line_width=None + progress_meter_border_depth=None + progress_meter_style=None + progress_meter_relief=None + progress_meter_color=None + progress_meter_size=None + text_justification=None + background_color=None + element_background_color=None + text_element_background_color=None + input_elements_background_color=None + scrollbar_color=None, text_color=None + debug_win_size=(None,None) + window_location=(None,None) + +Explanation of parameters + +:: + + icon - filename of icon used for taskbar and title bar + button_color - button color (foreground, background) + element_size - element size (width, height) in characters + margins - tkinter margins around outsize + element_padding - tkinter padding around each element + auto_size_text - autosize the elements to fit their text + auto_size_buttons - autosize the buttons to fit their text + font - font used for elements + border_width - amount of bezel or border around sunken or raised elements + slider_border_width - changes the way sliders look + slider_relief - changes the way sliders look + slider_orientation - changes orientation of slider + autoclose_time - time in seconds for autoclose boxes + message_box_line_width - number of characers in a line of text in message boxes + progress_meter_border_depth - amount of border around raised or lowered progress meters + progress_meter_style - style of progress meter as defined by tkinter + progress_meter_relief - relief style + progress_meter_color - color of the bar and background of progress meters + progress_meter_size - size in (characters, pixels) + background_color - Color of the main window's background + element_background_color - Background color of the elements + text_element_background_color - Text element background color + input_elements_background_color - Input fields background color + scrollbar_color - Color for scrollbars (may not always work) + text_color - Text element default text color + text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' + debug_win_size - size of the Print output window + window_location - location on the screen (x,y) of window's top left cornder + +These settings apply to all forms ``SetOptions``. The Row options and +Element options will take precedence over these settings. Settings can +be thought of as levels of settings with the Form-level being the +highest and the Element-level the lowest. Thus the levels are: + +- Form level +- Row level +- Element level + +Each lower level overrides the settings of the higher level. Once +settings have been changed, they remain changed for the duration of the +program (unless changed again). + +Asynchronous (Non-Blocking) Forms +--------------------------------- + +So you want to be a wizard do ya? Well go boldly! While the majority of +GUIs are a simple exercise to "collect input values and return with +them", there are instances where we want to continue executing while the +form is open. These are "asynchronous" forms and require special +options, new SDK calls, and **great care**. With asynchronous forms the +form is shown, user input is read, but your code keeps right on +chugging. YOUR responsibility is to call ``PySimpleGUI.ReadNonBlocking`` +on a periodic basis. Once a second or more will produce a reasonably +snappy GUI. + +When do you use a non-blocking form? A couple of examples are \* A media +file player like an MP3 player \* A status dashboard that's periodically +updated \* Progress Meters - when you want to make your own progress +meters \* Output using print to a scrolled text element. Good for +debugging. + +Word of warning... version 2.2, the currently released, and upcoming +version 2.3 differ in the return code for the ``ReadNonBlocking`` call. +Previously the function returned 2 values, except when the form is +closed using the "X" which returned a single value of ``None``. The +*new* way is that ``ReadNonBlocking`` always returns 2 values. If the +user closed the form with the "X" then the return values will be None, +None. You will want to key off the second value to catch this case. The +proper code to check if the user has exited the form will be a +polling-loop that looks something like this: + +:: + + while True: + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + +We're going to build an app that does the latter. It's going to update +our form with a running clock. + +The basic flow and functions you will be calling are: Setup + +:: + + form = FlexForm() + form_rows = ..... + form.LayoutAndRead(form_rows, non_blocking=True) + +Periodic refresh + +:: + + form.ReadNonBlocking() + +If you need to close the form + +:: + + form.CloseNonBlockingForm() + +Rather than the usual ``form.LayoutAndRead()`` call, we're manually +adding the rows (doing the layout) and then showing the form. After the +form is shown, you simply call ``form.ReadNonBlocking()`` every now and +then. + +When you are ready to close the form (assuming the form wasn't closed by +the user or a button click) you simply call +``form.CloseNonBlockingForm()`` + +**Example - Running timer that updates** See the sample code on the +GitHub named Demo Media Player for another example of Async Forms. We're +going to make a form and update one of the elements of that form every +.01 seconds. Here's the entire code to do that. + +:: + + import PySimpleGUI as sg + import time + + # form that doesn't block + # Make a form, but don't use context manager + form = sg.FlexForm('Running Timer', auto_size_text=True) + # Create a text element that will be updated with status information on the GUI itself + output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) + # Create the rows + form_rows = [[sg.Text('Non-blocking GUI with updates')], + [output_element], + [sg.SimpleButton('Quit')]] + # Layout the rows of the form and perform a read. Indicate the form is non-blocking! + form.LayoutAndRead(form_rows, non_blocking=True) + + # + # Some place later in your code... + # You need to perform a ReadNonBlocking on your form every now and then or + # else it won't refresh + # + + for i in range(1, 1000): + output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + time.sleep(.01) + else: + form.CloseNonBlockingForm() + +What we have here is the same sequence of function calls as in the +description. Get a form, add rows to it, show the form, and then refresh +it every now and then. + +The new thing in this example is the call use of the Update method for +the Text Element. The first thing we do inside the loop is "update" the +text element that we made earlier. This changes the value of the text +field on the form. The new value will be displayed when +``form.ReadNonBlocking()`` is called. + +Note the ``else`` statement on the for loop. This is needed because +we're about to exit the loop while the form is still open. The user has +not closed the form using the X nor a button so it's up to the caller to +close the form using ``CloseNonBlockingForm``. + +That's it... this example follows the async design pattern well. + +Sample Applications +------------------- + +Use the example programs as a starting basis for your GUI. Copy, paste, +modify and run! The demo files are: + +``Demo Recipes.py`` - Sample forms for all major form types and +situations. This is the place to get your code template from. Includes +asynchronous forms, etc. + +``Demo DisplayHash1and256.py`` - Demonstrates using High Level API calls +to get a filename + +``Demo DupliucateFileFinder.py`` - Demonstrates High Level API to get a +folder & Easy Progress Meter to show progress of the file scanning + +``Demo HowDoI.py`` - An amazing little application. Acts as a front-end +to HowDoI. This one program could forever change how you code. It does +searches on Stack Overflow and returns the CODE found in the best answer +for your query. If anyone wants to help me package this application up, +I could use a hand. + +Fun Stuff +--------- + +Here are some things to try if you're bored or want to further customize + +**Colors - Random and predefined** To set a button or text to a random +color, use the string ``'random'`` as the color value. You can also call +``PySimpleGUI.GetRandomColor``. To get a random color pair call +``PySimpleGUI.GetRandomColorPair``. This returns a tuple containing a +random color and that color's compliment. + +**Debug Output** Be sure and check out the EasyPrint (Print) function +described in the high-level API section. Leave your code the way it is, +route your stdout and stderror to a scrolling window. + +For a fun time, add these lines to the top of your script + +:: + + import PySimpleGUI as sg + print = sg.Print + +This will turn all of your print statements into prints that display in +a window on your screen rather than to the terminal. + +**Look and Feel** Dial in the look and feel that you like with the +``SetOptions`` function. You can change all of the defaults in one +function call. One line of code to customize the entire GUI. + +**ObjToString** Ever wanted to easily display an objects contents +easily? Use ObjToString to get a nicely formatted recursive walk of your +objects. This statement: + +:: + + print(sg.ObjToSting(x)) + +And this was the output + +:: + + + abc = abc + attr12 = 12 + c = + b = + a = + attr1 = 1 + attr2 = 2 + attr3 = three + attr10 = 10 + attrx = x + +You'll quickly wonder how you ever coded without it. + +-------------- + +Known Issues +============ + +While not an "issue" this is a ***stern warning*** + +**Do not attempt** to call ``PySimpleGUI`` from multiple threads! It's ``tkinter`` based and ``tkinter`` has issues with multiple threads +----------------------------------------------------------------------------------------------------------------------------------------- + +**Progress Meters** - the visual graphic portion of the meter may be +off. May return to the native tkinter progress meter solution in the +future. Right now a "custom" progress meter is used. On the bright side, +the statistics shown are extremely accurate and can tell you something +about the performance of your code. + +**Async Forms** - these include the 'easy' forms (EasyProgressMeter and +EasyPrint/Print). If you start overlapping having Async forms open with +normal forms then things get a littler squirrelly. Still tracking down +the issues and am making it more solid every day possible. You'll know +there's an issue when you see blank form. + +**EasyPrint** - EasyPrint is a new feature that's pretty awesome. You +print and the output goes to a window, with a scroll bar, that you can +copy and paste from. Being a new feature, it's got some potential +problems. There are known interaction problems with other GUI windows. +For example, closing a Print window can also close other windows you +have open. For now, don't close your debug print window until other +windows are closed too. + +Contributing +------------ + +A MikeTheWatchGuy production... entirely responsible for this code.... +unless it causes you trouble in which case I'm not at all responsible. + +Versions +-------- + ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| Version | Description | ++===========+==================================================================================================================================================+ +| 1.0.9 | July 10, 2018 - Initial Release | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 1.0.21 | July 13, 2018 - Readme updates | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all\_lower\_case | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.1.1 | July 18, 2018 - Global settings exposed, fixes | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.2.0 | July 20, 2018 - Image Elements, Print output | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.6.0 | July 27, 2018 - auto\_size\_button setting. License changed to LGPL 3+ | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.6.5 | Aug XX, 2018 - window\_location default setting | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + +Release Notes +~~~~~~~~~~~~~ + +2.3 - Sliders, Listbox's and Image elements (oh my!) + +If using Progress Meters, avoid cancelling them when you have another +window open. It could lead to future windows being blank. It's being +worked on. + +New debug printing capability. ``sg.Print`` + +2.5 Discovered issue with scroll bar on ``Output`` elements. The bar +will match size of ROW not the size of the element. Normally you never +notice this due to where on a form the ``Output`` element goes. + +Listboxes are still without scrollwheels. The mouse can drag to see more +items. The mouse scrollwheel will also scroll the list and will +``page up`` and ``page down`` keys. + +Upcoming +~~~~~~~~ + +Make suggestions people! Future release features + +Columns. How multiple columns would be specified in the SDK interface +are still being designed. + +Port to other graphic engines. Hook up the front-end interface to a +backend other than tkinter. Qt, WxPython, etc. + +Code Condition +-------------- + +:: + + Make it run + Make it right + Make it fast + +It's a recipe for success if done right. PySimpleGUI has completed the +"Make it run" phase. It's far from "right" in many ways. These are being +worked on. The module is particularly poor for PEP 8 compliance. It was +a learning exercise that turned into a somewhat complete GUI solution +for lightweight problems. + +While the internals to PySimpleGUI are a tad sketchy, the public +interfaces into the SDK are more strictly defined and comply with PEP 8 +for the most part. + +Please log bugs and suggestions in the GitHub! It will only make the +code stronger and better in the end, a good thing for us all, right? + +Design +------ + +A moment about the design-spirit of ``PySimpleGUI``. From the beginning, +this package was meant to take advantage of Python's capabilities with +the goal of programming ease. + +**Single File** While not the best programming practice, the +implementation resulted in a single file solution. Only one file is +needed, PySimpleGUI.py. You can post this file, email it, and easily +import it using one statement. + +**Functions as objects** In Python, functions behave just like object. +When you're placing a Text Element into your form, you may be sometimes +calling a function and other times declaring an object. If you use the +word Text, then you're getting an object. If you're using ``Txt``, then +you're calling a function that returns a ``Text`` object. + +**Lists** It seemed quite natural to use Python's powerful list +constructs when possible. The form is specified as a series of lists. +Each "row" of the GUI is represented as a list of Elements. When the +form read returns the results to the user, all of the results are +presented as a single list. This makes reading a form's values +super-simple to do in a single line of Python code. + +Authors +------- + +MikeTheWatchGuy + +License +------- + +GNU Lesser General Public License (LGPL 3) + + +Acknowledgments +--------------- + +- Jorj McKie was the motivator behind the entire project. His + wxsimpleGUI concepts sparked PySimpleGUI into existence +- `Fredrik Lundh `__ for his + work on ``tkinter`` + +How Do I +-------- + +Finally, I must thank the fine folks at How Do I. +https://github.com/gleitz/howdoi Their utility has forever changed the +way and pace in which I can program. I urge you to try the HowDoI.py +application here on GitHub. Trust me, **it's going to be worth the +effort!** Here are the steps to run that application + +:: + + Install howdoi: + pip install howdoi + Test your install: + python -m howdoi howdoi.py + To run it: + Python HowDoI.py + +The pip command is all there is to the setup. + +The way HowDoI works is that it uses your search term to look through +stack overflow posts. It finds the best answer, gets the code from the +answer, and presents it as a response. It gives you the correct answer +OFTEN. It's a miracle that it work SO well. For Python questions, I +simply start my query with 'Python'. Let's say you forgot how to reverse +a list in Python. When you run HowDoI and ask this question, this is +what you'll see. |snap0109| + +In the hands of a competent programmer, this tool is **amazing**. It's a +must-try kind of program that has completely changed my programming +process. I'm not afraid of asking for help! You just have to be smart +about using what you find. + +The PySimpleGUI window that the results are shown in is an 'input' field +which means you can copy and paste the results right into your code. + +.. |Downloads| image:: http://pepy.tech/badge/pysimplegui + :target: http://pepy.tech/project/pysimplegui +.. |snap0125| image:: https://user-images.githubusercontent.com/13696193/43114979-a696189e-8ecf-11e8-83c7-473fcf0ccc66.jpg +.. |results 2| image:: https://user-images.githubusercontent.com/13696193/43097502-44e3ed32-8e8a-11e8-9a51-2b8af0b1a682.jpg +.. |snap0155| image:: https://user-images.githubusercontent.com/13696193/43273879-a9fdc10a-90cb-11e8-8c20-4f6a244ebe2f.jpg +.. |snap0109| image:: https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg From 1affeb29056aed1d4b77284dc1f982d609e1c0f6 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 2 Aug 2018 22:25:13 -0400 Subject: [PATCH 092/209] removed --- docs/readme.rst | 1174 ----------------------------------------------- 1 file changed, 1174 deletions(-) delete mode 100644 docs/readme.rst diff --git a/docs/readme.rst b/docs/readme.rst deleted file mode 100644 index d7260a069..000000000 --- a/docs/readme.rst +++ /dev/null @@ -1,1174 +0,0 @@ -.. figure:: https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png - :alt: pysimplegui\_logo - - pysimplegui\_logo -|Downloads| since Jul 11, 2018 # PySimpleGUI (Ver 2.7) - -Super-simple GUI to grasp... Powerfully customizable. - -Note - *Python3* is required to run PySimpleGUI. It takes advantage of -some Python3 features that do not translate well into Python2. - -Looking to take your Python code from the world of command lines and -into the convenience of a GUI? Have a Raspberry Pi with a touchscreen -that's going to waste because you don't have the time to learn a GUI -SDK? Look no further, you've found your GUI package. - -:: - - import PySimpleGUI as sg - - sg.MsgBox('Hello From PySimpleGUI!', 'This is the shortest GUI program ever!') - -.. figure:: https://user-images.githubusercontent.com/13696193/43162494-33095ece-8f59-11e8-86de-b6d8bcc5a52f.jpg - :alt: snap0136 - - snap0136 -Build beautiful customized forms that fit your specific problem. Let -PySimpleGUI solve your GUI problem while you solve the real problems. Do -you really want to plod through the mountains of code required to -program tkinter? - -.. figure:: https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg - :alt: snap0156 - - snap0156 -Perhaps you're looking for a way to interact with your Raspberry Pi in a -more friendly way. The is the same form as above, except shown on a Pi. - -.. figure:: https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg - :alt: raspberry pi - - raspberry pi -In addition to a primary GUI, you can add a Progress Meter to your code -with ONE LINE of code. Slide this into any of your ``for`` loops and get -a nice meter like this: - -:: - - EasyProgressMeter('My meter title', current_value, max value) - -.. figure:: https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg - :alt: progress meter 2 - - progress meter 2 -You can build an async media player GUI with custom buttons in 30 lines -of code. - -.. figure:: https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg - :alt: media file player - - media file player -I was frustrated by having to deal with the dos prompt when I had a -powerful Windows machine right in front of me. Why is it SO difficult to -do even the simplest of input/output to a window in Python?? - -There are a number of 'easy to use' Python GUIs, but they're **very** -limiting. PySimpleGUI takes the best of packages like ``EasyGUI``\ and -``WxSimpleGUI`` , both really handy but limited. The primary difference -between these and PySimpleGUI is that in addition to getting the simple -Message Boxes you also get the ability to make your own forms that are -highly customizeable. Don't like the standard Message Box? Then make -your own! - -Every call has optional parameters so that you can change the look and -feel. Don't like the button color? It's easy to change by adding a -button\_color parameter to your widget. - -GUI Packages with more functionality, like QT and WxPython, require -configuring and can take a ***week*** to get *reasonably familiar* with -the interfaces. Clearly there needs to be a middle ground between forms -with 1 or two input fields and a full-blown GUI. You'll be making your -own custom forms with PySimpleGUI within minutes, even Async forms. - -With a simple GUI, it becomes practical to "associate" .py files with -the python interpreter on Windows. Double click a py file and up pops a -GUI window, a more pleasant experience than opening a dos Window and -typing a command line. - -The ``PySimpleGUI`` package is focused on the ***developer***. How can -the desired result be achieved in as little and as simple code as -possible? This was the mantra used to create PySimpleGUI. How can it be -done is a Python-like way? - -:: - - Features of PySimpleGUI include: - Text - Single Line Input - Buttons including these types: - File Browse - Folder Browse - Non-closing return - Close form - Realtime - Checkboxes - Radio Buttons - Listbox - Slider - Icons - Multi-line Text Input - Scroll-able Output - Images - Progress Bar - Async/Non-Blocking Windows - Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling window - 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) - Single-Line-Of-Coide Proress Bar & Debug Print - Complete control of colors, look and feel - Button images - -An example of many widgets used on a single form. A little further down -you'll find the TWENTY lines of code required to create this complex -form. Try it if you don't believe it. Start Python, copy and paste the -code below into the >>> prompt and hit enter. This will pop up... - -.. figure:: https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg - :alt: everything example - - everything example -Here is the code that produced the above screenshot. - -:: - - import PySimpleGUI as SG - - with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: - layout = [ - [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [SG.Text('Here is some text.... and a place to enter text')], - [SG.InputText()], - [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], - [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], - [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', - scale=(2, 10))], - [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [SG.Text('_' * 100, size=(70, 1))], - [SG.Text('Choose Source and Destination Folders', size=(35, 1))], - [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], - [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), - SG.FolderBrowse()], - [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] - ] - - button, values = form.LayoutAndRead(layout) - -**A note on screen shots** You will see a number of different styles of -buttons, data entry fields, etc, in this readme. They were all made with -the same SDK, the only difference is in the settings that are specified -on a per-element, row, form, or global basis. One setting in particular, -border\_width, can make a big difference on the look of the form. Some -of the screenshots had a border\_width of 6, others a value of 1. - -APIs ----- - -PySimpleGUI can be broken down into 2 types of API's: \* High Level -single call functions \* Custom form functions - -Python Language Features -~~~~~~~~~~~~~~~~~~~~~~~~ - -There are a couple of Python language features that PySimpleGUI utilizes -heavily that should be understood first... \* Variable number of -arguments to a function call \* Optional parameters to a function call - -Variable Number of Arguments -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The "High Level" API calls that *output* values take a variable number -of arguments so that they match a "print" statement as much as possible. -The idea is to make it simple for the programmer to output as many items -as desired and in any format. The user need not convert the variables to -be output into the strings. The PySimpleGUI functions do that for the -user. - -:: - - SG.MsgBox('Variable number of parameters example', var1, var2, "etc") - -Each new item begins on a new line in the Message Box - -.. figure:: https://user-images.githubusercontent.com/13696193/42844739-ebea22ac-89e1-11e8-8dd1-e61441325701.jpg - :alt: snap0104 - - snap0104 -Optional Parameters to a Function Call -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -This feature of the Python language is utilized ***heavily*** as a -method of customizing forms and form Elements. Rather than requiring the -programmer to specify every possible option for a widget, instead only -the options the caller wants to override are specified. - -Here is the function definition for the MsgBox function. The details -aren't important. What is important is seeing that there is a long list -of potential tweaks that a caller can make. However, they don't *have* -to be specified on each and every call. - -:: - - def MsgBox(*args, - button_color=None, - button_type=MSG_BOX_OK, - auto_close=False, - auto_close_duration=None, - icon=DEFAULT_WINDOW_ICON, - line_width=MESSAGE_BOX_LINE_WIDTH, - font=None): - -If the caller wanted to change the button color to be black on yellow, -the call would look something like this: - -:: - - SG.MsgBox('This box has a custom button color', - button_color=('black', 'yellow')) - -.. figure:: https://user-images.githubusercontent.com/13696193/42844830-2d7e8b9a-89e2-11e8-8ef4-5af9e36f30f3.jpg - :alt: snap0105 - - snap0105 - --------------- - -High Level API Calls -~~~~~~~~~~~~~~~~~~~~ - -The classic "input a value, print result" example. Often command line -programs simply take some value as input on the command line, do -something with it and then display the results. Moving from the command -line to a GUI is very simple. This code prompts user to input a line of -text and then displays that text in a messages box: - -:: - - import PySimpleGUI_local as SG - - rc = SG.GetTextBox('Title', 'Please input something') - SG.MsgBox('Results', 'The value returned from GetTextBox', rc) - -.. figure:: https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg - :alt: GetTextBox - - GetTextBox -.. figure:: https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg - :alt: MsgBox - - MsgBox -Message Boxes -^^^^^^^^^^^^^ - -In addition to MsgBox, you'll find a several API calls that are -shortcuts to common messages boxes. You can achieve similar results by -calling MsgBox with the correct parameters. - -The differences tend to be the number and types of buttons. Here are the -calls and the windows that are created. - -:: - - import PySimpleGUI as SG - -``SG.MsgBoxOK('This is an OK MsgBox')`` - -.. figure:: https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg - :alt: msgboxok - - msgboxok -:: - - SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') - -.. figure:: https://user-images.githubusercontent.com/13696193/42599858-8e8eff22-852e-11e8-8d5c-3fe99237eb7f.jpg - :alt: msgboxokcancel - - msgboxokcancel -:: - - SG.MsgBoxCancel('This is a Cancel MsgBox') - -.. figure:: https://user-images.githubusercontent.com/13696193/42599857-8e53dc4e-852e-11e8-8e83-6a8cccf8e706.jpg - :alt: msgboxcancel - - msgboxcancel -:: - - SG.MsgBoxYesNo('This is a Yes No MsgBox') - -.. figure:: https://user-images.githubusercontent.com/13696193/42599856-8e304540-852e-11e8-975d-fb2b62e94300.jpg - :alt: msgboxyesno - - msgboxyesno -:: - - SG.MsgBoxError('This is an error MsgBox') - -.. figure:: https://user-images.githubusercontent.com/13696193/42599853-8df8e078-852e-11e8-90dc-7815d69bff7e.jpg - :alt: msgbox error - - msgbox error -:: - - SG.MsgBoxAutoClose('This is an autoclose MsgBox') - -.. figure:: https://user-images.githubusercontent.com/13696193/42599855-8e147572-852e-11e8-8c23-7ec771909062.jpg - :alt: msgbox autoclose - - msgbox autoclose -:: - - SG.ScrolledTextBox(my_text, height=10) - -.. figure:: https://user-images.githubusercontent.com/13696193/42600800-a44f4562-8531-11e8-8c21-51dd70316879.jpg - :alt: scrolledtextbox - - scrolledtextbox -Take a moment to look at that last one. It's such a simple API call and -yet the result is awesome. Rather than seeing text scrolling past on -your display, you can capture that text and present it in a scrolled -interface. It's handy enough of an API call that it can also be called -using the name ``sprint`` which is easier to remember than -``ScrollectTextBox``. Your code could contain a line like: - -:: - - sprint(f'My variables values include x={x}', f'y={y}') - -This becomes a debug print of sorts that will route to a scrolled -window. - -High Level User Input -^^^^^^^^^^^^^^^^^^^^^ - -There are 3 very basic user input high-level function calls. It's -expected that for most applications, a custom input form will be -created. If you need only 1 value, then perhaps one of these high level -functions will work. - GetTextBox - GetFileBox - GetFolderBox - -``submit_clicked, value = SG.GetTextBox('Title', 'Please enter anything')`` - -.. figure:: https://user-images.githubusercontent.com/13696193/42600399-1ef66a5e-8530-11e8-9bc4-78ea839213cd.jpg - :alt: gettextbox - - gettextbox -:: - - submit_clicked, value = SG.GetFileBox('Title', 'Choose a file') - -.. figure:: https://user-images.githubusercontent.com/13696193/42600398-1ed8a122-8530-11e8-9f74-88b101efcea4.jpg - :alt: getfilebox - - getfilebox -:: - - submit_clicked, value = SG.GetPathBox('Title', 'Choose a folder') - -.. figure:: https://user-images.githubusercontent.com/13696193/42600397-1ea7cef8-8530-11e8-8d43-e1000c0933cd.jpg - :alt: getfolderbox - - getfolderbox -Progress Meter! -^^^^^^^^^^^^^^^ - -We all have loops in our code. 'Isn't it joyful waiting, watching a -counter scrolling past in a text window? How about one line of code to -get a progress meter, that contains statistics about your code? - -.. figure:: https://user-images.githubusercontent.com/13696193/42696332-dca3ca6e-8685-11e8-846b-6bee8362ee5f.jpg - :alt: progress meter 3 - - progress meter 3 -:: - - EasyProgressMeter(title, - current_value, - max_value, - *args, - orientation=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, - button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), - border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): - -Here's the one-line Progress Meter in action! - -:: - - for i in range(1,10000): - SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') - -That line of code resulted in this window popping up and updating. - -.. figure:: https://user-images.githubusercontent.com/13696193/42696912-a5c958b8-8687-11e8-9a7d-a390a465407a.jpg - :alt: progress meter 5 - - progress meter 5 -A meter AND fun statistics to watch while your machine grinds away, all -for the price of 1 line of code. With a little trickery you can provide -a way to break out of your loop using the Progress Meter form. The -cancel button results in a ``False`` return value from -``EasyProgressMeter``. It normally returns ``True``. - -:: - - if not SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message'): - break - -***Be sure and add one to your loop counter*** so that your counter goes -from 1 to the max value. If you do not add one, your counter will never -hit the max value. Instead it will go from 0 to max-1. #### Debug Output -Another call in the 'Easy' families of APIs is ``EasyPrint``. It will -output to a debug window. If the debug window isn't open, then the first -call will open it. No need to do anything but stick a 'print' call in -your code. You can even replace your 'print' calls with calls to -EasyPrint by simply sticking the statement - -:: - - print = SG.EasyPrint - -at the top of your code. There are a number of names for the same -EasyPrint function. ``Print`` is one of the better ones to use as it's -easy to remember. It is simply ``print`` with a capital P. - -:: - - import PySimpleGUI as SG - - for i in range(100): - SG.Print(i) - -|snap0125| Or if you didn't want to change your code: - -:: - - import PySimpleGUI as SG - - print=SG.Print - for i in range(100): - print(i) - -Just like the standard print call, ``EasyPrint`` supports the ``sep`` -and ``end`` keyword arguments. Other names that can be used to call -``EasyPrint`` include Print, ``eprint``, If you want to close the -window, call the function ``EasyPrintClose``. - -A word of caution. There are known problems when multiple PySimpleGUI -windows are opened, particularly if the user closes them in an unusual -way. Not a reason to stay away from using it. Just something to keep in -mind if you encounter a problem. - -You can change the size of the debug window using the ``SetOptions`` -call with the ``debug_win_size`` parameter. - -All Widgets / Elements ----------------------- - -This code utilizes as many of the elements in one form as possible. - -:: - - with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: - layout = [ - [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [SG.Text('Here is some text.... and a place to enter text')], - [SG.InputText()], - [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], - [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], - [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', - scale=(2, 10))], - [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [SG.Text('_' * 100, size=(70, 1))], - [SG.Text('Choose Source and Destination Folders', size=(35, 1))], - [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], - [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), - SG.FolderBrowse()], - [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] - ] - - button, values = form.LayoutAndRead(layout) - -This is a somewhat complex form with quite a bit of custom sizing to -make things line up well. This is code you only have to write once. When -looking at the code, remember that what you're seeing is a list of -lists. Each row contains a list of Graphical Elements that are used to -create the form. - -.. figure:: https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg - :alt: everything example - - everything example -Clicking the Submit button caused the form call to return. The call to -MsgBox resulted in this dialog box. |results 2| - -**``Note, button value can be None``**. The value for ``button`` will be -the text that is displayed on the button element when it was created. If -the user closed the form using something other than a button, then -``button`` will be ``None``. - -You can see in the MsgBox that the values returned are a list. Each -input field in the form generates one item in the return values list. -All input fields return a ``string`` except for Check Boxes and Radio -Buttons. These return ``bool``. - -ProgressBar -^^^^^^^^^^^ - -The ``ProgressBar`` element is used to build custom Progress Bar forms. -It is HIGHLY recommended that you use the functions that provide a -complete progress meter solution for you. Progress Meters are not easy -to work with because the forms have to be non-blocking and they are -tricky to debug. - -The **easiest** way to get progress meters into your code is to use the -``EasyProgessMeter`` API. This consists of a pair of functions, -``EasyProgessMeter`` and ``EasyProgressMeterCancel``. You can easily -cancel any progress meter by calling it with the current value = max -value. This will mark the meter as expired and close the window. You've -already seen EasyProgressMeter calls presented earlier in this readme. - -:: - - SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') - -The return value for ``EasyProgressMeter`` is: ``True`` if meter updated -correctly ``False`` if user clicked the Cancel button, closed the form, -or vale reached the max value. **Customized Progress Bar** If you want a -bit more customization of your meter, then you can go up 1 level and use -the calls to ``ProgressMeter`` and ``ProgressMeterUpdate``. These APIs -behave like an object we're all used to. First you create the -``ProgressMeter`` object, then you call the ``Update`` method to update -it. - -You setup the progress meter by calling - -:: - - my_meter = ProgressMeter(title, - max_value, - *args, - orientantion=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, - button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), - border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) - -Then to update the bar within your loop - -:: - - return_code = ProgressMeterUpdate(my_meter, - value, - *args): - -Putting it all together you get this design pattern - -:: - - my_meter = SG.ProgressMeter('Meter Title', 100000, orentation='Vert') - - for i in range(0, 100000): - SG.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') - -The final way of using a Progress Meter with PySimpleGUI is to build a -custom form with a ``ProgressBar`` Element in the form. You will need to -run your form as a non-blocking form. When you are ready to update your -progress bar, you call the ``UpdateBar`` method for the ``ProgressBar`` -element itself. - -Output -^^^^^^ - -The Output Element is a re-direction of Stdout. Anything "printed" will -be displayed in this element. - -:: - - Output(scale=(None, None), - size=(None, None)) - -Here's a complete solution for a chat-window using an Async form with an -Output Element - -:: - - import PySimpleGUI as SG - # Blocking form that doesn't close - def ChatBot(): - with SG.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: - layout = [[(SG.Text('This is where standard out is being routed', size=[40, 1]))], - [SG.Output(size=(80, 20))], - [SG.Multiline(size=(70, 5), enter_submits=True), SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))]] - # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form - # if you call LayoutAndRead from here, then you will miss the first button click - form.Layout(layout) - # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # - while True: - button, value = form.Read() - if button == 'SEND': - print(value) - else: - break - -Tabbed Forms ------------- - -Tabbed forms are shown using the ``ShowTabbedForm`` call. The call has -the format - -:: - - results = ShowTabbedForm('Title for the form', - (form,layout,'Tab 1 label'), - (form2,layout2, 'Tab 2 label'), ...) - -Each of the tabs of the form is in fact a form. The same steps are taken -to create the form as before. A ``FlexForm`` is created, then rows are -filled with Elements, and finally the form is shown. When calling -``ShowTabbedForm``, each form is passed in as a tuple. The tuple has the -format: ``(the form, the rows, a string shown on the tab)`` - -Results are returned as a list of lists. For each form you'll get a list -that's in the same format as a normal form. A single tab's values would -be: - -:: - - (button, (values)) - -Recall that values is a list as well. Multiple tabs in the form would -return like this: - -:: - - ((button1, (values1)), (button2, (values2)) - -## Colors ## Starting in version 2.5 you can change the background -colors for the window and the Elements. - -Your forms can go from this: |snap0155| - -to this... with one function call... - -.. figure:: https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg - :alt: snap0156 - - snap0156 -While you can do it on an element by element or form level basis, the -easiest way, by far, is a call to ``SetOptions``. - -Be aware that once you change these options they are changed for the -rest of your program's execution. All of your forms will have that look -and feel, until you change it to something else (which could be the -system default colors. - -This call sets all of the different color options. - -:: - - SetOptions(background_color='#9FB8AD', - text_element_background_color='#9FB8AD', - element_background_color='#9FB8AD', - scrollbar_color=None, - input_elements_background_color='#F7F3EC', - progress_meter_color = ('green', 'blue') - button_color=('white','#475841')) - -Global Settings ---------------- - -**Global Settings** Let's have some fun customizing! Make PySimpleGUI -look the way you want it to look. You can set the global settings using -the function ``PySimpleGUI.SetOptions``. Each option has an optional -parameter that's used to set it. - -:: - - SetOptions(icon=None - button_color=(None,None) - element_size=(None,None), - margins=(None,None), - element_padding=(None,None) - auto_size_text=None - auto_size_buttons=None - font=None - border_width=None - slider_border_width=None - slider_relief=None - slider_orientation=None - autoclose_time=None - message_box_line_width=None - progress_meter_border_depth=None - progress_meter_style=None - progress_meter_relief=None - progress_meter_color=None - progress_meter_size=None - text_justification=None - background_color=None - element_background_color=None - text_element_background_color=None - input_elements_background_color=None - scrollbar_color=None, text_color=None - debug_win_size=(None,None) - window_location=(None,None) - -Explanation of parameters - -:: - - icon - filename of icon used for taskbar and title bar - button_color - button color (foreground, background) - element_size - element size (width, height) in characters - margins - tkinter margins around outsize - element_padding - tkinter padding around each element - auto_size_text - autosize the elements to fit their text - auto_size_buttons - autosize the buttons to fit their text - font - font used for elements - border_width - amount of bezel or border around sunken or raised elements - slider_border_width - changes the way sliders look - slider_relief - changes the way sliders look - slider_orientation - changes orientation of slider - autoclose_time - time in seconds for autoclose boxes - message_box_line_width - number of characers in a line of text in message boxes - progress_meter_border_depth - amount of border around raised or lowered progress meters - progress_meter_style - style of progress meter as defined by tkinter - progress_meter_relief - relief style - progress_meter_color - color of the bar and background of progress meters - progress_meter_size - size in (characters, pixels) - background_color - Color of the main window's background - element_background_color - Background color of the elements - text_element_background_color - Text element background color - input_elements_background_color - Input fields background color - scrollbar_color - Color for scrollbars (may not always work) - text_color - Text element default text color - text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' - debug_win_size - size of the Print output window - window_location - location on the screen (x,y) of window's top left cornder - -These settings apply to all forms ``SetOptions``. The Row options and -Element options will take precedence over these settings. Settings can -be thought of as levels of settings with the Form-level being the -highest and the Element-level the lowest. Thus the levels are: - -- Form level -- Row level -- Element level - -Each lower level overrides the settings of the higher level. Once -settings have been changed, they remain changed for the duration of the -program (unless changed again). - -Asynchronous (Non-Blocking) Forms ---------------------------------- - -So you want to be a wizard do ya? Well go boldly! While the majority of -GUIs are a simple exercise to "collect input values and return with -them", there are instances where we want to continue executing while the -form is open. These are "asynchronous" forms and require special -options, new SDK calls, and **great care**. With asynchronous forms the -form is shown, user input is read, but your code keeps right on -chugging. YOUR responsibility is to call ``PySimpleGUI.ReadNonBlocking`` -on a periodic basis. Once a second or more will produce a reasonably -snappy GUI. - -When do you use a non-blocking form? A couple of examples are \* A media -file player like an MP3 player \* A status dashboard that's periodically -updated \* Progress Meters - when you want to make your own progress -meters \* Output using print to a scrolled text element. Good for -debugging. - -Word of warning... version 2.2, the currently released, and upcoming -version 2.3 differ in the return code for the ``ReadNonBlocking`` call. -Previously the function returned 2 values, except when the form is -closed using the "X" which returned a single value of ``None``. The -*new* way is that ``ReadNonBlocking`` always returns 2 values. If the -user closed the form with the "X" then the return values will be None, -None. You will want to key off the second value to catch this case. The -proper code to check if the user has exited the form will be a -polling-loop that looks something like this: - -:: - - while True: - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': - break - -We're going to build an app that does the latter. It's going to update -our form with a running clock. - -The basic flow and functions you will be calling are: Setup - -:: - - form = FlexForm() - form_rows = ..... - form.LayoutAndRead(form_rows, non_blocking=True) - -Periodic refresh - -:: - - form.ReadNonBlocking() - -If you need to close the form - -:: - - form.CloseNonBlockingForm() - -Rather than the usual ``form.LayoutAndRead()`` call, we're manually -adding the rows (doing the layout) and then showing the form. After the -form is shown, you simply call ``form.ReadNonBlocking()`` every now and -then. - -When you are ready to close the form (assuming the form wasn't closed by -the user or a button click) you simply call -``form.CloseNonBlockingForm()`` - -**Example - Running timer that updates** See the sample code on the -GitHub named Demo Media Player for another example of Async Forms. We're -going to make a form and update one of the elements of that form every -.01 seconds. Here's the entire code to do that. - -:: - - import PySimpleGUI as sg - import time - - # form that doesn't block - # Make a form, but don't use context manager - form = sg.FlexForm('Running Timer', auto_size_text=True) - # Create a text element that will be updated with status information on the GUI itself - output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) - # Create the rows - form_rows = [[sg.Text('Non-blocking GUI with updates')], - [output_element], - [sg.SimpleButton('Quit')]] - # Layout the rows of the form and perform a read. Indicate the form is non-blocking! - form.LayoutAndRead(form_rows, non_blocking=True) - - # - # Some place later in your code... - # You need to perform a ReadNonBlocking on your form every now and then or - # else it won't refresh - # - - for i in range(1, 1000): - output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': - break - time.sleep(.01) - else: - form.CloseNonBlockingForm() - -What we have here is the same sequence of function calls as in the -description. Get a form, add rows to it, show the form, and then refresh -it every now and then. - -The new thing in this example is the call use of the Update method for -the Text Element. The first thing we do inside the loop is "update" the -text element that we made earlier. This changes the value of the text -field on the form. The new value will be displayed when -``form.ReadNonBlocking()`` is called. - -Note the ``else`` statement on the for loop. This is needed because -we're about to exit the loop while the form is still open. The user has -not closed the form using the X nor a button so it's up to the caller to -close the form using ``CloseNonBlockingForm``. - -That's it... this example follows the async design pattern well. - -Sample Applications -------------------- - -Use the example programs as a starting basis for your GUI. Copy, paste, -modify and run! The demo files are: - -``Demo Recipes.py`` - Sample forms for all major form types and -situations. This is the place to get your code template from. Includes -asynchronous forms, etc. - -``Demo DisplayHash1and256.py`` - Demonstrates using High Level API calls -to get a filename - -``Demo DupliucateFileFinder.py`` - Demonstrates High Level API to get a -folder & Easy Progress Meter to show progress of the file scanning - -``Demo HowDoI.py`` - An amazing little application. Acts as a front-end -to HowDoI. This one program could forever change how you code. It does -searches on Stack Overflow and returns the CODE found in the best answer -for your query. If anyone wants to help me package this application up, -I could use a hand. - -Fun Stuff ---------- - -Here are some things to try if you're bored or want to further customize - -**Colors - Random and predefined** To set a button or text to a random -color, use the string ``'random'`` as the color value. You can also call -``PySimpleGUI.GetRandomColor``. To get a random color pair call -``PySimpleGUI.GetRandomColorPair``. This returns a tuple containing a -random color and that color's compliment. - -**Debug Output** Be sure and check out the EasyPrint (Print) function -described in the high-level API section. Leave your code the way it is, -route your stdout and stderror to a scrolling window. - -For a fun time, add these lines to the top of your script - -:: - - import PySimpleGUI as sg - print = sg.Print - -This will turn all of your print statements into prints that display in -a window on your screen rather than to the terminal. - -**Look and Feel** Dial in the look and feel that you like with the -``SetOptions`` function. You can change all of the defaults in one -function call. One line of code to customize the entire GUI. - -**ObjToString** Ever wanted to easily display an objects contents -easily? Use ObjToString to get a nicely formatted recursive walk of your -objects. This statement: - -:: - - print(sg.ObjToSting(x)) - -And this was the output - -:: - - - abc = abc - attr12 = 12 - c = - b = - a = - attr1 = 1 - attr2 = 2 - attr3 = three - attr10 = 10 - attrx = x - -You'll quickly wonder how you ever coded without it. - --------------- - -Known Issues -============ - -While not an "issue" this is a ***stern warning*** - -**Do not attempt** to call ``PySimpleGUI`` from multiple threads! It's ``tkinter`` based and ``tkinter`` has issues with multiple threads ------------------------------------------------------------------------------------------------------------------------------------------ - -**Progress Meters** - the visual graphic portion of the meter may be -off. May return to the native tkinter progress meter solution in the -future. Right now a "custom" progress meter is used. On the bright side, -the statistics shown are extremely accurate and can tell you something -about the performance of your code. - -**Async Forms** - these include the 'easy' forms (EasyProgressMeter and -EasyPrint/Print). If you start overlapping having Async forms open with -normal forms then things get a littler squirrelly. Still tracking down -the issues and am making it more solid every day possible. You'll know -there's an issue when you see blank form. - -**EasyPrint** - EasyPrint is a new feature that's pretty awesome. You -print and the output goes to a window, with a scroll bar, that you can -copy and paste from. Being a new feature, it's got some potential -problems. There are known interaction problems with other GUI windows. -For example, closing a Print window can also close other windows you -have open. For now, don't close your debug print window until other -windows are closed too. - -Contributing ------------- - -A MikeTheWatchGuy production... entirely responsible for this code.... -unless it causes you trouble in which case I'm not at all responsible. - -Versions --------- - -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| Version | Description | -+===========+==================================================================================================================================================+ -| 1.0.9 | July 10, 2018 - Initial Release | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1.0.21 | July 13, 2018 - Readme updates | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all\_lower\_case | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.1.1 | July 18, 2018 - Global settings exposed, fixes | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.2.0 | July 20, 2018 - Image Elements, Print output | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.6.0 | July 27, 2018 - auto\_size\_button setting. License changed to LGPL 3+ | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.6.5 | Aug XX, 2018 - window\_location default setting | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ - -Release Notes -~~~~~~~~~~~~~ - -2.3 - Sliders, Listbox's and Image elements (oh my!) - -If using Progress Meters, avoid cancelling them when you have another -window open. It could lead to future windows being blank. It's being -worked on. - -New debug printing capability. ``sg.Print`` - -2.5 Discovered issue with scroll bar on ``Output`` elements. The bar -will match size of ROW not the size of the element. Normally you never -notice this due to where on a form the ``Output`` element goes. - -Listboxes are still without scrollwheels. The mouse can drag to see more -items. The mouse scrollwheel will also scroll the list and will -``page up`` and ``page down`` keys. - -Upcoming -~~~~~~~~ - -Make suggestions people! Future release features - -Columns. How multiple columns would be specified in the SDK interface -are still being designed. - -Port to other graphic engines. Hook up the front-end interface to a -backend other than tkinter. Qt, WxPython, etc. - -Code Condition --------------- - -:: - - Make it run - Make it right - Make it fast - -It's a recipe for success if done right. PySimpleGUI has completed the -"Make it run" phase. It's far from "right" in many ways. These are being -worked on. The module is particularly poor for PEP 8 compliance. It was -a learning exercise that turned into a somewhat complete GUI solution -for lightweight problems. - -While the internals to PySimpleGUI are a tad sketchy, the public -interfaces into the SDK are more strictly defined and comply with PEP 8 -for the most part. - -Please log bugs and suggestions in the GitHub! It will only make the -code stronger and better in the end, a good thing for us all, right? - -Design ------- - -A moment about the design-spirit of ``PySimpleGUI``. From the beginning, -this package was meant to take advantage of Python's capabilities with -the goal of programming ease. - -**Single File** While not the best programming practice, the -implementation resulted in a single file solution. Only one file is -needed, PySimpleGUI.py. You can post this file, email it, and easily -import it using one statement. - -**Functions as objects** In Python, functions behave just like object. -When you're placing a Text Element into your form, you may be sometimes -calling a function and other times declaring an object. If you use the -word Text, then you're getting an object. If you're using ``Txt``, then -you're calling a function that returns a ``Text`` object. - -**Lists** It seemed quite natural to use Python's powerful list -constructs when possible. The form is specified as a series of lists. -Each "row" of the GUI is represented as a list of Elements. When the -form read returns the results to the user, all of the results are -presented as a single list. This makes reading a form's values -super-simple to do in a single line of Python code. - -Authors -------- - -MikeTheWatchGuy - -License -------- - -GNU Lesser General Public License (LGPL 3) + - -Acknowledgments ---------------- - -- Jorj McKie was the motivator behind the entire project. His - wxsimpleGUI concepts sparked PySimpleGUI into existence -- `Fredrik Lundh `__ for his - work on ``tkinter`` - -How Do I --------- - -Finally, I must thank the fine folks at How Do I. -https://github.com/gleitz/howdoi Their utility has forever changed the -way and pace in which I can program. I urge you to try the HowDoI.py -application here on GitHub. Trust me, **it's going to be worth the -effort!** Here are the steps to run that application - -:: - - Install howdoi: - pip install howdoi - Test your install: - python -m howdoi howdoi.py - To run it: - Python HowDoI.py - -The pip command is all there is to the setup. - -The way HowDoI works is that it uses your search term to look through -stack overflow posts. It finds the best answer, gets the code from the -answer, and presents it as a response. It gives you the correct answer -OFTEN. It's a miracle that it work SO well. For Python questions, I -simply start my query with 'Python'. Let's say you forgot how to reverse -a list in Python. When you run HowDoI and ask this question, this is -what you'll see. |snap0109| - -In the hands of a competent programmer, this tool is **amazing**. It's a -must-try kind of program that has completely changed my programming -process. I'm not afraid of asking for help! You just have to be smart -about using what you find. - -The PySimpleGUI window that the results are shown in is an 'input' field -which means you can copy and paste the results right into your code. - -.. |Downloads| image:: http://pepy.tech/badge/pysimplegui - :target: http://pepy.tech/project/pysimplegui -.. |snap0125| image:: https://user-images.githubusercontent.com/13696193/43114979-a696189e-8ecf-11e8-83c7-473fcf0ccc66.jpg -.. |results 2| image:: https://user-images.githubusercontent.com/13696193/43097502-44e3ed32-8e8a-11e8-9a51-2b8af0b1a682.jpg -.. |snap0155| image:: https://user-images.githubusercontent.com/13696193/43273879-a9fdc10a-90cb-11e8-8c20-4f6a244ebe2f.jpg -.. |snap0109| image:: https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg From 525020c84c3b19a0eaebca5eeea0d3ae3b447b02 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 2 Aug 2018 22:25:33 -0400 Subject: [PATCH 093/209] README.rst addition --- docs/README.rst | 1174 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1174 insertions(+) create mode 100644 docs/README.rst diff --git a/docs/README.rst b/docs/README.rst new file mode 100644 index 000000000..d7260a069 --- /dev/null +++ b/docs/README.rst @@ -0,0 +1,1174 @@ +.. figure:: https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png + :alt: pysimplegui\_logo + + pysimplegui\_logo +|Downloads| since Jul 11, 2018 # PySimpleGUI (Ver 2.7) + +Super-simple GUI to grasp... Powerfully customizable. + +Note - *Python3* is required to run PySimpleGUI. It takes advantage of +some Python3 features that do not translate well into Python2. + +Looking to take your Python code from the world of command lines and +into the convenience of a GUI? Have a Raspberry Pi with a touchscreen +that's going to waste because you don't have the time to learn a GUI +SDK? Look no further, you've found your GUI package. + +:: + + import PySimpleGUI as sg + + sg.MsgBox('Hello From PySimpleGUI!', 'This is the shortest GUI program ever!') + +.. figure:: https://user-images.githubusercontent.com/13696193/43162494-33095ece-8f59-11e8-86de-b6d8bcc5a52f.jpg + :alt: snap0136 + + snap0136 +Build beautiful customized forms that fit your specific problem. Let +PySimpleGUI solve your GUI problem while you solve the real problems. Do +you really want to plod through the mountains of code required to +program tkinter? + +.. figure:: https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg + :alt: snap0156 + + snap0156 +Perhaps you're looking for a way to interact with your Raspberry Pi in a +more friendly way. The is the same form as above, except shown on a Pi. + +.. figure:: https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg + :alt: raspberry pi + + raspberry pi +In addition to a primary GUI, you can add a Progress Meter to your code +with ONE LINE of code. Slide this into any of your ``for`` loops and get +a nice meter like this: + +:: + + EasyProgressMeter('My meter title', current_value, max value) + +.. figure:: https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg + :alt: progress meter 2 + + progress meter 2 +You can build an async media player GUI with custom buttons in 30 lines +of code. + +.. figure:: https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg + :alt: media file player + + media file player +I was frustrated by having to deal with the dos prompt when I had a +powerful Windows machine right in front of me. Why is it SO difficult to +do even the simplest of input/output to a window in Python?? + +There are a number of 'easy to use' Python GUIs, but they're **very** +limiting. PySimpleGUI takes the best of packages like ``EasyGUI``\ and +``WxSimpleGUI`` , both really handy but limited. The primary difference +between these and PySimpleGUI is that in addition to getting the simple +Message Boxes you also get the ability to make your own forms that are +highly customizeable. Don't like the standard Message Box? Then make +your own! + +Every call has optional parameters so that you can change the look and +feel. Don't like the button color? It's easy to change by adding a +button\_color parameter to your widget. + +GUI Packages with more functionality, like QT and WxPython, require +configuring and can take a ***week*** to get *reasonably familiar* with +the interfaces. Clearly there needs to be a middle ground between forms +with 1 or two input fields and a full-blown GUI. You'll be making your +own custom forms with PySimpleGUI within minutes, even Async forms. + +With a simple GUI, it becomes practical to "associate" .py files with +the python interpreter on Windows. Double click a py file and up pops a +GUI window, a more pleasant experience than opening a dos Window and +typing a command line. + +The ``PySimpleGUI`` package is focused on the ***developer***. How can +the desired result be achieved in as little and as simple code as +possible? This was the mantra used to create PySimpleGUI. How can it be +done is a Python-like way? + +:: + + Features of PySimpleGUI include: + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Realtime + Checkboxes + Radio Buttons + Listbox + Slider + Icons + Multi-line Text Input + Scroll-able Output + Images + Progress Bar + Async/Non-Blocking Windows + Tabbed forms + Persistent Windows + Redirect Python Output/Errors to scrolling window + 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + Single-Line-Of-Coide Proress Bar & Debug Print + Complete control of colors, look and feel + Button images + +An example of many widgets used on a single form. A little further down +you'll find the TWENTY lines of code required to create this complex +form. Try it if you don't believe it. Start Python, copy and paste the +code below into the >>> prompt and hit enter. This will pop up... + +.. figure:: https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg + :alt: everything example + + everything example +Here is the code that produced the above screenshot. + +:: + + import PySimpleGUI as SG + + with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [SG.Text('Here is some text.... and a place to enter text')], + [SG.InputText()], + [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], + [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], + [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [SG.Text('_' * 100, size=(70, 1))], + [SG.Text('Choose Source and Destination Folders', size=(35, 1))], + [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], + [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), + SG.FolderBrowse()], + [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + +**A note on screen shots** You will see a number of different styles of +buttons, data entry fields, etc, in this readme. They were all made with +the same SDK, the only difference is in the settings that are specified +on a per-element, row, form, or global basis. One setting in particular, +border\_width, can make a big difference on the look of the form. Some +of the screenshots had a border\_width of 6, others a value of 1. + +APIs +---- + +PySimpleGUI can be broken down into 2 types of API's: \* High Level +single call functions \* Custom form functions + +Python Language Features +~~~~~~~~~~~~~~~~~~~~~~~~ + +There are a couple of Python language features that PySimpleGUI utilizes +heavily that should be understood first... \* Variable number of +arguments to a function call \* Optional parameters to a function call + +Variable Number of Arguments +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The "High Level" API calls that *output* values take a variable number +of arguments so that they match a "print" statement as much as possible. +The idea is to make it simple for the programmer to output as many items +as desired and in any format. The user need not convert the variables to +be output into the strings. The PySimpleGUI functions do that for the +user. + +:: + + SG.MsgBox('Variable number of parameters example', var1, var2, "etc") + +Each new item begins on a new line in the Message Box + +.. figure:: https://user-images.githubusercontent.com/13696193/42844739-ebea22ac-89e1-11e8-8dd1-e61441325701.jpg + :alt: snap0104 + + snap0104 +Optional Parameters to a Function Call +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This feature of the Python language is utilized ***heavily*** as a +method of customizing forms and form Elements. Rather than requiring the +programmer to specify every possible option for a widget, instead only +the options the caller wants to override are specified. + +Here is the function definition for the MsgBox function. The details +aren't important. What is important is seeing that there is a long list +of potential tweaks that a caller can make. However, they don't *have* +to be specified on each and every call. + +:: + + def MsgBox(*args, + button_color=None, + button_type=MSG_BOX_OK, + auto_close=False, + auto_close_duration=None, + icon=DEFAULT_WINDOW_ICON, + line_width=MESSAGE_BOX_LINE_WIDTH, + font=None): + +If the caller wanted to change the button color to be black on yellow, +the call would look something like this: + +:: + + SG.MsgBox('This box has a custom button color', + button_color=('black', 'yellow')) + +.. figure:: https://user-images.githubusercontent.com/13696193/42844830-2d7e8b9a-89e2-11e8-8ef4-5af9e36f30f3.jpg + :alt: snap0105 + + snap0105 + +-------------- + +High Level API Calls +~~~~~~~~~~~~~~~~~~~~ + +The classic "input a value, print result" example. Often command line +programs simply take some value as input on the command line, do +something with it and then display the results. Moving from the command +line to a GUI is very simple. This code prompts user to input a line of +text and then displays that text in a messages box: + +:: + + import PySimpleGUI_local as SG + + rc = SG.GetTextBox('Title', 'Please input something') + SG.MsgBox('Results', 'The value returned from GetTextBox', rc) + +.. figure:: https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg + :alt: GetTextBox + + GetTextBox +.. figure:: https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg + :alt: MsgBox + + MsgBox +Message Boxes +^^^^^^^^^^^^^ + +In addition to MsgBox, you'll find a several API calls that are +shortcuts to common messages boxes. You can achieve similar results by +calling MsgBox with the correct parameters. + +The differences tend to be the number and types of buttons. Here are the +calls and the windows that are created. + +:: + + import PySimpleGUI as SG + +``SG.MsgBoxOK('This is an OK MsgBox')`` + +.. figure:: https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg + :alt: msgboxok + + msgboxok +:: + + SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') + +.. figure:: https://user-images.githubusercontent.com/13696193/42599858-8e8eff22-852e-11e8-8d5c-3fe99237eb7f.jpg + :alt: msgboxokcancel + + msgboxokcancel +:: + + SG.MsgBoxCancel('This is a Cancel MsgBox') + +.. figure:: https://user-images.githubusercontent.com/13696193/42599857-8e53dc4e-852e-11e8-8e83-6a8cccf8e706.jpg + :alt: msgboxcancel + + msgboxcancel +:: + + SG.MsgBoxYesNo('This is a Yes No MsgBox') + +.. figure:: https://user-images.githubusercontent.com/13696193/42599856-8e304540-852e-11e8-975d-fb2b62e94300.jpg + :alt: msgboxyesno + + msgboxyesno +:: + + SG.MsgBoxError('This is an error MsgBox') + +.. figure:: https://user-images.githubusercontent.com/13696193/42599853-8df8e078-852e-11e8-90dc-7815d69bff7e.jpg + :alt: msgbox error + + msgbox error +:: + + SG.MsgBoxAutoClose('This is an autoclose MsgBox') + +.. figure:: https://user-images.githubusercontent.com/13696193/42599855-8e147572-852e-11e8-8c23-7ec771909062.jpg + :alt: msgbox autoclose + + msgbox autoclose +:: + + SG.ScrolledTextBox(my_text, height=10) + +.. figure:: https://user-images.githubusercontent.com/13696193/42600800-a44f4562-8531-11e8-8c21-51dd70316879.jpg + :alt: scrolledtextbox + + scrolledtextbox +Take a moment to look at that last one. It's such a simple API call and +yet the result is awesome. Rather than seeing text scrolling past on +your display, you can capture that text and present it in a scrolled +interface. It's handy enough of an API call that it can also be called +using the name ``sprint`` which is easier to remember than +``ScrollectTextBox``. Your code could contain a line like: + +:: + + sprint(f'My variables values include x={x}', f'y={y}') + +This becomes a debug print of sorts that will route to a scrolled +window. + +High Level User Input +^^^^^^^^^^^^^^^^^^^^^ + +There are 3 very basic user input high-level function calls. It's +expected that for most applications, a custom input form will be +created. If you need only 1 value, then perhaps one of these high level +functions will work. - GetTextBox - GetFileBox - GetFolderBox + +``submit_clicked, value = SG.GetTextBox('Title', 'Please enter anything')`` + +.. figure:: https://user-images.githubusercontent.com/13696193/42600399-1ef66a5e-8530-11e8-9bc4-78ea839213cd.jpg + :alt: gettextbox + + gettextbox +:: + + submit_clicked, value = SG.GetFileBox('Title', 'Choose a file') + +.. figure:: https://user-images.githubusercontent.com/13696193/42600398-1ed8a122-8530-11e8-9f74-88b101efcea4.jpg + :alt: getfilebox + + getfilebox +:: + + submit_clicked, value = SG.GetPathBox('Title', 'Choose a folder') + +.. figure:: https://user-images.githubusercontent.com/13696193/42600397-1ea7cef8-8530-11e8-8d43-e1000c0933cd.jpg + :alt: getfolderbox + + getfolderbox +Progress Meter! +^^^^^^^^^^^^^^^ + +We all have loops in our code. 'Isn't it joyful waiting, watching a +counter scrolling past in a text window? How about one line of code to +get a progress meter, that contains statistics about your code? + +.. figure:: https://user-images.githubusercontent.com/13696193/42696332-dca3ca6e-8685-11e8-846b-6bee8362ee5f.jpg + :alt: progress meter 3 + + progress meter 3 +:: + + EasyProgressMeter(title, + current_value, + max_value, + *args, + orientation=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): + +Here's the one-line Progress Meter in action! + +:: + + for i in range(1,10000): + SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') + +That line of code resulted in this window popping up and updating. + +.. figure:: https://user-images.githubusercontent.com/13696193/42696912-a5c958b8-8687-11e8-9a7d-a390a465407a.jpg + :alt: progress meter 5 + + progress meter 5 +A meter AND fun statistics to watch while your machine grinds away, all +for the price of 1 line of code. With a little trickery you can provide +a way to break out of your loop using the Progress Meter form. The +cancel button results in a ``False`` return value from +``EasyProgressMeter``. It normally returns ``True``. + +:: + + if not SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message'): + break + +***Be sure and add one to your loop counter*** so that your counter goes +from 1 to the max value. If you do not add one, your counter will never +hit the max value. Instead it will go from 0 to max-1. #### Debug Output +Another call in the 'Easy' families of APIs is ``EasyPrint``. It will +output to a debug window. If the debug window isn't open, then the first +call will open it. No need to do anything but stick a 'print' call in +your code. You can even replace your 'print' calls with calls to +EasyPrint by simply sticking the statement + +:: + + print = SG.EasyPrint + +at the top of your code. There are a number of names for the same +EasyPrint function. ``Print`` is one of the better ones to use as it's +easy to remember. It is simply ``print`` with a capital P. + +:: + + import PySimpleGUI as SG + + for i in range(100): + SG.Print(i) + +|snap0125| Or if you didn't want to change your code: + +:: + + import PySimpleGUI as SG + + print=SG.Print + for i in range(100): + print(i) + +Just like the standard print call, ``EasyPrint`` supports the ``sep`` +and ``end`` keyword arguments. Other names that can be used to call +``EasyPrint`` include Print, ``eprint``, If you want to close the +window, call the function ``EasyPrintClose``. + +A word of caution. There are known problems when multiple PySimpleGUI +windows are opened, particularly if the user closes them in an unusual +way. Not a reason to stay away from using it. Just something to keep in +mind if you encounter a problem. + +You can change the size of the debug window using the ``SetOptions`` +call with the ``debug_win_size`` parameter. + +All Widgets / Elements +---------------------- + +This code utilizes as many of the elements in one form as possible. + +:: + + with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [SG.Text('Here is some text.... and a place to enter text')], + [SG.InputText()], + [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], + [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], + [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [SG.Text('_' * 100, size=(70, 1))], + [SG.Text('Choose Source and Destination Folders', size=(35, 1))], + [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], + [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), + SG.FolderBrowse()], + [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + +This is a somewhat complex form with quite a bit of custom sizing to +make things line up well. This is code you only have to write once. When +looking at the code, remember that what you're seeing is a list of +lists. Each row contains a list of Graphical Elements that are used to +create the form. + +.. figure:: https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg + :alt: everything example + + everything example +Clicking the Submit button caused the form call to return. The call to +MsgBox resulted in this dialog box. |results 2| + +**``Note, button value can be None``**. The value for ``button`` will be +the text that is displayed on the button element when it was created. If +the user closed the form using something other than a button, then +``button`` will be ``None``. + +You can see in the MsgBox that the values returned are a list. Each +input field in the form generates one item in the return values list. +All input fields return a ``string`` except for Check Boxes and Radio +Buttons. These return ``bool``. + +ProgressBar +^^^^^^^^^^^ + +The ``ProgressBar`` element is used to build custom Progress Bar forms. +It is HIGHLY recommended that you use the functions that provide a +complete progress meter solution for you. Progress Meters are not easy +to work with because the forms have to be non-blocking and they are +tricky to debug. + +The **easiest** way to get progress meters into your code is to use the +``EasyProgessMeter`` API. This consists of a pair of functions, +``EasyProgessMeter`` and ``EasyProgressMeterCancel``. You can easily +cancel any progress meter by calling it with the current value = max +value. This will mark the meter as expired and close the window. You've +already seen EasyProgressMeter calls presented earlier in this readme. + +:: + + SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') + +The return value for ``EasyProgressMeter`` is: ``True`` if meter updated +correctly ``False`` if user clicked the Cancel button, closed the form, +or vale reached the max value. **Customized Progress Bar** If you want a +bit more customization of your meter, then you can go up 1 level and use +the calls to ``ProgressMeter`` and ``ProgressMeterUpdate``. These APIs +behave like an object we're all used to. First you create the +``ProgressMeter`` object, then you call the ``Update`` method to update +it. + +You setup the progress meter by calling + +:: + + my_meter = ProgressMeter(title, + max_value, + *args, + orientantion=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) + +Then to update the bar within your loop + +:: + + return_code = ProgressMeterUpdate(my_meter, + value, + *args): + +Putting it all together you get this design pattern + +:: + + my_meter = SG.ProgressMeter('Meter Title', 100000, orentation='Vert') + + for i in range(0, 100000): + SG.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') + +The final way of using a Progress Meter with PySimpleGUI is to build a +custom form with a ``ProgressBar`` Element in the form. You will need to +run your form as a non-blocking form. When you are ready to update your +progress bar, you call the ``UpdateBar`` method for the ``ProgressBar`` +element itself. + +Output +^^^^^^ + +The Output Element is a re-direction of Stdout. Anything "printed" will +be displayed in this element. + +:: + + Output(scale=(None, None), + size=(None, None)) + +Here's a complete solution for a chat-window using an Async form with an +Output Element + +:: + + import PySimpleGUI as SG + # Blocking form that doesn't close + def ChatBot(): + with SG.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + layout = [[(SG.Text('This is where standard out is being routed', size=[40, 1]))], + [SG.Output(size=(80, 20))], + [SG.Multiline(size=(70, 5), enter_submits=True), SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))]] + # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form + # if you call LayoutAndRead from here, then you will miss the first button click + form.Layout(layout) + # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # + while True: + button, value = form.Read() + if button == 'SEND': + print(value) + else: + break + +Tabbed Forms +------------ + +Tabbed forms are shown using the ``ShowTabbedForm`` call. The call has +the format + +:: + + results = ShowTabbedForm('Title for the form', + (form,layout,'Tab 1 label'), + (form2,layout2, 'Tab 2 label'), ...) + +Each of the tabs of the form is in fact a form. The same steps are taken +to create the form as before. A ``FlexForm`` is created, then rows are +filled with Elements, and finally the form is shown. When calling +``ShowTabbedForm``, each form is passed in as a tuple. The tuple has the +format: ``(the form, the rows, a string shown on the tab)`` + +Results are returned as a list of lists. For each form you'll get a list +that's in the same format as a normal form. A single tab's values would +be: + +:: + + (button, (values)) + +Recall that values is a list as well. Multiple tabs in the form would +return like this: + +:: + + ((button1, (values1)), (button2, (values2)) + +## Colors ## Starting in version 2.5 you can change the background +colors for the window and the Elements. + +Your forms can go from this: |snap0155| + +to this... with one function call... + +.. figure:: https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg + :alt: snap0156 + + snap0156 +While you can do it on an element by element or form level basis, the +easiest way, by far, is a call to ``SetOptions``. + +Be aware that once you change these options they are changed for the +rest of your program's execution. All of your forms will have that look +and feel, until you change it to something else (which could be the +system default colors. + +This call sets all of the different color options. + +:: + + SetOptions(background_color='#9FB8AD', + text_element_background_color='#9FB8AD', + element_background_color='#9FB8AD', + scrollbar_color=None, + input_elements_background_color='#F7F3EC', + progress_meter_color = ('green', 'blue') + button_color=('white','#475841')) + +Global Settings +--------------- + +**Global Settings** Let's have some fun customizing! Make PySimpleGUI +look the way you want it to look. You can set the global settings using +the function ``PySimpleGUI.SetOptions``. Each option has an optional +parameter that's used to set it. + +:: + + SetOptions(icon=None + button_color=(None,None) + element_size=(None,None), + margins=(None,None), + element_padding=(None,None) + auto_size_text=None + auto_size_buttons=None + font=None + border_width=None + slider_border_width=None + slider_relief=None + slider_orientation=None + autoclose_time=None + message_box_line_width=None + progress_meter_border_depth=None + progress_meter_style=None + progress_meter_relief=None + progress_meter_color=None + progress_meter_size=None + text_justification=None + background_color=None + element_background_color=None + text_element_background_color=None + input_elements_background_color=None + scrollbar_color=None, text_color=None + debug_win_size=(None,None) + window_location=(None,None) + +Explanation of parameters + +:: + + icon - filename of icon used for taskbar and title bar + button_color - button color (foreground, background) + element_size - element size (width, height) in characters + margins - tkinter margins around outsize + element_padding - tkinter padding around each element + auto_size_text - autosize the elements to fit their text + auto_size_buttons - autosize the buttons to fit their text + font - font used for elements + border_width - amount of bezel or border around sunken or raised elements + slider_border_width - changes the way sliders look + slider_relief - changes the way sliders look + slider_orientation - changes orientation of slider + autoclose_time - time in seconds for autoclose boxes + message_box_line_width - number of characers in a line of text in message boxes + progress_meter_border_depth - amount of border around raised or lowered progress meters + progress_meter_style - style of progress meter as defined by tkinter + progress_meter_relief - relief style + progress_meter_color - color of the bar and background of progress meters + progress_meter_size - size in (characters, pixels) + background_color - Color of the main window's background + element_background_color - Background color of the elements + text_element_background_color - Text element background color + input_elements_background_color - Input fields background color + scrollbar_color - Color for scrollbars (may not always work) + text_color - Text element default text color + text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' + debug_win_size - size of the Print output window + window_location - location on the screen (x,y) of window's top left cornder + +These settings apply to all forms ``SetOptions``. The Row options and +Element options will take precedence over these settings. Settings can +be thought of as levels of settings with the Form-level being the +highest and the Element-level the lowest. Thus the levels are: + +- Form level +- Row level +- Element level + +Each lower level overrides the settings of the higher level. Once +settings have been changed, they remain changed for the duration of the +program (unless changed again). + +Asynchronous (Non-Blocking) Forms +--------------------------------- + +So you want to be a wizard do ya? Well go boldly! While the majority of +GUIs are a simple exercise to "collect input values and return with +them", there are instances where we want to continue executing while the +form is open. These are "asynchronous" forms and require special +options, new SDK calls, and **great care**. With asynchronous forms the +form is shown, user input is read, but your code keeps right on +chugging. YOUR responsibility is to call ``PySimpleGUI.ReadNonBlocking`` +on a periodic basis. Once a second or more will produce a reasonably +snappy GUI. + +When do you use a non-blocking form? A couple of examples are \* A media +file player like an MP3 player \* A status dashboard that's periodically +updated \* Progress Meters - when you want to make your own progress +meters \* Output using print to a scrolled text element. Good for +debugging. + +Word of warning... version 2.2, the currently released, and upcoming +version 2.3 differ in the return code for the ``ReadNonBlocking`` call. +Previously the function returned 2 values, except when the form is +closed using the "X" which returned a single value of ``None``. The +*new* way is that ``ReadNonBlocking`` always returns 2 values. If the +user closed the form with the "X" then the return values will be None, +None. You will want to key off the second value to catch this case. The +proper code to check if the user has exited the form will be a +polling-loop that looks something like this: + +:: + + while True: + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + +We're going to build an app that does the latter. It's going to update +our form with a running clock. + +The basic flow and functions you will be calling are: Setup + +:: + + form = FlexForm() + form_rows = ..... + form.LayoutAndRead(form_rows, non_blocking=True) + +Periodic refresh + +:: + + form.ReadNonBlocking() + +If you need to close the form + +:: + + form.CloseNonBlockingForm() + +Rather than the usual ``form.LayoutAndRead()`` call, we're manually +adding the rows (doing the layout) and then showing the form. After the +form is shown, you simply call ``form.ReadNonBlocking()`` every now and +then. + +When you are ready to close the form (assuming the form wasn't closed by +the user or a button click) you simply call +``form.CloseNonBlockingForm()`` + +**Example - Running timer that updates** See the sample code on the +GitHub named Demo Media Player for another example of Async Forms. We're +going to make a form and update one of the elements of that form every +.01 seconds. Here's the entire code to do that. + +:: + + import PySimpleGUI as sg + import time + + # form that doesn't block + # Make a form, but don't use context manager + form = sg.FlexForm('Running Timer', auto_size_text=True) + # Create a text element that will be updated with status information on the GUI itself + output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) + # Create the rows + form_rows = [[sg.Text('Non-blocking GUI with updates')], + [output_element], + [sg.SimpleButton('Quit')]] + # Layout the rows of the form and perform a read. Indicate the form is non-blocking! + form.LayoutAndRead(form_rows, non_blocking=True) + + # + # Some place later in your code... + # You need to perform a ReadNonBlocking on your form every now and then or + # else it won't refresh + # + + for i in range(1, 1000): + output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + time.sleep(.01) + else: + form.CloseNonBlockingForm() + +What we have here is the same sequence of function calls as in the +description. Get a form, add rows to it, show the form, and then refresh +it every now and then. + +The new thing in this example is the call use of the Update method for +the Text Element. The first thing we do inside the loop is "update" the +text element that we made earlier. This changes the value of the text +field on the form. The new value will be displayed when +``form.ReadNonBlocking()`` is called. + +Note the ``else`` statement on the for loop. This is needed because +we're about to exit the loop while the form is still open. The user has +not closed the form using the X nor a button so it's up to the caller to +close the form using ``CloseNonBlockingForm``. + +That's it... this example follows the async design pattern well. + +Sample Applications +------------------- + +Use the example programs as a starting basis for your GUI. Copy, paste, +modify and run! The demo files are: + +``Demo Recipes.py`` - Sample forms for all major form types and +situations. This is the place to get your code template from. Includes +asynchronous forms, etc. + +``Demo DisplayHash1and256.py`` - Demonstrates using High Level API calls +to get a filename + +``Demo DupliucateFileFinder.py`` - Demonstrates High Level API to get a +folder & Easy Progress Meter to show progress of the file scanning + +``Demo HowDoI.py`` - An amazing little application. Acts as a front-end +to HowDoI. This one program could forever change how you code. It does +searches on Stack Overflow and returns the CODE found in the best answer +for your query. If anyone wants to help me package this application up, +I could use a hand. + +Fun Stuff +--------- + +Here are some things to try if you're bored or want to further customize + +**Colors - Random and predefined** To set a button or text to a random +color, use the string ``'random'`` as the color value. You can also call +``PySimpleGUI.GetRandomColor``. To get a random color pair call +``PySimpleGUI.GetRandomColorPair``. This returns a tuple containing a +random color and that color's compliment. + +**Debug Output** Be sure and check out the EasyPrint (Print) function +described in the high-level API section. Leave your code the way it is, +route your stdout and stderror to a scrolling window. + +For a fun time, add these lines to the top of your script + +:: + + import PySimpleGUI as sg + print = sg.Print + +This will turn all of your print statements into prints that display in +a window on your screen rather than to the terminal. + +**Look and Feel** Dial in the look and feel that you like with the +``SetOptions`` function. You can change all of the defaults in one +function call. One line of code to customize the entire GUI. + +**ObjToString** Ever wanted to easily display an objects contents +easily? Use ObjToString to get a nicely formatted recursive walk of your +objects. This statement: + +:: + + print(sg.ObjToSting(x)) + +And this was the output + +:: + + + abc = abc + attr12 = 12 + c = + b = + a = + attr1 = 1 + attr2 = 2 + attr3 = three + attr10 = 10 + attrx = x + +You'll quickly wonder how you ever coded without it. + +-------------- + +Known Issues +============ + +While not an "issue" this is a ***stern warning*** + +**Do not attempt** to call ``PySimpleGUI`` from multiple threads! It's ``tkinter`` based and ``tkinter`` has issues with multiple threads +----------------------------------------------------------------------------------------------------------------------------------------- + +**Progress Meters** - the visual graphic portion of the meter may be +off. May return to the native tkinter progress meter solution in the +future. Right now a "custom" progress meter is used. On the bright side, +the statistics shown are extremely accurate and can tell you something +about the performance of your code. + +**Async Forms** - these include the 'easy' forms (EasyProgressMeter and +EasyPrint/Print). If you start overlapping having Async forms open with +normal forms then things get a littler squirrelly. Still tracking down +the issues and am making it more solid every day possible. You'll know +there's an issue when you see blank form. + +**EasyPrint** - EasyPrint is a new feature that's pretty awesome. You +print and the output goes to a window, with a scroll bar, that you can +copy and paste from. Being a new feature, it's got some potential +problems. There are known interaction problems with other GUI windows. +For example, closing a Print window can also close other windows you +have open. For now, don't close your debug print window until other +windows are closed too. + +Contributing +------------ + +A MikeTheWatchGuy production... entirely responsible for this code.... +unless it causes you trouble in which case I'm not at all responsible. + +Versions +-------- + ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| Version | Description | ++===========+==================================================================================================================================================+ +| 1.0.9 | July 10, 2018 - Initial Release | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 1.0.21 | July 13, 2018 - Readme updates | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all\_lower\_case | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.1.1 | July 18, 2018 - Global settings exposed, fixes | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.2.0 | July 20, 2018 - Image Elements, Print output | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.6.0 | July 27, 2018 - auto\_size\_button setting. License changed to LGPL 3+ | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.6.5 | Aug XX, 2018 - window\_location default setting | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + +Release Notes +~~~~~~~~~~~~~ + +2.3 - Sliders, Listbox's and Image elements (oh my!) + +If using Progress Meters, avoid cancelling them when you have another +window open. It could lead to future windows being blank. It's being +worked on. + +New debug printing capability. ``sg.Print`` + +2.5 Discovered issue with scroll bar on ``Output`` elements. The bar +will match size of ROW not the size of the element. Normally you never +notice this due to where on a form the ``Output`` element goes. + +Listboxes are still without scrollwheels. The mouse can drag to see more +items. The mouse scrollwheel will also scroll the list and will +``page up`` and ``page down`` keys. + +Upcoming +~~~~~~~~ + +Make suggestions people! Future release features + +Columns. How multiple columns would be specified in the SDK interface +are still being designed. + +Port to other graphic engines. Hook up the front-end interface to a +backend other than tkinter. Qt, WxPython, etc. + +Code Condition +-------------- + +:: + + Make it run + Make it right + Make it fast + +It's a recipe for success if done right. PySimpleGUI has completed the +"Make it run" phase. It's far from "right" in many ways. These are being +worked on. The module is particularly poor for PEP 8 compliance. It was +a learning exercise that turned into a somewhat complete GUI solution +for lightweight problems. + +While the internals to PySimpleGUI are a tad sketchy, the public +interfaces into the SDK are more strictly defined and comply with PEP 8 +for the most part. + +Please log bugs and suggestions in the GitHub! It will only make the +code stronger and better in the end, a good thing for us all, right? + +Design +------ + +A moment about the design-spirit of ``PySimpleGUI``. From the beginning, +this package was meant to take advantage of Python's capabilities with +the goal of programming ease. + +**Single File** While not the best programming practice, the +implementation resulted in a single file solution. Only one file is +needed, PySimpleGUI.py. You can post this file, email it, and easily +import it using one statement. + +**Functions as objects** In Python, functions behave just like object. +When you're placing a Text Element into your form, you may be sometimes +calling a function and other times declaring an object. If you use the +word Text, then you're getting an object. If you're using ``Txt``, then +you're calling a function that returns a ``Text`` object. + +**Lists** It seemed quite natural to use Python's powerful list +constructs when possible. The form is specified as a series of lists. +Each "row" of the GUI is represented as a list of Elements. When the +form read returns the results to the user, all of the results are +presented as a single list. This makes reading a form's values +super-simple to do in a single line of Python code. + +Authors +------- + +MikeTheWatchGuy + +License +------- + +GNU Lesser General Public License (LGPL 3) + + +Acknowledgments +--------------- + +- Jorj McKie was the motivator behind the entire project. His + wxsimpleGUI concepts sparked PySimpleGUI into existence +- `Fredrik Lundh `__ for his + work on ``tkinter`` + +How Do I +-------- + +Finally, I must thank the fine folks at How Do I. +https://github.com/gleitz/howdoi Their utility has forever changed the +way and pace in which I can program. I urge you to try the HowDoI.py +application here on GitHub. Trust me, **it's going to be worth the +effort!** Here are the steps to run that application + +:: + + Install howdoi: + pip install howdoi + Test your install: + python -m howdoi howdoi.py + To run it: + Python HowDoI.py + +The pip command is all there is to the setup. + +The way HowDoI works is that it uses your search term to look through +stack overflow posts. It finds the best answer, gets the code from the +answer, and presents it as a response. It gives you the correct answer +OFTEN. It's a miracle that it work SO well. For Python questions, I +simply start my query with 'Python'. Let's say you forgot how to reverse +a list in Python. When you run HowDoI and ask this question, this is +what you'll see. |snap0109| + +In the hands of a competent programmer, this tool is **amazing**. It's a +must-try kind of program that has completely changed my programming +process. I'm not afraid of asking for help! You just have to be smart +about using what you find. + +The PySimpleGUI window that the results are shown in is an 'input' field +which means you can copy and paste the results right into your code. + +.. |Downloads| image:: http://pepy.tech/badge/pysimplegui + :target: http://pepy.tech/project/pysimplegui +.. |snap0125| image:: https://user-images.githubusercontent.com/13696193/43114979-a696189e-8ecf-11e8-83c7-473fcf0ccc66.jpg +.. |results 2| image:: https://user-images.githubusercontent.com/13696193/43097502-44e3ed32-8e8a-11e8-9a51-2b8af0b1a682.jpg +.. |snap0155| image:: https://user-images.githubusercontent.com/13696193/43273879-a9fdc10a-90cb-11e8-8c20-4f6a244ebe2f.jpg +.. |snap0109| image:: https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg From 46858be048dd5464c7523f8b57a7647a5788a75a Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 2 Aug 2018 22:48:05 -0400 Subject: [PATCH 094/209] index.rst --- docs/index.rst | 1174 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1174 insertions(+) create mode 100644 docs/index.rst diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 000000000..d7260a069 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,1174 @@ +.. figure:: https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png + :alt: pysimplegui\_logo + + pysimplegui\_logo +|Downloads| since Jul 11, 2018 # PySimpleGUI (Ver 2.7) + +Super-simple GUI to grasp... Powerfully customizable. + +Note - *Python3* is required to run PySimpleGUI. It takes advantage of +some Python3 features that do not translate well into Python2. + +Looking to take your Python code from the world of command lines and +into the convenience of a GUI? Have a Raspberry Pi with a touchscreen +that's going to waste because you don't have the time to learn a GUI +SDK? Look no further, you've found your GUI package. + +:: + + import PySimpleGUI as sg + + sg.MsgBox('Hello From PySimpleGUI!', 'This is the shortest GUI program ever!') + +.. figure:: https://user-images.githubusercontent.com/13696193/43162494-33095ece-8f59-11e8-86de-b6d8bcc5a52f.jpg + :alt: snap0136 + + snap0136 +Build beautiful customized forms that fit your specific problem. Let +PySimpleGUI solve your GUI problem while you solve the real problems. Do +you really want to plod through the mountains of code required to +program tkinter? + +.. figure:: https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg + :alt: snap0156 + + snap0156 +Perhaps you're looking for a way to interact with your Raspberry Pi in a +more friendly way. The is the same form as above, except shown on a Pi. + +.. figure:: https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg + :alt: raspberry pi + + raspberry pi +In addition to a primary GUI, you can add a Progress Meter to your code +with ONE LINE of code. Slide this into any of your ``for`` loops and get +a nice meter like this: + +:: + + EasyProgressMeter('My meter title', current_value, max value) + +.. figure:: https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg + :alt: progress meter 2 + + progress meter 2 +You can build an async media player GUI with custom buttons in 30 lines +of code. + +.. figure:: https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg + :alt: media file player + + media file player +I was frustrated by having to deal with the dos prompt when I had a +powerful Windows machine right in front of me. Why is it SO difficult to +do even the simplest of input/output to a window in Python?? + +There are a number of 'easy to use' Python GUIs, but they're **very** +limiting. PySimpleGUI takes the best of packages like ``EasyGUI``\ and +``WxSimpleGUI`` , both really handy but limited. The primary difference +between these and PySimpleGUI is that in addition to getting the simple +Message Boxes you also get the ability to make your own forms that are +highly customizeable. Don't like the standard Message Box? Then make +your own! + +Every call has optional parameters so that you can change the look and +feel. Don't like the button color? It's easy to change by adding a +button\_color parameter to your widget. + +GUI Packages with more functionality, like QT and WxPython, require +configuring and can take a ***week*** to get *reasonably familiar* with +the interfaces. Clearly there needs to be a middle ground between forms +with 1 or two input fields and a full-blown GUI. You'll be making your +own custom forms with PySimpleGUI within minutes, even Async forms. + +With a simple GUI, it becomes practical to "associate" .py files with +the python interpreter on Windows. Double click a py file and up pops a +GUI window, a more pleasant experience than opening a dos Window and +typing a command line. + +The ``PySimpleGUI`` package is focused on the ***developer***. How can +the desired result be achieved in as little and as simple code as +possible? This was the mantra used to create PySimpleGUI. How can it be +done is a Python-like way? + +:: + + Features of PySimpleGUI include: + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Realtime + Checkboxes + Radio Buttons + Listbox + Slider + Icons + Multi-line Text Input + Scroll-able Output + Images + Progress Bar + Async/Non-Blocking Windows + Tabbed forms + Persistent Windows + Redirect Python Output/Errors to scrolling window + 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + Single-Line-Of-Coide Proress Bar & Debug Print + Complete control of colors, look and feel + Button images + +An example of many widgets used on a single form. A little further down +you'll find the TWENTY lines of code required to create this complex +form. Try it if you don't believe it. Start Python, copy and paste the +code below into the >>> prompt and hit enter. This will pop up... + +.. figure:: https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg + :alt: everything example + + everything example +Here is the code that produced the above screenshot. + +:: + + import PySimpleGUI as SG + + with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [SG.Text('Here is some text.... and a place to enter text')], + [SG.InputText()], + [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], + [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], + [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [SG.Text('_' * 100, size=(70, 1))], + [SG.Text('Choose Source and Destination Folders', size=(35, 1))], + [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], + [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), + SG.FolderBrowse()], + [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + +**A note on screen shots** You will see a number of different styles of +buttons, data entry fields, etc, in this readme. They were all made with +the same SDK, the only difference is in the settings that are specified +on a per-element, row, form, or global basis. One setting in particular, +border\_width, can make a big difference on the look of the form. Some +of the screenshots had a border\_width of 6, others a value of 1. + +APIs +---- + +PySimpleGUI can be broken down into 2 types of API's: \* High Level +single call functions \* Custom form functions + +Python Language Features +~~~~~~~~~~~~~~~~~~~~~~~~ + +There are a couple of Python language features that PySimpleGUI utilizes +heavily that should be understood first... \* Variable number of +arguments to a function call \* Optional parameters to a function call + +Variable Number of Arguments +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The "High Level" API calls that *output* values take a variable number +of arguments so that they match a "print" statement as much as possible. +The idea is to make it simple for the programmer to output as many items +as desired and in any format. The user need not convert the variables to +be output into the strings. The PySimpleGUI functions do that for the +user. + +:: + + SG.MsgBox('Variable number of parameters example', var1, var2, "etc") + +Each new item begins on a new line in the Message Box + +.. figure:: https://user-images.githubusercontent.com/13696193/42844739-ebea22ac-89e1-11e8-8dd1-e61441325701.jpg + :alt: snap0104 + + snap0104 +Optional Parameters to a Function Call +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This feature of the Python language is utilized ***heavily*** as a +method of customizing forms and form Elements. Rather than requiring the +programmer to specify every possible option for a widget, instead only +the options the caller wants to override are specified. + +Here is the function definition for the MsgBox function. The details +aren't important. What is important is seeing that there is a long list +of potential tweaks that a caller can make. However, they don't *have* +to be specified on each and every call. + +:: + + def MsgBox(*args, + button_color=None, + button_type=MSG_BOX_OK, + auto_close=False, + auto_close_duration=None, + icon=DEFAULT_WINDOW_ICON, + line_width=MESSAGE_BOX_LINE_WIDTH, + font=None): + +If the caller wanted to change the button color to be black on yellow, +the call would look something like this: + +:: + + SG.MsgBox('This box has a custom button color', + button_color=('black', 'yellow')) + +.. figure:: https://user-images.githubusercontent.com/13696193/42844830-2d7e8b9a-89e2-11e8-8ef4-5af9e36f30f3.jpg + :alt: snap0105 + + snap0105 + +-------------- + +High Level API Calls +~~~~~~~~~~~~~~~~~~~~ + +The classic "input a value, print result" example. Often command line +programs simply take some value as input on the command line, do +something with it and then display the results. Moving from the command +line to a GUI is very simple. This code prompts user to input a line of +text and then displays that text in a messages box: + +:: + + import PySimpleGUI_local as SG + + rc = SG.GetTextBox('Title', 'Please input something') + SG.MsgBox('Results', 'The value returned from GetTextBox', rc) + +.. figure:: https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg + :alt: GetTextBox + + GetTextBox +.. figure:: https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg + :alt: MsgBox + + MsgBox +Message Boxes +^^^^^^^^^^^^^ + +In addition to MsgBox, you'll find a several API calls that are +shortcuts to common messages boxes. You can achieve similar results by +calling MsgBox with the correct parameters. + +The differences tend to be the number and types of buttons. Here are the +calls and the windows that are created. + +:: + + import PySimpleGUI as SG + +``SG.MsgBoxOK('This is an OK MsgBox')`` + +.. figure:: https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg + :alt: msgboxok + + msgboxok +:: + + SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') + +.. figure:: https://user-images.githubusercontent.com/13696193/42599858-8e8eff22-852e-11e8-8d5c-3fe99237eb7f.jpg + :alt: msgboxokcancel + + msgboxokcancel +:: + + SG.MsgBoxCancel('This is a Cancel MsgBox') + +.. figure:: https://user-images.githubusercontent.com/13696193/42599857-8e53dc4e-852e-11e8-8e83-6a8cccf8e706.jpg + :alt: msgboxcancel + + msgboxcancel +:: + + SG.MsgBoxYesNo('This is a Yes No MsgBox') + +.. figure:: https://user-images.githubusercontent.com/13696193/42599856-8e304540-852e-11e8-975d-fb2b62e94300.jpg + :alt: msgboxyesno + + msgboxyesno +:: + + SG.MsgBoxError('This is an error MsgBox') + +.. figure:: https://user-images.githubusercontent.com/13696193/42599853-8df8e078-852e-11e8-90dc-7815d69bff7e.jpg + :alt: msgbox error + + msgbox error +:: + + SG.MsgBoxAutoClose('This is an autoclose MsgBox') + +.. figure:: https://user-images.githubusercontent.com/13696193/42599855-8e147572-852e-11e8-8c23-7ec771909062.jpg + :alt: msgbox autoclose + + msgbox autoclose +:: + + SG.ScrolledTextBox(my_text, height=10) + +.. figure:: https://user-images.githubusercontent.com/13696193/42600800-a44f4562-8531-11e8-8c21-51dd70316879.jpg + :alt: scrolledtextbox + + scrolledtextbox +Take a moment to look at that last one. It's such a simple API call and +yet the result is awesome. Rather than seeing text scrolling past on +your display, you can capture that text and present it in a scrolled +interface. It's handy enough of an API call that it can also be called +using the name ``sprint`` which is easier to remember than +``ScrollectTextBox``. Your code could contain a line like: + +:: + + sprint(f'My variables values include x={x}', f'y={y}') + +This becomes a debug print of sorts that will route to a scrolled +window. + +High Level User Input +^^^^^^^^^^^^^^^^^^^^^ + +There are 3 very basic user input high-level function calls. It's +expected that for most applications, a custom input form will be +created. If you need only 1 value, then perhaps one of these high level +functions will work. - GetTextBox - GetFileBox - GetFolderBox + +``submit_clicked, value = SG.GetTextBox('Title', 'Please enter anything')`` + +.. figure:: https://user-images.githubusercontent.com/13696193/42600399-1ef66a5e-8530-11e8-9bc4-78ea839213cd.jpg + :alt: gettextbox + + gettextbox +:: + + submit_clicked, value = SG.GetFileBox('Title', 'Choose a file') + +.. figure:: https://user-images.githubusercontent.com/13696193/42600398-1ed8a122-8530-11e8-9f74-88b101efcea4.jpg + :alt: getfilebox + + getfilebox +:: + + submit_clicked, value = SG.GetPathBox('Title', 'Choose a folder') + +.. figure:: https://user-images.githubusercontent.com/13696193/42600397-1ea7cef8-8530-11e8-8d43-e1000c0933cd.jpg + :alt: getfolderbox + + getfolderbox +Progress Meter! +^^^^^^^^^^^^^^^ + +We all have loops in our code. 'Isn't it joyful waiting, watching a +counter scrolling past in a text window? How about one line of code to +get a progress meter, that contains statistics about your code? + +.. figure:: https://user-images.githubusercontent.com/13696193/42696332-dca3ca6e-8685-11e8-846b-6bee8362ee5f.jpg + :alt: progress meter 3 + + progress meter 3 +:: + + EasyProgressMeter(title, + current_value, + max_value, + *args, + orientation=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): + +Here's the one-line Progress Meter in action! + +:: + + for i in range(1,10000): + SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') + +That line of code resulted in this window popping up and updating. + +.. figure:: https://user-images.githubusercontent.com/13696193/42696912-a5c958b8-8687-11e8-9a7d-a390a465407a.jpg + :alt: progress meter 5 + + progress meter 5 +A meter AND fun statistics to watch while your machine grinds away, all +for the price of 1 line of code. With a little trickery you can provide +a way to break out of your loop using the Progress Meter form. The +cancel button results in a ``False`` return value from +``EasyProgressMeter``. It normally returns ``True``. + +:: + + if not SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message'): + break + +***Be sure and add one to your loop counter*** so that your counter goes +from 1 to the max value. If you do not add one, your counter will never +hit the max value. Instead it will go from 0 to max-1. #### Debug Output +Another call in the 'Easy' families of APIs is ``EasyPrint``. It will +output to a debug window. If the debug window isn't open, then the first +call will open it. No need to do anything but stick a 'print' call in +your code. You can even replace your 'print' calls with calls to +EasyPrint by simply sticking the statement + +:: + + print = SG.EasyPrint + +at the top of your code. There are a number of names for the same +EasyPrint function. ``Print`` is one of the better ones to use as it's +easy to remember. It is simply ``print`` with a capital P. + +:: + + import PySimpleGUI as SG + + for i in range(100): + SG.Print(i) + +|snap0125| Or if you didn't want to change your code: + +:: + + import PySimpleGUI as SG + + print=SG.Print + for i in range(100): + print(i) + +Just like the standard print call, ``EasyPrint`` supports the ``sep`` +and ``end`` keyword arguments. Other names that can be used to call +``EasyPrint`` include Print, ``eprint``, If you want to close the +window, call the function ``EasyPrintClose``. + +A word of caution. There are known problems when multiple PySimpleGUI +windows are opened, particularly if the user closes them in an unusual +way. Not a reason to stay away from using it. Just something to keep in +mind if you encounter a problem. + +You can change the size of the debug window using the ``SetOptions`` +call with the ``debug_win_size`` parameter. + +All Widgets / Elements +---------------------- + +This code utilizes as many of the elements in one form as possible. + +:: + + with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [SG.Text('Here is some text.... and a place to enter text')], + [SG.InputText()], + [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], + [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], + [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [SG.Text('_' * 100, size=(70, 1))], + [SG.Text('Choose Source and Destination Folders', size=(35, 1))], + [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], + [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), + SG.FolderBrowse()], + [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + +This is a somewhat complex form with quite a bit of custom sizing to +make things line up well. This is code you only have to write once. When +looking at the code, remember that what you're seeing is a list of +lists. Each row contains a list of Graphical Elements that are used to +create the form. + +.. figure:: https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg + :alt: everything example + + everything example +Clicking the Submit button caused the form call to return. The call to +MsgBox resulted in this dialog box. |results 2| + +**``Note, button value can be None``**. The value for ``button`` will be +the text that is displayed on the button element when it was created. If +the user closed the form using something other than a button, then +``button`` will be ``None``. + +You can see in the MsgBox that the values returned are a list. Each +input field in the form generates one item in the return values list. +All input fields return a ``string`` except for Check Boxes and Radio +Buttons. These return ``bool``. + +ProgressBar +^^^^^^^^^^^ + +The ``ProgressBar`` element is used to build custom Progress Bar forms. +It is HIGHLY recommended that you use the functions that provide a +complete progress meter solution for you. Progress Meters are not easy +to work with because the forms have to be non-blocking and they are +tricky to debug. + +The **easiest** way to get progress meters into your code is to use the +``EasyProgessMeter`` API. This consists of a pair of functions, +``EasyProgessMeter`` and ``EasyProgressMeterCancel``. You can easily +cancel any progress meter by calling it with the current value = max +value. This will mark the meter as expired and close the window. You've +already seen EasyProgressMeter calls presented earlier in this readme. + +:: + + SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') + +The return value for ``EasyProgressMeter`` is: ``True`` if meter updated +correctly ``False`` if user clicked the Cancel button, closed the form, +or vale reached the max value. **Customized Progress Bar** If you want a +bit more customization of your meter, then you can go up 1 level and use +the calls to ``ProgressMeter`` and ``ProgressMeterUpdate``. These APIs +behave like an object we're all used to. First you create the +``ProgressMeter`` object, then you call the ``Update`` method to update +it. + +You setup the progress meter by calling + +:: + + my_meter = ProgressMeter(title, + max_value, + *args, + orientantion=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) + +Then to update the bar within your loop + +:: + + return_code = ProgressMeterUpdate(my_meter, + value, + *args): + +Putting it all together you get this design pattern + +:: + + my_meter = SG.ProgressMeter('Meter Title', 100000, orentation='Vert') + + for i in range(0, 100000): + SG.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') + +The final way of using a Progress Meter with PySimpleGUI is to build a +custom form with a ``ProgressBar`` Element in the form. You will need to +run your form as a non-blocking form. When you are ready to update your +progress bar, you call the ``UpdateBar`` method for the ``ProgressBar`` +element itself. + +Output +^^^^^^ + +The Output Element is a re-direction of Stdout. Anything "printed" will +be displayed in this element. + +:: + + Output(scale=(None, None), + size=(None, None)) + +Here's a complete solution for a chat-window using an Async form with an +Output Element + +:: + + import PySimpleGUI as SG + # Blocking form that doesn't close + def ChatBot(): + with SG.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + layout = [[(SG.Text('This is where standard out is being routed', size=[40, 1]))], + [SG.Output(size=(80, 20))], + [SG.Multiline(size=(70, 5), enter_submits=True), SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))]] + # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form + # if you call LayoutAndRead from here, then you will miss the first button click + form.Layout(layout) + # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # + while True: + button, value = form.Read() + if button == 'SEND': + print(value) + else: + break + +Tabbed Forms +------------ + +Tabbed forms are shown using the ``ShowTabbedForm`` call. The call has +the format + +:: + + results = ShowTabbedForm('Title for the form', + (form,layout,'Tab 1 label'), + (form2,layout2, 'Tab 2 label'), ...) + +Each of the tabs of the form is in fact a form. The same steps are taken +to create the form as before. A ``FlexForm`` is created, then rows are +filled with Elements, and finally the form is shown. When calling +``ShowTabbedForm``, each form is passed in as a tuple. The tuple has the +format: ``(the form, the rows, a string shown on the tab)`` + +Results are returned as a list of lists. For each form you'll get a list +that's in the same format as a normal form. A single tab's values would +be: + +:: + + (button, (values)) + +Recall that values is a list as well. Multiple tabs in the form would +return like this: + +:: + + ((button1, (values1)), (button2, (values2)) + +## Colors ## Starting in version 2.5 you can change the background +colors for the window and the Elements. + +Your forms can go from this: |snap0155| + +to this... with one function call... + +.. figure:: https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg + :alt: snap0156 + + snap0156 +While you can do it on an element by element or form level basis, the +easiest way, by far, is a call to ``SetOptions``. + +Be aware that once you change these options they are changed for the +rest of your program's execution. All of your forms will have that look +and feel, until you change it to something else (which could be the +system default colors. + +This call sets all of the different color options. + +:: + + SetOptions(background_color='#9FB8AD', + text_element_background_color='#9FB8AD', + element_background_color='#9FB8AD', + scrollbar_color=None, + input_elements_background_color='#F7F3EC', + progress_meter_color = ('green', 'blue') + button_color=('white','#475841')) + +Global Settings +--------------- + +**Global Settings** Let's have some fun customizing! Make PySimpleGUI +look the way you want it to look. You can set the global settings using +the function ``PySimpleGUI.SetOptions``. Each option has an optional +parameter that's used to set it. + +:: + + SetOptions(icon=None + button_color=(None,None) + element_size=(None,None), + margins=(None,None), + element_padding=(None,None) + auto_size_text=None + auto_size_buttons=None + font=None + border_width=None + slider_border_width=None + slider_relief=None + slider_orientation=None + autoclose_time=None + message_box_line_width=None + progress_meter_border_depth=None + progress_meter_style=None + progress_meter_relief=None + progress_meter_color=None + progress_meter_size=None + text_justification=None + background_color=None + element_background_color=None + text_element_background_color=None + input_elements_background_color=None + scrollbar_color=None, text_color=None + debug_win_size=(None,None) + window_location=(None,None) + +Explanation of parameters + +:: + + icon - filename of icon used for taskbar and title bar + button_color - button color (foreground, background) + element_size - element size (width, height) in characters + margins - tkinter margins around outsize + element_padding - tkinter padding around each element + auto_size_text - autosize the elements to fit their text + auto_size_buttons - autosize the buttons to fit their text + font - font used for elements + border_width - amount of bezel or border around sunken or raised elements + slider_border_width - changes the way sliders look + slider_relief - changes the way sliders look + slider_orientation - changes orientation of slider + autoclose_time - time in seconds for autoclose boxes + message_box_line_width - number of characers in a line of text in message boxes + progress_meter_border_depth - amount of border around raised or lowered progress meters + progress_meter_style - style of progress meter as defined by tkinter + progress_meter_relief - relief style + progress_meter_color - color of the bar and background of progress meters + progress_meter_size - size in (characters, pixels) + background_color - Color of the main window's background + element_background_color - Background color of the elements + text_element_background_color - Text element background color + input_elements_background_color - Input fields background color + scrollbar_color - Color for scrollbars (may not always work) + text_color - Text element default text color + text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' + debug_win_size - size of the Print output window + window_location - location on the screen (x,y) of window's top left cornder + +These settings apply to all forms ``SetOptions``. The Row options and +Element options will take precedence over these settings. Settings can +be thought of as levels of settings with the Form-level being the +highest and the Element-level the lowest. Thus the levels are: + +- Form level +- Row level +- Element level + +Each lower level overrides the settings of the higher level. Once +settings have been changed, they remain changed for the duration of the +program (unless changed again). + +Asynchronous (Non-Blocking) Forms +--------------------------------- + +So you want to be a wizard do ya? Well go boldly! While the majority of +GUIs are a simple exercise to "collect input values and return with +them", there are instances where we want to continue executing while the +form is open. These are "asynchronous" forms and require special +options, new SDK calls, and **great care**. With asynchronous forms the +form is shown, user input is read, but your code keeps right on +chugging. YOUR responsibility is to call ``PySimpleGUI.ReadNonBlocking`` +on a periodic basis. Once a second or more will produce a reasonably +snappy GUI. + +When do you use a non-blocking form? A couple of examples are \* A media +file player like an MP3 player \* A status dashboard that's periodically +updated \* Progress Meters - when you want to make your own progress +meters \* Output using print to a scrolled text element. Good for +debugging. + +Word of warning... version 2.2, the currently released, and upcoming +version 2.3 differ in the return code for the ``ReadNonBlocking`` call. +Previously the function returned 2 values, except when the form is +closed using the "X" which returned a single value of ``None``. The +*new* way is that ``ReadNonBlocking`` always returns 2 values. If the +user closed the form with the "X" then the return values will be None, +None. You will want to key off the second value to catch this case. The +proper code to check if the user has exited the form will be a +polling-loop that looks something like this: + +:: + + while True: + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + +We're going to build an app that does the latter. It's going to update +our form with a running clock. + +The basic flow and functions you will be calling are: Setup + +:: + + form = FlexForm() + form_rows = ..... + form.LayoutAndRead(form_rows, non_blocking=True) + +Periodic refresh + +:: + + form.ReadNonBlocking() + +If you need to close the form + +:: + + form.CloseNonBlockingForm() + +Rather than the usual ``form.LayoutAndRead()`` call, we're manually +adding the rows (doing the layout) and then showing the form. After the +form is shown, you simply call ``form.ReadNonBlocking()`` every now and +then. + +When you are ready to close the form (assuming the form wasn't closed by +the user or a button click) you simply call +``form.CloseNonBlockingForm()`` + +**Example - Running timer that updates** See the sample code on the +GitHub named Demo Media Player for another example of Async Forms. We're +going to make a form and update one of the elements of that form every +.01 seconds. Here's the entire code to do that. + +:: + + import PySimpleGUI as sg + import time + + # form that doesn't block + # Make a form, but don't use context manager + form = sg.FlexForm('Running Timer', auto_size_text=True) + # Create a text element that will be updated with status information on the GUI itself + output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) + # Create the rows + form_rows = [[sg.Text('Non-blocking GUI with updates')], + [output_element], + [sg.SimpleButton('Quit')]] + # Layout the rows of the form and perform a read. Indicate the form is non-blocking! + form.LayoutAndRead(form_rows, non_blocking=True) + + # + # Some place later in your code... + # You need to perform a ReadNonBlocking on your form every now and then or + # else it won't refresh + # + + for i in range(1, 1000): + output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + time.sleep(.01) + else: + form.CloseNonBlockingForm() + +What we have here is the same sequence of function calls as in the +description. Get a form, add rows to it, show the form, and then refresh +it every now and then. + +The new thing in this example is the call use of the Update method for +the Text Element. The first thing we do inside the loop is "update" the +text element that we made earlier. This changes the value of the text +field on the form. The new value will be displayed when +``form.ReadNonBlocking()`` is called. + +Note the ``else`` statement on the for loop. This is needed because +we're about to exit the loop while the form is still open. The user has +not closed the form using the X nor a button so it's up to the caller to +close the form using ``CloseNonBlockingForm``. + +That's it... this example follows the async design pattern well. + +Sample Applications +------------------- + +Use the example programs as a starting basis for your GUI. Copy, paste, +modify and run! The demo files are: + +``Demo Recipes.py`` - Sample forms for all major form types and +situations. This is the place to get your code template from. Includes +asynchronous forms, etc. + +``Demo DisplayHash1and256.py`` - Demonstrates using High Level API calls +to get a filename + +``Demo DupliucateFileFinder.py`` - Demonstrates High Level API to get a +folder & Easy Progress Meter to show progress of the file scanning + +``Demo HowDoI.py`` - An amazing little application. Acts as a front-end +to HowDoI. This one program could forever change how you code. It does +searches on Stack Overflow and returns the CODE found in the best answer +for your query. If anyone wants to help me package this application up, +I could use a hand. + +Fun Stuff +--------- + +Here are some things to try if you're bored or want to further customize + +**Colors - Random and predefined** To set a button or text to a random +color, use the string ``'random'`` as the color value. You can also call +``PySimpleGUI.GetRandomColor``. To get a random color pair call +``PySimpleGUI.GetRandomColorPair``. This returns a tuple containing a +random color and that color's compliment. + +**Debug Output** Be sure and check out the EasyPrint (Print) function +described in the high-level API section. Leave your code the way it is, +route your stdout and stderror to a scrolling window. + +For a fun time, add these lines to the top of your script + +:: + + import PySimpleGUI as sg + print = sg.Print + +This will turn all of your print statements into prints that display in +a window on your screen rather than to the terminal. + +**Look and Feel** Dial in the look and feel that you like with the +``SetOptions`` function. You can change all of the defaults in one +function call. One line of code to customize the entire GUI. + +**ObjToString** Ever wanted to easily display an objects contents +easily? Use ObjToString to get a nicely formatted recursive walk of your +objects. This statement: + +:: + + print(sg.ObjToSting(x)) + +And this was the output + +:: + + + abc = abc + attr12 = 12 + c = + b = + a = + attr1 = 1 + attr2 = 2 + attr3 = three + attr10 = 10 + attrx = x + +You'll quickly wonder how you ever coded without it. + +-------------- + +Known Issues +============ + +While not an "issue" this is a ***stern warning*** + +**Do not attempt** to call ``PySimpleGUI`` from multiple threads! It's ``tkinter`` based and ``tkinter`` has issues with multiple threads +----------------------------------------------------------------------------------------------------------------------------------------- + +**Progress Meters** - the visual graphic portion of the meter may be +off. May return to the native tkinter progress meter solution in the +future. Right now a "custom" progress meter is used. On the bright side, +the statistics shown are extremely accurate and can tell you something +about the performance of your code. + +**Async Forms** - these include the 'easy' forms (EasyProgressMeter and +EasyPrint/Print). If you start overlapping having Async forms open with +normal forms then things get a littler squirrelly. Still tracking down +the issues and am making it more solid every day possible. You'll know +there's an issue when you see blank form. + +**EasyPrint** - EasyPrint is a new feature that's pretty awesome. You +print and the output goes to a window, with a scroll bar, that you can +copy and paste from. Being a new feature, it's got some potential +problems. There are known interaction problems with other GUI windows. +For example, closing a Print window can also close other windows you +have open. For now, don't close your debug print window until other +windows are closed too. + +Contributing +------------ + +A MikeTheWatchGuy production... entirely responsible for this code.... +unless it causes you trouble in which case I'm not at all responsible. + +Versions +-------- + ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| Version | Description | ++===========+==================================================================================================================================================+ +| 1.0.9 | July 10, 2018 - Initial Release | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 1.0.21 | July 13, 2018 - Readme updates | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all\_lower\_case | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.1.1 | July 18, 2018 - Global settings exposed, fixes | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.2.0 | July 20, 2018 - Image Elements, Print output | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.6.0 | July 27, 2018 - auto\_size\_button setting. License changed to LGPL 3+ | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +| 2.6.5 | Aug XX, 2018 - window\_location default setting | ++-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + +Release Notes +~~~~~~~~~~~~~ + +2.3 - Sliders, Listbox's and Image elements (oh my!) + +If using Progress Meters, avoid cancelling them when you have another +window open. It could lead to future windows being blank. It's being +worked on. + +New debug printing capability. ``sg.Print`` + +2.5 Discovered issue with scroll bar on ``Output`` elements. The bar +will match size of ROW not the size of the element. Normally you never +notice this due to where on a form the ``Output`` element goes. + +Listboxes are still without scrollwheels. The mouse can drag to see more +items. The mouse scrollwheel will also scroll the list and will +``page up`` and ``page down`` keys. + +Upcoming +~~~~~~~~ + +Make suggestions people! Future release features + +Columns. How multiple columns would be specified in the SDK interface +are still being designed. + +Port to other graphic engines. Hook up the front-end interface to a +backend other than tkinter. Qt, WxPython, etc. + +Code Condition +-------------- + +:: + + Make it run + Make it right + Make it fast + +It's a recipe for success if done right. PySimpleGUI has completed the +"Make it run" phase. It's far from "right" in many ways. These are being +worked on. The module is particularly poor for PEP 8 compliance. It was +a learning exercise that turned into a somewhat complete GUI solution +for lightweight problems. + +While the internals to PySimpleGUI are a tad sketchy, the public +interfaces into the SDK are more strictly defined and comply with PEP 8 +for the most part. + +Please log bugs and suggestions in the GitHub! It will only make the +code stronger and better in the end, a good thing for us all, right? + +Design +------ + +A moment about the design-spirit of ``PySimpleGUI``. From the beginning, +this package was meant to take advantage of Python's capabilities with +the goal of programming ease. + +**Single File** While not the best programming practice, the +implementation resulted in a single file solution. Only one file is +needed, PySimpleGUI.py. You can post this file, email it, and easily +import it using one statement. + +**Functions as objects** In Python, functions behave just like object. +When you're placing a Text Element into your form, you may be sometimes +calling a function and other times declaring an object. If you use the +word Text, then you're getting an object. If you're using ``Txt``, then +you're calling a function that returns a ``Text`` object. + +**Lists** It seemed quite natural to use Python's powerful list +constructs when possible. The form is specified as a series of lists. +Each "row" of the GUI is represented as a list of Elements. When the +form read returns the results to the user, all of the results are +presented as a single list. This makes reading a form's values +super-simple to do in a single line of Python code. + +Authors +------- + +MikeTheWatchGuy + +License +------- + +GNU Lesser General Public License (LGPL 3) + + +Acknowledgments +--------------- + +- Jorj McKie was the motivator behind the entire project. His + wxsimpleGUI concepts sparked PySimpleGUI into existence +- `Fredrik Lundh `__ for his + work on ``tkinter`` + +How Do I +-------- + +Finally, I must thank the fine folks at How Do I. +https://github.com/gleitz/howdoi Their utility has forever changed the +way and pace in which I can program. I urge you to try the HowDoI.py +application here on GitHub. Trust me, **it's going to be worth the +effort!** Here are the steps to run that application + +:: + + Install howdoi: + pip install howdoi + Test your install: + python -m howdoi howdoi.py + To run it: + Python HowDoI.py + +The pip command is all there is to the setup. + +The way HowDoI works is that it uses your search term to look through +stack overflow posts. It finds the best answer, gets the code from the +answer, and presents it as a response. It gives you the correct answer +OFTEN. It's a miracle that it work SO well. For Python questions, I +simply start my query with 'Python'. Let's say you forgot how to reverse +a list in Python. When you run HowDoI and ask this question, this is +what you'll see. |snap0109| + +In the hands of a competent programmer, this tool is **amazing**. It's a +must-try kind of program that has completely changed my programming +process. I'm not afraid of asking for help! You just have to be smart +about using what you find. + +The PySimpleGUI window that the results are shown in is an 'input' field +which means you can copy and paste the results right into your code. + +.. |Downloads| image:: http://pepy.tech/badge/pysimplegui + :target: http://pepy.tech/project/pysimplegui +.. |snap0125| image:: https://user-images.githubusercontent.com/13696193/43114979-a696189e-8ecf-11e8-83c7-473fcf0ccc66.jpg +.. |results 2| image:: https://user-images.githubusercontent.com/13696193/43097502-44e3ed32-8e8a-11e8-9a51-2b8af0b1a682.jpg +.. |snap0155| image:: https://user-images.githubusercontent.com/13696193/43273879-a9fdc10a-90cb-11e8-8c20-4f6a244ebe2f.jpg +.. |snap0109| image:: https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg From 1b19c4e546d688f7bb72b68c448c8a60f52b98d9 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 3 Aug 2018 12:35:46 -0400 Subject: [PATCH 095/209] Removed format literal string --- Demo_DuplicateFileFinder.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Demo_DuplicateFileFinder.py b/Demo_DuplicateFileFinder.py index 40cef6996..958e5f8f4 100644 --- a/Demo_DuplicateFileFinder.py +++ b/Demo_DuplicateFileFinder.py @@ -36,8 +36,7 @@ def FindDuplicatesFilesInFolder(path): continue shatab.append(f_sha) - msg = f'{total} Files processed\n'\ - f'{dup_count} Duplicates found\n' + msg = '{} Files processed\n {} Duplicates found'.format(total_files, dup_count) sg.MsgBox('Duplicate Finder Ended', msg) # ====____====____==== Pseudo-MAIN program ====____====____==== # From 71a60dd80978d5531f663fb2af2ed8da16cbf2af Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 3 Aug 2018 16:45:51 -0400 Subject: [PATCH 096/209] Removed f-string --- Demo_Tabbed_Form.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Demo_Tabbed_Form.py b/Demo_Tabbed_Form.py index 4305a003d..00ac6fd58 100644 --- a/Demo_Tabbed_Form.py +++ b/Demo_Tabbed_Form.py @@ -1,7 +1,5 @@ import PySimpleGUI as sg -MAX_NUMBER_OF_THREADS = 12 - def eBaySuperSearcherGUI(): # Drop Down list of options configs = ('0 - Gruen - Started 2 days ago in Watches', @@ -55,7 +53,7 @@ def eBaySuperSearcherGUI(): [sg.Text('_'*100, size=(80,1))], [sg.Text('Price Range'), sg.InputText(size=(10,1)),sg.Text('To'), sg.InputText(size=(10,1))], [sg.Text('_'*100, size=(80,1))], - [sg.Submit(button_color=('red', 'yellow')), sg.Cancel(button_color=('white', 'blue')), sg.Text(f'{MAX_NUMBER_OF_THREADS} Threads will be started')]] + [sg.Submit(button_color=('red', 'yellow')), sg.Cancel(button_color=('white', 'blue'))]] # First category is default (need to special case this) From 089c6124b8c52ce8b8a082a2bcd118f2ac492275 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 3 Aug 2018 18:40:54 -0400 Subject: [PATCH 097/209] Updated screenshots Fresh screenshots so that the flatter buttons are in the readme. Changed all SG. to sg. --- readme.md | 280 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 144 insertions(+), 136 deletions(-) diff --git a/readme.md b/readme.md index 9b29f3d3d..f03d65375 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,5 @@ + ![pysimplegui_logo](https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png) [![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 @@ -31,7 +32,7 @@ In addition to a primary GUI, you can add a Progress Meter to your code with ONE EasyProgressMeter('My meter title', current_value, max value) -![progress meter 2](https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg) + ![snap0177](https://user-images.githubusercontent.com/13696193/43658025-947973d2-9725-11e8-902f-e2d5effb6e3e.jpg) You can build an async media player GUI with custom buttons in 30 lines of code. @@ -83,29 +84,29 @@ An example of many widgets used on a single form. A little further down you'll Here is the code that produced the above screenshot. - import PySimpleGUI as SG + import PySimpleGUI as sg - with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: layout = [ - [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [SG.Text('Here is some text.... and a place to enter text')], - [SG.InputText()], - [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], - [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], - [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText()], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', scale=(2, 10))], - [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [SG.Text('_' * 100, size=(70, 1))], - [SG.Text('Choose Source and Destination Folders', size=(35, 1))], - [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], - [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), - SG.FolderBrowse()], - [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] + [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [sg.Text('_' * 100, size=(70, 1))], + [sg.Text('Choose Source and Destination Folders', size=(35, 1))], + [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], + [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), + sg.FolderBrowse()], + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] ] button, values = form.LayoutAndRead(layout) @@ -145,17 +146,19 @@ Simply download the file - PySimpleGUI.py and import it into your code Python 3 tkinter -Should run on all Python platforms that have tkinter running on them. Has been thoroughly tested on Windows. While not tested elsewhere, should work on Linux, Mac, Pi, etc. +Runs on all Python platforms that have tkinter running on them. Thoroughly tested on Windows. Runs on Windows, Mac, Linux, Raspberry Pi. Even runs on `pypy3`. ### Using To use in your code, simply import.... - `import PySimpleGUI as SG` + `import PySimpleGUI as sg` Then use either "high level" API calls or build your own forms. - SG.MsgBox('This is my first message box') -![snap0103](https://user-images.githubusercontent.com/13696193/42844641-a04bb798-89e1-11e8-8a37-50ddd9905772.jpg) + sg.MsgBox('This is my first message box') + +![snap0178](https://user-images.githubusercontent.com/13696193/43658024-945c83f8-9725-11e8-8ddd-0bbe67a9fc5d.jpg) + Yes, it's just that easy to have a window appear on the screen using Python. With PySimpleGUI, making a custom form appear isn't much more difficult. The goal is to get you running on your GUI within ***minutes***, not hours nor days. @@ -177,11 +180,12 @@ PySimpleGUI can be broken down into 2 types of API's: The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. - SG.MsgBox('Variable number of parameters example', var1, var2, "etc") + sg.MsgBox('Variable number of parameters example', var1, var2, "etc") Each new item begins on a new line in the Message Box - ![snap0104](https://user-images.githubusercontent.com/13696193/42844739-ebea22ac-89e1-11e8-8dd1-e61441325701.jpg) + ![snap0179](https://user-images.githubusercontent.com/13696193/43658129-f6ca49c6-9725-11e8-9317-1f77443eb04a.jpg) + #### Optional Parameters to a Function Call @@ -201,11 +205,10 @@ Here is the function definition for the MsgBox function. The details aren't impo If the caller wanted to change the button color to be black on yellow, the call would look something like this: - SG.MsgBox('This box has a custom button color', - button_color=('black', 'yellow')) + sg.MsgBox('This box has a custom button color', button_color=('black', 'yellow')) -![snap0105](https://user-images.githubusercontent.com/13696193/42844830-2d7e8b9a-89e2-11e8-8ef4-5af9e36f30f3.jpg) +![snap0180](https://user-images.githubusercontent.com/13696193/43658171-13a72bfe-9726-11e8-8c7a-0a46e46fb202.jpg) --- @@ -216,53 +219,64 @@ The classic "input a value, print result" example. Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. This code prompts user to input a line of text and then displays that text in a messages box: - import PySimpleGUI_local as SG - rc = SG.GetTextBox('Title', 'Please input something') - SG.MsgBox('Results', 'The value returned from GetTextBox', rc) + import PySimpleGUI as sg + + rc = sg.GetTextBox('Title', 'Please input something') + sg.MsgBox('Results', 'The value returned from GetTextBox', rc) + + + ![snap0181](https://user-images.githubusercontent.com/13696193/43658233-48cc7794-9726-11e8-8582-8844280c344e.jpg) -![GetTextBox](https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg) +![snap0182](https://user-images.githubusercontent.com/13696193/43658232-48aaad4e-9726-11e8-95f5-aa9b9213bb77.jpg) -![MsgBox](https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg) #### Message Boxes In addition to MsgBox, you'll find a several API calls that are shortcuts to common messages boxes. You can achieve similar results by calling MsgBox with the correct parameters. The differences tend to be the number and types of buttons. Here are the calls and the windows that are created. - import PySimpleGUI as SG + import PySimpleGUI as sg + + `sg.MsgBoxOK('This is an OK MsgBox')` + + ![ok](https://user-images.githubusercontent.com/13696193/43667331-723ac666-9745-11e8-8666-230c35a6afd6.jpg) + - `SG.MsgBoxOK('This is an OK MsgBox')` + sg.MsgBoxOKCancel('This is an OK Cancel MsgBox') - ![msgboxok](https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg) +![ok cancel 2](https://user-images.githubusercontent.com/13696193/43667330-71d5bea6-9745-11e8-8944-b3900853aa62.jpg) - SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') + sg.MsgBoxCancel('This is a Cancel MsgBox') -![msgboxokcancel](https://user-images.githubusercontent.com/13696193/42599858-8e8eff22-852e-11e8-8d5c-3fe99237eb7f.jpg) +![cancel](https://user-images.githubusercontent.com/13696193/43667329-71a007de-9745-11e8-974b-d028f68798e7.jpg) - SG.MsgBoxCancel('This is a Cancel MsgBox') -![msgboxcancel](https://user-images.githubusercontent.com/13696193/42599857-8e53dc4e-852e-11e8-8e83-6a8cccf8e706.jpg) + sg.MsgBoxYesNo('This is a Yes No MsgBox') - SG.MsgBoxYesNo('This is a Yes No MsgBox') -![msgboxyesno](https://user-images.githubusercontent.com/13696193/42599856-8e304540-852e-11e8-975d-fb2b62e94300.jpg) +![yesno](https://user-images.githubusercontent.com/13696193/43667327-717ff7dc-9745-11e8-9dce-52c305a85101.jpg) - SG.MsgBoxError('This is an error MsgBox') -![msgbox error](https://user-images.githubusercontent.com/13696193/42599853-8df8e078-852e-11e8-90dc-7815d69bff7e.jpg) - SG.MsgBoxAutoClose('This is an autoclose MsgBox') + sg.MsgBoxError('This is an error MsgBox') -![msgbox autoclose](https://user-images.githubusercontent.com/13696193/42599855-8e147572-852e-11e8-8c23-7ec771909062.jpg) +![error msgbox](https://user-images.githubusercontent.com/13696193/43667326-71621712-9745-11e8-87c4-56e2ab500f8e.jpg) - SG.ScrolledTextBox(my_text, height=10) + sg.MsgBoxAutoClose('This is an autoclose MsgBox') -![scrolledtextbox](https://user-images.githubusercontent.com/13696193/42600800-a44f4562-8531-11e8-8c21-51dd70316879.jpg) +![autoclose](https://user-images.githubusercontent.com/13696193/43667325-714997dc-9745-11e8-836a-7185dc80329f.jpg) -Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. Your code could contain a line like: + sg.ScrolledTextBox(my_text, height=10) + +![scrolledtextbox 2](https://user-images.githubusercontent.com/13696193/43667324-712aa0d4-9745-11e8-83a9-a0d0570d0865.jpg) + + +Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing your printed text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. Your code could contain a line like: sprint(f'My variables values include x={x}', f'y={y}') This becomes a debug print of sorts that will route to a scrolled window. +See also the `EasyPrint` and `Print` functions. + #### High Level User Input There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. If you need only 1 value, then perhaps one of these high level functions will work. @@ -270,23 +284,22 @@ There are 3 very basic user input high-level function calls. It's expected that - GetFileBox - GetFolderBox - `submit_clicked, value = SG.GetTextBox('Title', 'Please enter anything')` + `submit_clicked, value = sg.GetTextBox('Title', 'Please enter anything')` -![gettextbox](https://user-images.githubusercontent.com/13696193/42600399-1ef66a5e-8530-11e8-9bc4-78ea839213cd.jpg) +![gettextbox 2](https://user-images.githubusercontent.com/13696193/43667510-355b23a2-9746-11e8-9f1e-91c0dd0f4ed8.jpg) - submit_clicked, value = SG.GetFileBox('Title', 'Choose a file') + submit_clicked, value = sg.GetFileBox('Title', 'Choose a file') -![getfilebox](https://user-images.githubusercontent.com/13696193/42600398-1ed8a122-8530-11e8-9f74-88b101efcea4.jpg) +![getfilebox 2](https://user-images.githubusercontent.com/13696193/43667535-5821fc94-9746-11e8-95c3-82395099e994.jpg) - submit_clicked, value = SG.GetPathBox('Title', 'Choose a folder') + submit_clicked, value = sg.GetPathBox('Title', 'Choose a folder') + +![getpathbox](https://user-images.githubusercontent.com/13696193/43667556-79874c22-9746-11e8-80f2-8262d32802c2.jpg) -![getfolderbox](https://user-images.githubusercontent.com/13696193/42600397-1ea7cef8-8530-11e8-8d43-e1000c0933cd.jpg) #### Progress Meter! We all have loops in our code. 'Isn't it joyful waiting, watching a counter scrolling past in a text window? How about one line of code to get a progress meter, that contains statistics about your code? -![progress meter 3](https://user-images.githubusercontent.com/13696193/42696332-dca3ca6e-8685-11e8-846b-6bee8362ee5f.jpg) - EasyProgressMeter(title, current_value, @@ -302,38 +315,36 @@ We all have loops in our code. 'Isn't it joyful waiting, watching a counter scr Here's the one-line Progress Meter in action! for i in range(1,10000): - SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') + sg.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') That line of code resulted in this window popping up and updating. -![progress meter 5](https://user-images.githubusercontent.com/13696193/42696912-a5c958b8-8687-11e8-9a7d-a390a465407a.jpg) +![preogress meter](https://user-images.githubusercontent.com/13696193/43667625-d47da702-9746-11e8-91e6-e5177883abae.jpg) A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. - if not SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message'): - break - ***Be sure and add one to your loop counter*** so that your counter goes from 1 to the max value. If you do not add one, your counter will never hit the max value. Instead it will go from 0 to max-1. + #### Debug Output Another call in the 'Easy' families of APIs is `EasyPrint`. It will output to a debug window. If the debug window isn't open, then the first call will open it. No need to do anything but stick a 'print' call in your code. You can even replace your 'print' calls with calls to EasyPrint by simply sticking the statement - print = SG.EasyPrint + print = sg.EasyPrint at the top of your code. There are a number of names for the same EasyPrint function. `Print` is one of the better ones to use as it's easy to remember. It is simply `print` with a capital P. - import PySimpleGUI as SG + import PySimpleGUI as sg for i in range(100): - SG.Print(i) + sg.Print(i) ![snap0125](https://user-images.githubusercontent.com/13696193/43114979-a696189e-8ecf-11e8-83c7-473fcf0ccc66.jpg) Or if you didn't want to change your code: - import PySimpleGUI as SG + import PySimpleGUI as sg - print=SG.Print + print=sg.Print for i in range(100): print(i) @@ -450,16 +461,16 @@ Turning back to our example. This GUI roughly looks like this: Going through each line of code in the above form will help explain how to use this design patter. Copy, modify and run it! - with SG.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: + with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: This creates a new form, storing it in the variable `form`. - form_rows = [[SG.Text('SHA-1 and SHA-256 Hashes for the file')], + form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. - [SG.InputText(), SG.FileBrowse()], + [sg.InputText(), sg.FileBrowse()], Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. - [SG.Submit(), SG.Cancel()]] + [sg.Submit(), sg.Cancel()]] The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its value to the caller. @@ -498,27 +509,27 @@ If you have a SINGLE value being returned, it is written this way: ## All Widgets / Elements This code utilizes as many of the elements in one form as possible. - with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: layout = [ - [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [SG.Text('Here is some text.... and a place to enter text')], - [SG.InputText()], - [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], - [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], - [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText()], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', scale=(2, 10))], - [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [SG.Text('_' * 100, size=(70, 1))], - [SG.Text('Choose Source and Destination Folders', size=(35, 1))], - [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], - [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), - SG.FolderBrowse()], - [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] + [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [sg.Text('_' * 100, size=(70, 1))], + [sg.Text('Choose Source and Destination Folders', size=(35, 1))], + [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], + [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), + sg.FolderBrowse()], + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] ] button, values = form.LayoutAndRead(layout) @@ -647,7 +658,7 @@ Building a form is simply making lists of Elements. Each list is a row in the o The code is a crude representation of the GUI, laid out in text. #### Text Element - layout = [[SG.Text('This is what a Text Element looks like')]] + layout = [[sg.Text('This is what a Text Element looks like')]] ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) @@ -698,7 +709,7 @@ The shorthand functions for `Text` are `Txt` and `T` #### Multiline Text Element - layout = [[SG.Multiline('This is what a Multi-line Text Element looks like', size=(45,5))]] + layout = [[sg.Multiline('This is what a Multi-line Text Element looks like', size=(45,5))]] ![multiline text](https://user-images.githubusercontent.com/13696193/42670464-0824c754-8629-11e8-9741-6ed08f924618.jpg) This Element doubles as both an input and output Element. The `DefaultText` optional parameter is used to indicate what to output to the window. @@ -734,7 +745,7 @@ Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. #### Text Input Element - layout = [[SG.InputText('Default text')]] + layout = [[sg.InputText('Default text')]] ![inputtext](https://user-images.githubusercontent.com/13696193/42693515-610a716c-867d-11e8-9a00-7e7fcf771230.jpg) def InputText(default_text = '', @@ -756,7 +767,7 @@ Shorthand functions that are equivalent to `InputText` are `Input` and `In` #### Combo Element Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. - layout = [[SG.InputCombo(['choice 1', 'choice 2'])]] + layout = [[sg.InputCombo(['choice 1', 'choice 2'])]] ![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) @@ -774,7 +785,7 @@ Also known as a drop-down list. Only required parameter is the list of choices. #### Listbox Element The standard listbox like you'll find in most GUIs. Note that the return values from this element will be a ***list of results, not a single result***. This is because the user can select more than 1 item from the list (if you set the right mode). - layout = [[SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6))]] + layout = [[sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6))]] ![snap0130](https://user-images.githubusercontent.com/13696193/43115859-2fbf0646-8ed3-11e8-9979-bbee8eaebfab.jpg) @@ -809,7 +820,7 @@ The `select_mode` option can be a string or a constant value defined as a variab #### Slider Element Sliders have a couple of slider-specific settings as well as appearance settings. Examples include the `orientation` and `range` settings. - layout = [[SG.Slider(range=(1,500), default_value=222, size=(20,15), orientation='horizontal', font=('Helvetica', 12))]] + layout = [[sg.Slider(range=(1,500), default_value=222, size=(20,15), orientation='horizontal', font=('Helvetica', 12))]] ![snap0129](https://user-images.githubusercontent.com/13696193/43115741-e1cb52c8-8ed2-11e8-80bb-0e99ae846ec1.jpg) @@ -841,7 +852,7 @@ Sliders have a couple of slider-specific settings as well as appearance settings #### Radio Button Element Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. - layout = [[SG.Radio('My first Radio!', "RADIO1", default=True), SG.Radio('My second radio!', "RADIO1")]] + layout = [[sg.Radio('My first Radio!', "RADIO1", default=True), sg.Radio('My second radio!', "RADIO1")]] ![radio element](https://user-images.githubusercontent.com/13696193/42705705-327b4b6c-86a2-11e8-81a7-740e57646ba8.jpg) @@ -867,7 +878,7 @@ Creates one radio button that is assigned to a group of radio buttons. Only 1 o #### Checkbox Element Checkbox elements are like Radio Button elements. They return a bool indicating whether or not they are checked. - layout = [[SG.Checkbox('My first Checkbox!', default=True), SG.Checkbox('My second Checkbox!')]] + layout = [[sg.Checkbox('My first Checkbox!', default=True), sg.Checkbox('My second Checkbox!')]] ![checkbox element](https://user-images.githubusercontent.com/13696193/42717015-655d73d2-86cc-11e8-9c69-3c810f48e578.jpg) @@ -891,7 +902,7 @@ Checkbox elements are like Radio Button elements. They return a bool indicating #### Spin Element An up/down spinner control. The valid values are passed in as a list. - layout = [[SG.Spin([i for i in range(1,11)], initial_value=1), SG.Text('Volume level')]] + layout = [[sg.Spin([i for i in range(1,11)], initial_value=1), sg.Text('Volume level')]] ![spin element](https://user-images.githubusercontent.com/13696193/42717231-8ddb51d4-86cd-11e8-827a-75f2237477fa.jpg) @@ -951,7 +962,7 @@ Pre-made buttons include: FileBrowse FolderBrowse . - layout = [[SG.OK(), SG.Cancel()]] + layout = [[sg.OK(), sg.Cancel()]] ![ok cancel](https://user-images.githubusercontent.com/13696193/42717733-1803f584-86d1-11e8-9223-36b782971b9f.jpg) @@ -969,14 +980,14 @@ The `InputText` element is located at (1,0)... row 1, column 0. The `Browse` bu Target = (-1,0) The code for the entire form could be: - layout = [[SG.T('Source Folder')], - [SG.In()], - [SG.FolderBrowse(Target=(-1,0)), SG.OK()]] + layout = [[sg.T('Source Folder')], + [sg.In()], + [sg.FolderBrowse(Target=(-1,0)), sg.OK()]] **Custom Buttons** Not all buttons are created equal. A button that closes a form is different that a button that returns from the form without closing it. If you want to define your own button, you will generally do this with the Button Element `SimpleButton`, which closes the form when clicked. -layout = [[SG.SimpleButton('My Button')]] +layout = [[sg.SimpleButton('My Button')]] ![singlebutton](https://user-images.githubusercontent.com/13696193/42718281-9453deca-86d5-11e8-83c7-4b6d33720858.jpg) @@ -1052,20 +1063,19 @@ The `FileBrowse` button has an additional setting named `file_types`. This vari This code produces a form where the Browse button only shows files of type .TXT - layout = [[SG.In() ,SG.FileBrowse(file_types=(("Text Files", "*.txt"),))]] + layout = [[sg.In() ,sg.FileBrowse(file_types=(("Text Files", "*.txt"),))]] ***The ENTER key*** The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. - ---- + --- #### ProgressBar The `ProgressBar` element is used to build custom Progress Bar forms. It is HIGHLY recommended that you use the functions that provide a complete progress meter solution for you. Progress Meters are not easy to work with because the forms have to be non-blocking and they are tricky to debug. The **easiest** way to get progress meters into your code is to use the `EasyProgessMeter` API. This consists of a pair of functions, `EasyProgessMeter` and `EasyProgressMeterCancel`. You can easily cancel any progress meter by calling it with the current value = max value. This will mark the meter as expired and close the window. You've already seen EasyProgressMeter calls presented earlier in this readme. - SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') + sg.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') The return value for `EasyProgressMeter` is: `True` if meter updated correctly @@ -1091,10 +1101,10 @@ Then to update the bar within your loop *args): Putting it all together you get this design pattern - my_meter = SG.ProgressMeter('Meter Title', 100000, orentation='Vert') + my_meter = sg.ProgressMeter('Meter Title', 100000, orentation='Vert') for i in range(0, 100000): - SG.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') + sg.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') The final way of using a Progress Meter with PySimpleGUI is to build a custom form with a `ProgressBar` Element in the form. You will need to run your form as a non-blocking form. When you are ready to update your progress bar, you call the `UpdateBar` method for the `ProgressBar` element itself. @@ -1108,13 +1118,13 @@ The Output Element is a re-direction of Stdout. Anything "printed" will be disp Here's a complete solution for a chat-window using an Async form with an Output Element - import PySimpleGUI as SG + import PySimpleGUI as sg # Blocking form that doesn't close def ChatBot(): - with SG.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: - layout = [[(SG.Text('This is where standard out is being routed', size=[40, 1]))], - [SG.Output(size=(80, 20))], - [SG.Multiline(size=(70, 5), enter_submits=True), SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))]] + with sg.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + layout = [[(sg.Text('This is where standard out is being routed', size=[40, 1]))], + [sg.Output(size=(80, 20))], + [sg.Multiline(size=(70, 5), enter_submits=True), sg.ReadFormButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0])), sg.SimpleButton('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]] # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form # if you call LayoutAndRead from here, then you will miss the first button click form.Layout(layout) @@ -1178,14 +1188,14 @@ This call sets all of the different color options. Let's have some fun customizing! Make PySimpleGUI look the way you want it to look. You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. SetOptions(icon=None - button_color=(None,None) - element_size=(None,None), - margins=(None,None), - element_padding=(None,None) - auto_size_text=None - auto_size_buttons=None - font=None - border_width=None + button_color=(None,None) + element_size=(None,None), + margins=(None,None), + element_padding=(None,None) + auto_size_text=None + auto_size_buttons=None + font=None + border_width=None slider_border_width=None slider_relief=None slider_orientation=None @@ -1268,9 +1278,9 @@ The basic flow and functions you will be calling are: Setup - form = FlexForm() - form_rows = ..... - form.LayoutAndRead(form_rows, non_blocking=True) + form = FlexForm() + form_rows = ..... + form.LayoutAndRead(form_rows, non_blocking=True) Periodic refresh @@ -1344,10 +1354,6 @@ Use the example programs as a starting basis for your GUI. Copy, paste, modify ## Fun Stuff Here are some things to try if you're bored or want to further customize -**Colors - Random and predefined** -To set a button or text to a random color, use the string `'random'` as the color value. You can also call `PySimpleGUI.GetRandomColor`. -To get a random color pair call `PySimpleGUI.GetRandomColorPair`. This returns a tuple containing a random color and that color's compliment. - **Debug Output** Be sure and check out the EasyPrint (Print) function described in the high-level API section. Leave your code the way it is, route your stdout and stderror to a scrolling window. @@ -1411,7 +1417,8 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi | 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. | 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ -| 2.6.5 | Aug XX, 2018 - window_location default setting +| 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting + ### Release Notes 2.3 - Sliders, Listbox's and Image elements (oh my!) @@ -1424,6 +1431,9 @@ New debug printing capability. `sg.Print` Listboxes are still without scrollwheels. The mouse can drag to see more items. The mouse scrollwheel will also scroll the list and will `page up` and `page down` keys. +2.7 Is the "feature complete" release. Pretty much all features are done and in the code + + ### Upcoming Make suggestions people! Future release features @@ -1493,6 +1503,4 @@ For Python questions, I simply start my query with 'Python'. Let's say you forg In the hands of a competent programmer, this tool is **amazing**. It's a must-try kind of program that has completely changed my programming process. I'm not afraid of asking for help! You just have to be smart about using what you find. -The PySimpleGUI window that the results are shown in is an 'input' field which means you can copy and paste the results right into your code. - - +The PySimpleGUI window that the results are shown in is an 'input' field which means you can copy and paste the results right into your code. \ No newline at end of file From a8b8e146a018c5e4b4394d8dc3ab9842003e87fe Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 3 Aug 2018 18:56:30 -0400 Subject: [PATCH 098/209] Removeed rst docs from docs folder --- docs/README.rst | 1174 ------------------------------------ docs/index.rst | 1174 ------------------------------------ docs/readme.md | 1506 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1506 insertions(+), 2348 deletions(-) delete mode 100644 docs/README.rst delete mode 100644 docs/index.rst create mode 100644 docs/readme.md diff --git a/docs/README.rst b/docs/README.rst deleted file mode 100644 index d7260a069..000000000 --- a/docs/README.rst +++ /dev/null @@ -1,1174 +0,0 @@ -.. figure:: https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png - :alt: pysimplegui\_logo - - pysimplegui\_logo -|Downloads| since Jul 11, 2018 # PySimpleGUI (Ver 2.7) - -Super-simple GUI to grasp... Powerfully customizable. - -Note - *Python3* is required to run PySimpleGUI. It takes advantage of -some Python3 features that do not translate well into Python2. - -Looking to take your Python code from the world of command lines and -into the convenience of a GUI? Have a Raspberry Pi with a touchscreen -that's going to waste because you don't have the time to learn a GUI -SDK? Look no further, you've found your GUI package. - -:: - - import PySimpleGUI as sg - - sg.MsgBox('Hello From PySimpleGUI!', 'This is the shortest GUI program ever!') - -.. figure:: https://user-images.githubusercontent.com/13696193/43162494-33095ece-8f59-11e8-86de-b6d8bcc5a52f.jpg - :alt: snap0136 - - snap0136 -Build beautiful customized forms that fit your specific problem. Let -PySimpleGUI solve your GUI problem while you solve the real problems. Do -you really want to plod through the mountains of code required to -program tkinter? - -.. figure:: https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg - :alt: snap0156 - - snap0156 -Perhaps you're looking for a way to interact with your Raspberry Pi in a -more friendly way. The is the same form as above, except shown on a Pi. - -.. figure:: https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg - :alt: raspberry pi - - raspberry pi -In addition to a primary GUI, you can add a Progress Meter to your code -with ONE LINE of code. Slide this into any of your ``for`` loops and get -a nice meter like this: - -:: - - EasyProgressMeter('My meter title', current_value, max value) - -.. figure:: https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg - :alt: progress meter 2 - - progress meter 2 -You can build an async media player GUI with custom buttons in 30 lines -of code. - -.. figure:: https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg - :alt: media file player - - media file player -I was frustrated by having to deal with the dos prompt when I had a -powerful Windows machine right in front of me. Why is it SO difficult to -do even the simplest of input/output to a window in Python?? - -There are a number of 'easy to use' Python GUIs, but they're **very** -limiting. PySimpleGUI takes the best of packages like ``EasyGUI``\ and -``WxSimpleGUI`` , both really handy but limited. The primary difference -between these and PySimpleGUI is that in addition to getting the simple -Message Boxes you also get the ability to make your own forms that are -highly customizeable. Don't like the standard Message Box? Then make -your own! - -Every call has optional parameters so that you can change the look and -feel. Don't like the button color? It's easy to change by adding a -button\_color parameter to your widget. - -GUI Packages with more functionality, like QT and WxPython, require -configuring and can take a ***week*** to get *reasonably familiar* with -the interfaces. Clearly there needs to be a middle ground between forms -with 1 or two input fields and a full-blown GUI. You'll be making your -own custom forms with PySimpleGUI within minutes, even Async forms. - -With a simple GUI, it becomes practical to "associate" .py files with -the python interpreter on Windows. Double click a py file and up pops a -GUI window, a more pleasant experience than opening a dos Window and -typing a command line. - -The ``PySimpleGUI`` package is focused on the ***developer***. How can -the desired result be achieved in as little and as simple code as -possible? This was the mantra used to create PySimpleGUI. How can it be -done is a Python-like way? - -:: - - Features of PySimpleGUI include: - Text - Single Line Input - Buttons including these types: - File Browse - Folder Browse - Non-closing return - Close form - Realtime - Checkboxes - Radio Buttons - Listbox - Slider - Icons - Multi-line Text Input - Scroll-able Output - Images - Progress Bar - Async/Non-Blocking Windows - Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling window - 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) - Single-Line-Of-Coide Proress Bar & Debug Print - Complete control of colors, look and feel - Button images - -An example of many widgets used on a single form. A little further down -you'll find the TWENTY lines of code required to create this complex -form. Try it if you don't believe it. Start Python, copy and paste the -code below into the >>> prompt and hit enter. This will pop up... - -.. figure:: https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg - :alt: everything example - - everything example -Here is the code that produced the above screenshot. - -:: - - import PySimpleGUI as SG - - with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: - layout = [ - [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [SG.Text('Here is some text.... and a place to enter text')], - [SG.InputText()], - [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], - [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], - [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', - scale=(2, 10))], - [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [SG.Text('_' * 100, size=(70, 1))], - [SG.Text('Choose Source and Destination Folders', size=(35, 1))], - [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], - [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), - SG.FolderBrowse()], - [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] - ] - - button, values = form.LayoutAndRead(layout) - -**A note on screen shots** You will see a number of different styles of -buttons, data entry fields, etc, in this readme. They were all made with -the same SDK, the only difference is in the settings that are specified -on a per-element, row, form, or global basis. One setting in particular, -border\_width, can make a big difference on the look of the form. Some -of the screenshots had a border\_width of 6, others a value of 1. - -APIs ----- - -PySimpleGUI can be broken down into 2 types of API's: \* High Level -single call functions \* Custom form functions - -Python Language Features -~~~~~~~~~~~~~~~~~~~~~~~~ - -There are a couple of Python language features that PySimpleGUI utilizes -heavily that should be understood first... \* Variable number of -arguments to a function call \* Optional parameters to a function call - -Variable Number of Arguments -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The "High Level" API calls that *output* values take a variable number -of arguments so that they match a "print" statement as much as possible. -The idea is to make it simple for the programmer to output as many items -as desired and in any format. The user need not convert the variables to -be output into the strings. The PySimpleGUI functions do that for the -user. - -:: - - SG.MsgBox('Variable number of parameters example', var1, var2, "etc") - -Each new item begins on a new line in the Message Box - -.. figure:: https://user-images.githubusercontent.com/13696193/42844739-ebea22ac-89e1-11e8-8dd1-e61441325701.jpg - :alt: snap0104 - - snap0104 -Optional Parameters to a Function Call -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -This feature of the Python language is utilized ***heavily*** as a -method of customizing forms and form Elements. Rather than requiring the -programmer to specify every possible option for a widget, instead only -the options the caller wants to override are specified. - -Here is the function definition for the MsgBox function. The details -aren't important. What is important is seeing that there is a long list -of potential tweaks that a caller can make. However, they don't *have* -to be specified on each and every call. - -:: - - def MsgBox(*args, - button_color=None, - button_type=MSG_BOX_OK, - auto_close=False, - auto_close_duration=None, - icon=DEFAULT_WINDOW_ICON, - line_width=MESSAGE_BOX_LINE_WIDTH, - font=None): - -If the caller wanted to change the button color to be black on yellow, -the call would look something like this: - -:: - - SG.MsgBox('This box has a custom button color', - button_color=('black', 'yellow')) - -.. figure:: https://user-images.githubusercontent.com/13696193/42844830-2d7e8b9a-89e2-11e8-8ef4-5af9e36f30f3.jpg - :alt: snap0105 - - snap0105 - --------------- - -High Level API Calls -~~~~~~~~~~~~~~~~~~~~ - -The classic "input a value, print result" example. Often command line -programs simply take some value as input on the command line, do -something with it and then display the results. Moving from the command -line to a GUI is very simple. This code prompts user to input a line of -text and then displays that text in a messages box: - -:: - - import PySimpleGUI_local as SG - - rc = SG.GetTextBox('Title', 'Please input something') - SG.MsgBox('Results', 'The value returned from GetTextBox', rc) - -.. figure:: https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg - :alt: GetTextBox - - GetTextBox -.. figure:: https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg - :alt: MsgBox - - MsgBox -Message Boxes -^^^^^^^^^^^^^ - -In addition to MsgBox, you'll find a several API calls that are -shortcuts to common messages boxes. You can achieve similar results by -calling MsgBox with the correct parameters. - -The differences tend to be the number and types of buttons. Here are the -calls and the windows that are created. - -:: - - import PySimpleGUI as SG - -``SG.MsgBoxOK('This is an OK MsgBox')`` - -.. figure:: https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg - :alt: msgboxok - - msgboxok -:: - - SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') - -.. figure:: https://user-images.githubusercontent.com/13696193/42599858-8e8eff22-852e-11e8-8d5c-3fe99237eb7f.jpg - :alt: msgboxokcancel - - msgboxokcancel -:: - - SG.MsgBoxCancel('This is a Cancel MsgBox') - -.. figure:: https://user-images.githubusercontent.com/13696193/42599857-8e53dc4e-852e-11e8-8e83-6a8cccf8e706.jpg - :alt: msgboxcancel - - msgboxcancel -:: - - SG.MsgBoxYesNo('This is a Yes No MsgBox') - -.. figure:: https://user-images.githubusercontent.com/13696193/42599856-8e304540-852e-11e8-975d-fb2b62e94300.jpg - :alt: msgboxyesno - - msgboxyesno -:: - - SG.MsgBoxError('This is an error MsgBox') - -.. figure:: https://user-images.githubusercontent.com/13696193/42599853-8df8e078-852e-11e8-90dc-7815d69bff7e.jpg - :alt: msgbox error - - msgbox error -:: - - SG.MsgBoxAutoClose('This is an autoclose MsgBox') - -.. figure:: https://user-images.githubusercontent.com/13696193/42599855-8e147572-852e-11e8-8c23-7ec771909062.jpg - :alt: msgbox autoclose - - msgbox autoclose -:: - - SG.ScrolledTextBox(my_text, height=10) - -.. figure:: https://user-images.githubusercontent.com/13696193/42600800-a44f4562-8531-11e8-8c21-51dd70316879.jpg - :alt: scrolledtextbox - - scrolledtextbox -Take a moment to look at that last one. It's such a simple API call and -yet the result is awesome. Rather than seeing text scrolling past on -your display, you can capture that text and present it in a scrolled -interface. It's handy enough of an API call that it can also be called -using the name ``sprint`` which is easier to remember than -``ScrollectTextBox``. Your code could contain a line like: - -:: - - sprint(f'My variables values include x={x}', f'y={y}') - -This becomes a debug print of sorts that will route to a scrolled -window. - -High Level User Input -^^^^^^^^^^^^^^^^^^^^^ - -There are 3 very basic user input high-level function calls. It's -expected that for most applications, a custom input form will be -created. If you need only 1 value, then perhaps one of these high level -functions will work. - GetTextBox - GetFileBox - GetFolderBox - -``submit_clicked, value = SG.GetTextBox('Title', 'Please enter anything')`` - -.. figure:: https://user-images.githubusercontent.com/13696193/42600399-1ef66a5e-8530-11e8-9bc4-78ea839213cd.jpg - :alt: gettextbox - - gettextbox -:: - - submit_clicked, value = SG.GetFileBox('Title', 'Choose a file') - -.. figure:: https://user-images.githubusercontent.com/13696193/42600398-1ed8a122-8530-11e8-9f74-88b101efcea4.jpg - :alt: getfilebox - - getfilebox -:: - - submit_clicked, value = SG.GetPathBox('Title', 'Choose a folder') - -.. figure:: https://user-images.githubusercontent.com/13696193/42600397-1ea7cef8-8530-11e8-8d43-e1000c0933cd.jpg - :alt: getfolderbox - - getfolderbox -Progress Meter! -^^^^^^^^^^^^^^^ - -We all have loops in our code. 'Isn't it joyful waiting, watching a -counter scrolling past in a text window? How about one line of code to -get a progress meter, that contains statistics about your code? - -.. figure:: https://user-images.githubusercontent.com/13696193/42696332-dca3ca6e-8685-11e8-846b-6bee8362ee5f.jpg - :alt: progress meter 3 - - progress meter 3 -:: - - EasyProgressMeter(title, - current_value, - max_value, - *args, - orientation=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, - button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), - border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): - -Here's the one-line Progress Meter in action! - -:: - - for i in range(1,10000): - SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') - -That line of code resulted in this window popping up and updating. - -.. figure:: https://user-images.githubusercontent.com/13696193/42696912-a5c958b8-8687-11e8-9a7d-a390a465407a.jpg - :alt: progress meter 5 - - progress meter 5 -A meter AND fun statistics to watch while your machine grinds away, all -for the price of 1 line of code. With a little trickery you can provide -a way to break out of your loop using the Progress Meter form. The -cancel button results in a ``False`` return value from -``EasyProgressMeter``. It normally returns ``True``. - -:: - - if not SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message'): - break - -***Be sure and add one to your loop counter*** so that your counter goes -from 1 to the max value. If you do not add one, your counter will never -hit the max value. Instead it will go from 0 to max-1. #### Debug Output -Another call in the 'Easy' families of APIs is ``EasyPrint``. It will -output to a debug window. If the debug window isn't open, then the first -call will open it. No need to do anything but stick a 'print' call in -your code. You can even replace your 'print' calls with calls to -EasyPrint by simply sticking the statement - -:: - - print = SG.EasyPrint - -at the top of your code. There are a number of names for the same -EasyPrint function. ``Print`` is one of the better ones to use as it's -easy to remember. It is simply ``print`` with a capital P. - -:: - - import PySimpleGUI as SG - - for i in range(100): - SG.Print(i) - -|snap0125| Or if you didn't want to change your code: - -:: - - import PySimpleGUI as SG - - print=SG.Print - for i in range(100): - print(i) - -Just like the standard print call, ``EasyPrint`` supports the ``sep`` -and ``end`` keyword arguments. Other names that can be used to call -``EasyPrint`` include Print, ``eprint``, If you want to close the -window, call the function ``EasyPrintClose``. - -A word of caution. There are known problems when multiple PySimpleGUI -windows are opened, particularly if the user closes them in an unusual -way. Not a reason to stay away from using it. Just something to keep in -mind if you encounter a problem. - -You can change the size of the debug window using the ``SetOptions`` -call with the ``debug_win_size`` parameter. - -All Widgets / Elements ----------------------- - -This code utilizes as many of the elements in one form as possible. - -:: - - with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: - layout = [ - [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [SG.Text('Here is some text.... and a place to enter text')], - [SG.InputText()], - [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], - [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], - [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', - scale=(2, 10))], - [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [SG.Text('_' * 100, size=(70, 1))], - [SG.Text('Choose Source and Destination Folders', size=(35, 1))], - [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], - [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), - SG.FolderBrowse()], - [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] - ] - - button, values = form.LayoutAndRead(layout) - -This is a somewhat complex form with quite a bit of custom sizing to -make things line up well. This is code you only have to write once. When -looking at the code, remember that what you're seeing is a list of -lists. Each row contains a list of Graphical Elements that are used to -create the form. - -.. figure:: https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg - :alt: everything example - - everything example -Clicking the Submit button caused the form call to return. The call to -MsgBox resulted in this dialog box. |results 2| - -**``Note, button value can be None``**. The value for ``button`` will be -the text that is displayed on the button element when it was created. If -the user closed the form using something other than a button, then -``button`` will be ``None``. - -You can see in the MsgBox that the values returned are a list. Each -input field in the form generates one item in the return values list. -All input fields return a ``string`` except for Check Boxes and Radio -Buttons. These return ``bool``. - -ProgressBar -^^^^^^^^^^^ - -The ``ProgressBar`` element is used to build custom Progress Bar forms. -It is HIGHLY recommended that you use the functions that provide a -complete progress meter solution for you. Progress Meters are not easy -to work with because the forms have to be non-blocking and they are -tricky to debug. - -The **easiest** way to get progress meters into your code is to use the -``EasyProgessMeter`` API. This consists of a pair of functions, -``EasyProgessMeter`` and ``EasyProgressMeterCancel``. You can easily -cancel any progress meter by calling it with the current value = max -value. This will mark the meter as expired and close the window. You've -already seen EasyProgressMeter calls presented earlier in this readme. - -:: - - SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') - -The return value for ``EasyProgressMeter`` is: ``True`` if meter updated -correctly ``False`` if user clicked the Cancel button, closed the form, -or vale reached the max value. **Customized Progress Bar** If you want a -bit more customization of your meter, then you can go up 1 level and use -the calls to ``ProgressMeter`` and ``ProgressMeterUpdate``. These APIs -behave like an object we're all used to. First you create the -``ProgressMeter`` object, then you call the ``Update`` method to update -it. - -You setup the progress meter by calling - -:: - - my_meter = ProgressMeter(title, - max_value, - *args, - orientantion=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, - button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), - border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) - -Then to update the bar within your loop - -:: - - return_code = ProgressMeterUpdate(my_meter, - value, - *args): - -Putting it all together you get this design pattern - -:: - - my_meter = SG.ProgressMeter('Meter Title', 100000, orentation='Vert') - - for i in range(0, 100000): - SG.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') - -The final way of using a Progress Meter with PySimpleGUI is to build a -custom form with a ``ProgressBar`` Element in the form. You will need to -run your form as a non-blocking form. When you are ready to update your -progress bar, you call the ``UpdateBar`` method for the ``ProgressBar`` -element itself. - -Output -^^^^^^ - -The Output Element is a re-direction of Stdout. Anything "printed" will -be displayed in this element. - -:: - - Output(scale=(None, None), - size=(None, None)) - -Here's a complete solution for a chat-window using an Async form with an -Output Element - -:: - - import PySimpleGUI as SG - # Blocking form that doesn't close - def ChatBot(): - with SG.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: - layout = [[(SG.Text('This is where standard out is being routed', size=[40, 1]))], - [SG.Output(size=(80, 20))], - [SG.Multiline(size=(70, 5), enter_submits=True), SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))]] - # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form - # if you call LayoutAndRead from here, then you will miss the first button click - form.Layout(layout) - # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # - while True: - button, value = form.Read() - if button == 'SEND': - print(value) - else: - break - -Tabbed Forms ------------- - -Tabbed forms are shown using the ``ShowTabbedForm`` call. The call has -the format - -:: - - results = ShowTabbedForm('Title for the form', - (form,layout,'Tab 1 label'), - (form2,layout2, 'Tab 2 label'), ...) - -Each of the tabs of the form is in fact a form. The same steps are taken -to create the form as before. A ``FlexForm`` is created, then rows are -filled with Elements, and finally the form is shown. When calling -``ShowTabbedForm``, each form is passed in as a tuple. The tuple has the -format: ``(the form, the rows, a string shown on the tab)`` - -Results are returned as a list of lists. For each form you'll get a list -that's in the same format as a normal form. A single tab's values would -be: - -:: - - (button, (values)) - -Recall that values is a list as well. Multiple tabs in the form would -return like this: - -:: - - ((button1, (values1)), (button2, (values2)) - -## Colors ## Starting in version 2.5 you can change the background -colors for the window and the Elements. - -Your forms can go from this: |snap0155| - -to this... with one function call... - -.. figure:: https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg - :alt: snap0156 - - snap0156 -While you can do it on an element by element or form level basis, the -easiest way, by far, is a call to ``SetOptions``. - -Be aware that once you change these options they are changed for the -rest of your program's execution. All of your forms will have that look -and feel, until you change it to something else (which could be the -system default colors. - -This call sets all of the different color options. - -:: - - SetOptions(background_color='#9FB8AD', - text_element_background_color='#9FB8AD', - element_background_color='#9FB8AD', - scrollbar_color=None, - input_elements_background_color='#F7F3EC', - progress_meter_color = ('green', 'blue') - button_color=('white','#475841')) - -Global Settings ---------------- - -**Global Settings** Let's have some fun customizing! Make PySimpleGUI -look the way you want it to look. You can set the global settings using -the function ``PySimpleGUI.SetOptions``. Each option has an optional -parameter that's used to set it. - -:: - - SetOptions(icon=None - button_color=(None,None) - element_size=(None,None), - margins=(None,None), - element_padding=(None,None) - auto_size_text=None - auto_size_buttons=None - font=None - border_width=None - slider_border_width=None - slider_relief=None - slider_orientation=None - autoclose_time=None - message_box_line_width=None - progress_meter_border_depth=None - progress_meter_style=None - progress_meter_relief=None - progress_meter_color=None - progress_meter_size=None - text_justification=None - background_color=None - element_background_color=None - text_element_background_color=None - input_elements_background_color=None - scrollbar_color=None, text_color=None - debug_win_size=(None,None) - window_location=(None,None) - -Explanation of parameters - -:: - - icon - filename of icon used for taskbar and title bar - button_color - button color (foreground, background) - element_size - element size (width, height) in characters - margins - tkinter margins around outsize - element_padding - tkinter padding around each element - auto_size_text - autosize the elements to fit their text - auto_size_buttons - autosize the buttons to fit their text - font - font used for elements - border_width - amount of bezel or border around sunken or raised elements - slider_border_width - changes the way sliders look - slider_relief - changes the way sliders look - slider_orientation - changes orientation of slider - autoclose_time - time in seconds for autoclose boxes - message_box_line_width - number of characers in a line of text in message boxes - progress_meter_border_depth - amount of border around raised or lowered progress meters - progress_meter_style - style of progress meter as defined by tkinter - progress_meter_relief - relief style - progress_meter_color - color of the bar and background of progress meters - progress_meter_size - size in (characters, pixels) - background_color - Color of the main window's background - element_background_color - Background color of the elements - text_element_background_color - Text element background color - input_elements_background_color - Input fields background color - scrollbar_color - Color for scrollbars (may not always work) - text_color - Text element default text color - text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' - debug_win_size - size of the Print output window - window_location - location on the screen (x,y) of window's top left cornder - -These settings apply to all forms ``SetOptions``. The Row options and -Element options will take precedence over these settings. Settings can -be thought of as levels of settings with the Form-level being the -highest and the Element-level the lowest. Thus the levels are: - -- Form level -- Row level -- Element level - -Each lower level overrides the settings of the higher level. Once -settings have been changed, they remain changed for the duration of the -program (unless changed again). - -Asynchronous (Non-Blocking) Forms ---------------------------------- - -So you want to be a wizard do ya? Well go boldly! While the majority of -GUIs are a simple exercise to "collect input values and return with -them", there are instances where we want to continue executing while the -form is open. These are "asynchronous" forms and require special -options, new SDK calls, and **great care**. With asynchronous forms the -form is shown, user input is read, but your code keeps right on -chugging. YOUR responsibility is to call ``PySimpleGUI.ReadNonBlocking`` -on a periodic basis. Once a second or more will produce a reasonably -snappy GUI. - -When do you use a non-blocking form? A couple of examples are \* A media -file player like an MP3 player \* A status dashboard that's periodically -updated \* Progress Meters - when you want to make your own progress -meters \* Output using print to a scrolled text element. Good for -debugging. - -Word of warning... version 2.2, the currently released, and upcoming -version 2.3 differ in the return code for the ``ReadNonBlocking`` call. -Previously the function returned 2 values, except when the form is -closed using the "X" which returned a single value of ``None``. The -*new* way is that ``ReadNonBlocking`` always returns 2 values. If the -user closed the form with the "X" then the return values will be None, -None. You will want to key off the second value to catch this case. The -proper code to check if the user has exited the form will be a -polling-loop that looks something like this: - -:: - - while True: - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': - break - -We're going to build an app that does the latter. It's going to update -our form with a running clock. - -The basic flow and functions you will be calling are: Setup - -:: - - form = FlexForm() - form_rows = ..... - form.LayoutAndRead(form_rows, non_blocking=True) - -Periodic refresh - -:: - - form.ReadNonBlocking() - -If you need to close the form - -:: - - form.CloseNonBlockingForm() - -Rather than the usual ``form.LayoutAndRead()`` call, we're manually -adding the rows (doing the layout) and then showing the form. After the -form is shown, you simply call ``form.ReadNonBlocking()`` every now and -then. - -When you are ready to close the form (assuming the form wasn't closed by -the user or a button click) you simply call -``form.CloseNonBlockingForm()`` - -**Example - Running timer that updates** See the sample code on the -GitHub named Demo Media Player for another example of Async Forms. We're -going to make a form and update one of the elements of that form every -.01 seconds. Here's the entire code to do that. - -:: - - import PySimpleGUI as sg - import time - - # form that doesn't block - # Make a form, but don't use context manager - form = sg.FlexForm('Running Timer', auto_size_text=True) - # Create a text element that will be updated with status information on the GUI itself - output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) - # Create the rows - form_rows = [[sg.Text('Non-blocking GUI with updates')], - [output_element], - [sg.SimpleButton('Quit')]] - # Layout the rows of the form and perform a read. Indicate the form is non-blocking! - form.LayoutAndRead(form_rows, non_blocking=True) - - # - # Some place later in your code... - # You need to perform a ReadNonBlocking on your form every now and then or - # else it won't refresh - # - - for i in range(1, 1000): - output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': - break - time.sleep(.01) - else: - form.CloseNonBlockingForm() - -What we have here is the same sequence of function calls as in the -description. Get a form, add rows to it, show the form, and then refresh -it every now and then. - -The new thing in this example is the call use of the Update method for -the Text Element. The first thing we do inside the loop is "update" the -text element that we made earlier. This changes the value of the text -field on the form. The new value will be displayed when -``form.ReadNonBlocking()`` is called. - -Note the ``else`` statement on the for loop. This is needed because -we're about to exit the loop while the form is still open. The user has -not closed the form using the X nor a button so it's up to the caller to -close the form using ``CloseNonBlockingForm``. - -That's it... this example follows the async design pattern well. - -Sample Applications -------------------- - -Use the example programs as a starting basis for your GUI. Copy, paste, -modify and run! The demo files are: - -``Demo Recipes.py`` - Sample forms for all major form types and -situations. This is the place to get your code template from. Includes -asynchronous forms, etc. - -``Demo DisplayHash1and256.py`` - Demonstrates using High Level API calls -to get a filename - -``Demo DupliucateFileFinder.py`` - Demonstrates High Level API to get a -folder & Easy Progress Meter to show progress of the file scanning - -``Demo HowDoI.py`` - An amazing little application. Acts as a front-end -to HowDoI. This one program could forever change how you code. It does -searches on Stack Overflow and returns the CODE found in the best answer -for your query. If anyone wants to help me package this application up, -I could use a hand. - -Fun Stuff ---------- - -Here are some things to try if you're bored or want to further customize - -**Colors - Random and predefined** To set a button or text to a random -color, use the string ``'random'`` as the color value. You can also call -``PySimpleGUI.GetRandomColor``. To get a random color pair call -``PySimpleGUI.GetRandomColorPair``. This returns a tuple containing a -random color and that color's compliment. - -**Debug Output** Be sure and check out the EasyPrint (Print) function -described in the high-level API section. Leave your code the way it is, -route your stdout and stderror to a scrolling window. - -For a fun time, add these lines to the top of your script - -:: - - import PySimpleGUI as sg - print = sg.Print - -This will turn all of your print statements into prints that display in -a window on your screen rather than to the terminal. - -**Look and Feel** Dial in the look and feel that you like with the -``SetOptions`` function. You can change all of the defaults in one -function call. One line of code to customize the entire GUI. - -**ObjToString** Ever wanted to easily display an objects contents -easily? Use ObjToString to get a nicely formatted recursive walk of your -objects. This statement: - -:: - - print(sg.ObjToSting(x)) - -And this was the output - -:: - - - abc = abc - attr12 = 12 - c = - b = - a = - attr1 = 1 - attr2 = 2 - attr3 = three - attr10 = 10 - attrx = x - -You'll quickly wonder how you ever coded without it. - --------------- - -Known Issues -============ - -While not an "issue" this is a ***stern warning*** - -**Do not attempt** to call ``PySimpleGUI`` from multiple threads! It's ``tkinter`` based and ``tkinter`` has issues with multiple threads ------------------------------------------------------------------------------------------------------------------------------------------ - -**Progress Meters** - the visual graphic portion of the meter may be -off. May return to the native tkinter progress meter solution in the -future. Right now a "custom" progress meter is used. On the bright side, -the statistics shown are extremely accurate and can tell you something -about the performance of your code. - -**Async Forms** - these include the 'easy' forms (EasyProgressMeter and -EasyPrint/Print). If you start overlapping having Async forms open with -normal forms then things get a littler squirrelly. Still tracking down -the issues and am making it more solid every day possible. You'll know -there's an issue when you see blank form. - -**EasyPrint** - EasyPrint is a new feature that's pretty awesome. You -print and the output goes to a window, with a scroll bar, that you can -copy and paste from. Being a new feature, it's got some potential -problems. There are known interaction problems with other GUI windows. -For example, closing a Print window can also close other windows you -have open. For now, don't close your debug print window until other -windows are closed too. - -Contributing ------------- - -A MikeTheWatchGuy production... entirely responsible for this code.... -unless it causes you trouble in which case I'm not at all responsible. - -Versions --------- - -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| Version | Description | -+===========+==================================================================================================================================================+ -| 1.0.9 | July 10, 2018 - Initial Release | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1.0.21 | July 13, 2018 - Readme updates | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all\_lower\_case | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.1.1 | July 18, 2018 - Global settings exposed, fixes | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.2.0 | July 20, 2018 - Image Elements, Print output | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.6.0 | July 27, 2018 - auto\_size\_button setting. License changed to LGPL 3+ | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.6.5 | Aug XX, 2018 - window\_location default setting | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ - -Release Notes -~~~~~~~~~~~~~ - -2.3 - Sliders, Listbox's and Image elements (oh my!) - -If using Progress Meters, avoid cancelling them when you have another -window open. It could lead to future windows being blank. It's being -worked on. - -New debug printing capability. ``sg.Print`` - -2.5 Discovered issue with scroll bar on ``Output`` elements. The bar -will match size of ROW not the size of the element. Normally you never -notice this due to where on a form the ``Output`` element goes. - -Listboxes are still without scrollwheels. The mouse can drag to see more -items. The mouse scrollwheel will also scroll the list and will -``page up`` and ``page down`` keys. - -Upcoming -~~~~~~~~ - -Make suggestions people! Future release features - -Columns. How multiple columns would be specified in the SDK interface -are still being designed. - -Port to other graphic engines. Hook up the front-end interface to a -backend other than tkinter. Qt, WxPython, etc. - -Code Condition --------------- - -:: - - Make it run - Make it right - Make it fast - -It's a recipe for success if done right. PySimpleGUI has completed the -"Make it run" phase. It's far from "right" in many ways. These are being -worked on. The module is particularly poor for PEP 8 compliance. It was -a learning exercise that turned into a somewhat complete GUI solution -for lightweight problems. - -While the internals to PySimpleGUI are a tad sketchy, the public -interfaces into the SDK are more strictly defined and comply with PEP 8 -for the most part. - -Please log bugs and suggestions in the GitHub! It will only make the -code stronger and better in the end, a good thing for us all, right? - -Design ------- - -A moment about the design-spirit of ``PySimpleGUI``. From the beginning, -this package was meant to take advantage of Python's capabilities with -the goal of programming ease. - -**Single File** While not the best programming practice, the -implementation resulted in a single file solution. Only one file is -needed, PySimpleGUI.py. You can post this file, email it, and easily -import it using one statement. - -**Functions as objects** In Python, functions behave just like object. -When you're placing a Text Element into your form, you may be sometimes -calling a function and other times declaring an object. If you use the -word Text, then you're getting an object. If you're using ``Txt``, then -you're calling a function that returns a ``Text`` object. - -**Lists** It seemed quite natural to use Python's powerful list -constructs when possible. The form is specified as a series of lists. -Each "row" of the GUI is represented as a list of Elements. When the -form read returns the results to the user, all of the results are -presented as a single list. This makes reading a form's values -super-simple to do in a single line of Python code. - -Authors -------- - -MikeTheWatchGuy - -License -------- - -GNU Lesser General Public License (LGPL 3) + - -Acknowledgments ---------------- - -- Jorj McKie was the motivator behind the entire project. His - wxsimpleGUI concepts sparked PySimpleGUI into existence -- `Fredrik Lundh `__ for his - work on ``tkinter`` - -How Do I --------- - -Finally, I must thank the fine folks at How Do I. -https://github.com/gleitz/howdoi Their utility has forever changed the -way and pace in which I can program. I urge you to try the HowDoI.py -application here on GitHub. Trust me, **it's going to be worth the -effort!** Here are the steps to run that application - -:: - - Install howdoi: - pip install howdoi - Test your install: - python -m howdoi howdoi.py - To run it: - Python HowDoI.py - -The pip command is all there is to the setup. - -The way HowDoI works is that it uses your search term to look through -stack overflow posts. It finds the best answer, gets the code from the -answer, and presents it as a response. It gives you the correct answer -OFTEN. It's a miracle that it work SO well. For Python questions, I -simply start my query with 'Python'. Let's say you forgot how to reverse -a list in Python. When you run HowDoI and ask this question, this is -what you'll see. |snap0109| - -In the hands of a competent programmer, this tool is **amazing**. It's a -must-try kind of program that has completely changed my programming -process. I'm not afraid of asking for help! You just have to be smart -about using what you find. - -The PySimpleGUI window that the results are shown in is an 'input' field -which means you can copy and paste the results right into your code. - -.. |Downloads| image:: http://pepy.tech/badge/pysimplegui - :target: http://pepy.tech/project/pysimplegui -.. |snap0125| image:: https://user-images.githubusercontent.com/13696193/43114979-a696189e-8ecf-11e8-83c7-473fcf0ccc66.jpg -.. |results 2| image:: https://user-images.githubusercontent.com/13696193/43097502-44e3ed32-8e8a-11e8-9a51-2b8af0b1a682.jpg -.. |snap0155| image:: https://user-images.githubusercontent.com/13696193/43273879-a9fdc10a-90cb-11e8-8c20-4f6a244ebe2f.jpg -.. |snap0109| image:: https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg diff --git a/docs/index.rst b/docs/index.rst deleted file mode 100644 index d7260a069..000000000 --- a/docs/index.rst +++ /dev/null @@ -1,1174 +0,0 @@ -.. figure:: https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png - :alt: pysimplegui\_logo - - pysimplegui\_logo -|Downloads| since Jul 11, 2018 # PySimpleGUI (Ver 2.7) - -Super-simple GUI to grasp... Powerfully customizable. - -Note - *Python3* is required to run PySimpleGUI. It takes advantage of -some Python3 features that do not translate well into Python2. - -Looking to take your Python code from the world of command lines and -into the convenience of a GUI? Have a Raspberry Pi with a touchscreen -that's going to waste because you don't have the time to learn a GUI -SDK? Look no further, you've found your GUI package. - -:: - - import PySimpleGUI as sg - - sg.MsgBox('Hello From PySimpleGUI!', 'This is the shortest GUI program ever!') - -.. figure:: https://user-images.githubusercontent.com/13696193/43162494-33095ece-8f59-11e8-86de-b6d8bcc5a52f.jpg - :alt: snap0136 - - snap0136 -Build beautiful customized forms that fit your specific problem. Let -PySimpleGUI solve your GUI problem while you solve the real problems. Do -you really want to plod through the mountains of code required to -program tkinter? - -.. figure:: https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg - :alt: snap0156 - - snap0156 -Perhaps you're looking for a way to interact with your Raspberry Pi in a -more friendly way. The is the same form as above, except shown on a Pi. - -.. figure:: https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg - :alt: raspberry pi - - raspberry pi -In addition to a primary GUI, you can add a Progress Meter to your code -with ONE LINE of code. Slide this into any of your ``for`` loops and get -a nice meter like this: - -:: - - EasyProgressMeter('My meter title', current_value, max value) - -.. figure:: https://user-images.githubusercontent.com/13696193/42695896-a37eff5c-8684-11e8-8fbb-3d756655a44b.jpg - :alt: progress meter 2 - - progress meter 2 -You can build an async media player GUI with custom buttons in 30 lines -of code. - -.. figure:: https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg - :alt: media file player - - media file player -I was frustrated by having to deal with the dos prompt when I had a -powerful Windows machine right in front of me. Why is it SO difficult to -do even the simplest of input/output to a window in Python?? - -There are a number of 'easy to use' Python GUIs, but they're **very** -limiting. PySimpleGUI takes the best of packages like ``EasyGUI``\ and -``WxSimpleGUI`` , both really handy but limited. The primary difference -between these and PySimpleGUI is that in addition to getting the simple -Message Boxes you also get the ability to make your own forms that are -highly customizeable. Don't like the standard Message Box? Then make -your own! - -Every call has optional parameters so that you can change the look and -feel. Don't like the button color? It's easy to change by adding a -button\_color parameter to your widget. - -GUI Packages with more functionality, like QT and WxPython, require -configuring and can take a ***week*** to get *reasonably familiar* with -the interfaces. Clearly there needs to be a middle ground between forms -with 1 or two input fields and a full-blown GUI. You'll be making your -own custom forms with PySimpleGUI within minutes, even Async forms. - -With a simple GUI, it becomes practical to "associate" .py files with -the python interpreter on Windows. Double click a py file and up pops a -GUI window, a more pleasant experience than opening a dos Window and -typing a command line. - -The ``PySimpleGUI`` package is focused on the ***developer***. How can -the desired result be achieved in as little and as simple code as -possible? This was the mantra used to create PySimpleGUI. How can it be -done is a Python-like way? - -:: - - Features of PySimpleGUI include: - Text - Single Line Input - Buttons including these types: - File Browse - Folder Browse - Non-closing return - Close form - Realtime - Checkboxes - Radio Buttons - Listbox - Slider - Icons - Multi-line Text Input - Scroll-able Output - Images - Progress Bar - Async/Non-Blocking Windows - Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling window - 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) - Single-Line-Of-Coide Proress Bar & Debug Print - Complete control of colors, look and feel - Button images - -An example of many widgets used on a single form. A little further down -you'll find the TWENTY lines of code required to create this complex -form. Try it if you don't believe it. Start Python, copy and paste the -code below into the >>> prompt and hit enter. This will pop up... - -.. figure:: https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg - :alt: everything example - - everything example -Here is the code that produced the above screenshot. - -:: - - import PySimpleGUI as SG - - with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: - layout = [ - [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [SG.Text('Here is some text.... and a place to enter text')], - [SG.InputText()], - [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], - [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], - [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', - scale=(2, 10))], - [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [SG.Text('_' * 100, size=(70, 1))], - [SG.Text('Choose Source and Destination Folders', size=(35, 1))], - [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], - [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), - SG.FolderBrowse()], - [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] - ] - - button, values = form.LayoutAndRead(layout) - -**A note on screen shots** You will see a number of different styles of -buttons, data entry fields, etc, in this readme. They were all made with -the same SDK, the only difference is in the settings that are specified -on a per-element, row, form, or global basis. One setting in particular, -border\_width, can make a big difference on the look of the form. Some -of the screenshots had a border\_width of 6, others a value of 1. - -APIs ----- - -PySimpleGUI can be broken down into 2 types of API's: \* High Level -single call functions \* Custom form functions - -Python Language Features -~~~~~~~~~~~~~~~~~~~~~~~~ - -There are a couple of Python language features that PySimpleGUI utilizes -heavily that should be understood first... \* Variable number of -arguments to a function call \* Optional parameters to a function call - -Variable Number of Arguments -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The "High Level" API calls that *output* values take a variable number -of arguments so that they match a "print" statement as much as possible. -The idea is to make it simple for the programmer to output as many items -as desired and in any format. The user need not convert the variables to -be output into the strings. The PySimpleGUI functions do that for the -user. - -:: - - SG.MsgBox('Variable number of parameters example', var1, var2, "etc") - -Each new item begins on a new line in the Message Box - -.. figure:: https://user-images.githubusercontent.com/13696193/42844739-ebea22ac-89e1-11e8-8dd1-e61441325701.jpg - :alt: snap0104 - - snap0104 -Optional Parameters to a Function Call -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -This feature of the Python language is utilized ***heavily*** as a -method of customizing forms and form Elements. Rather than requiring the -programmer to specify every possible option for a widget, instead only -the options the caller wants to override are specified. - -Here is the function definition for the MsgBox function. The details -aren't important. What is important is seeing that there is a long list -of potential tweaks that a caller can make. However, they don't *have* -to be specified on each and every call. - -:: - - def MsgBox(*args, - button_color=None, - button_type=MSG_BOX_OK, - auto_close=False, - auto_close_duration=None, - icon=DEFAULT_WINDOW_ICON, - line_width=MESSAGE_BOX_LINE_WIDTH, - font=None): - -If the caller wanted to change the button color to be black on yellow, -the call would look something like this: - -:: - - SG.MsgBox('This box has a custom button color', - button_color=('black', 'yellow')) - -.. figure:: https://user-images.githubusercontent.com/13696193/42844830-2d7e8b9a-89e2-11e8-8ef4-5af9e36f30f3.jpg - :alt: snap0105 - - snap0105 - --------------- - -High Level API Calls -~~~~~~~~~~~~~~~~~~~~ - -The classic "input a value, print result" example. Often command line -programs simply take some value as input on the command line, do -something with it and then display the results. Moving from the command -line to a GUI is very simple. This code prompts user to input a line of -text and then displays that text in a messages box: - -:: - - import PySimpleGUI_local as SG - - rc = SG.GetTextBox('Title', 'Please input something') - SG.MsgBox('Results', 'The value returned from GetTextBox', rc) - -.. figure:: https://user-images.githubusercontent.com/13696193/42592930-1ca1370a-8519-11e8-907e-ad73e9be7749.jpg - :alt: GetTextBox - - GetTextBox -.. figure:: https://user-images.githubusercontent.com/13696193/42592929-1c7361ae-8519-11e8-8adc-411c1afee69f.jpg - :alt: MsgBox - - MsgBox -Message Boxes -^^^^^^^^^^^^^ - -In addition to MsgBox, you'll find a several API calls that are -shortcuts to common messages boxes. You can achieve similar results by -calling MsgBox with the correct parameters. - -The differences tend to be the number and types of buttons. Here are the -calls and the windows that are created. - -:: - - import PySimpleGUI as SG - -``SG.MsgBoxOK('This is an OK MsgBox')`` - -.. figure:: https://user-images.githubusercontent.com/13696193/42599852-8dd6914e-852e-11e8-888f-f133d787210b.jpg - :alt: msgboxok - - msgboxok -:: - - SG.MsgBoxOKCancel('This is an OK Cancel MsgBox') - -.. figure:: https://user-images.githubusercontent.com/13696193/42599858-8e8eff22-852e-11e8-8d5c-3fe99237eb7f.jpg - :alt: msgboxokcancel - - msgboxokcancel -:: - - SG.MsgBoxCancel('This is a Cancel MsgBox') - -.. figure:: https://user-images.githubusercontent.com/13696193/42599857-8e53dc4e-852e-11e8-8e83-6a8cccf8e706.jpg - :alt: msgboxcancel - - msgboxcancel -:: - - SG.MsgBoxYesNo('This is a Yes No MsgBox') - -.. figure:: https://user-images.githubusercontent.com/13696193/42599856-8e304540-852e-11e8-975d-fb2b62e94300.jpg - :alt: msgboxyesno - - msgboxyesno -:: - - SG.MsgBoxError('This is an error MsgBox') - -.. figure:: https://user-images.githubusercontent.com/13696193/42599853-8df8e078-852e-11e8-90dc-7815d69bff7e.jpg - :alt: msgbox error - - msgbox error -:: - - SG.MsgBoxAutoClose('This is an autoclose MsgBox') - -.. figure:: https://user-images.githubusercontent.com/13696193/42599855-8e147572-852e-11e8-8c23-7ec771909062.jpg - :alt: msgbox autoclose - - msgbox autoclose -:: - - SG.ScrolledTextBox(my_text, height=10) - -.. figure:: https://user-images.githubusercontent.com/13696193/42600800-a44f4562-8531-11e8-8c21-51dd70316879.jpg - :alt: scrolledtextbox - - scrolledtextbox -Take a moment to look at that last one. It's such a simple API call and -yet the result is awesome. Rather than seeing text scrolling past on -your display, you can capture that text and present it in a scrolled -interface. It's handy enough of an API call that it can also be called -using the name ``sprint`` which is easier to remember than -``ScrollectTextBox``. Your code could contain a line like: - -:: - - sprint(f'My variables values include x={x}', f'y={y}') - -This becomes a debug print of sorts that will route to a scrolled -window. - -High Level User Input -^^^^^^^^^^^^^^^^^^^^^ - -There are 3 very basic user input high-level function calls. It's -expected that for most applications, a custom input form will be -created. If you need only 1 value, then perhaps one of these high level -functions will work. - GetTextBox - GetFileBox - GetFolderBox - -``submit_clicked, value = SG.GetTextBox('Title', 'Please enter anything')`` - -.. figure:: https://user-images.githubusercontent.com/13696193/42600399-1ef66a5e-8530-11e8-9bc4-78ea839213cd.jpg - :alt: gettextbox - - gettextbox -:: - - submit_clicked, value = SG.GetFileBox('Title', 'Choose a file') - -.. figure:: https://user-images.githubusercontent.com/13696193/42600398-1ed8a122-8530-11e8-9f74-88b101efcea4.jpg - :alt: getfilebox - - getfilebox -:: - - submit_clicked, value = SG.GetPathBox('Title', 'Choose a folder') - -.. figure:: https://user-images.githubusercontent.com/13696193/42600397-1ea7cef8-8530-11e8-8d43-e1000c0933cd.jpg - :alt: getfolderbox - - getfolderbox -Progress Meter! -^^^^^^^^^^^^^^^ - -We all have loops in our code. 'Isn't it joyful waiting, watching a -counter scrolling past in a text window? How about one line of code to -get a progress meter, that contains statistics about your code? - -.. figure:: https://user-images.githubusercontent.com/13696193/42696332-dca3ca6e-8685-11e8-846b-6bee8362ee5f.jpg - :alt: progress meter 3 - - progress meter 3 -:: - - EasyProgressMeter(title, - current_value, - max_value, - *args, - orientation=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, - button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), - border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): - -Here's the one-line Progress Meter in action! - -:: - - for i in range(1,10000): - SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') - -That line of code resulted in this window popping up and updating. - -.. figure:: https://user-images.githubusercontent.com/13696193/42696912-a5c958b8-8687-11e8-9a7d-a390a465407a.jpg - :alt: progress meter 5 - - progress meter 5 -A meter AND fun statistics to watch while your machine grinds away, all -for the price of 1 line of code. With a little trickery you can provide -a way to break out of your loop using the Progress Meter form. The -cancel button results in a ``False`` return value from -``EasyProgressMeter``. It normally returns ``True``. - -:: - - if not SG.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message'): - break - -***Be sure and add one to your loop counter*** so that your counter goes -from 1 to the max value. If you do not add one, your counter will never -hit the max value. Instead it will go from 0 to max-1. #### Debug Output -Another call in the 'Easy' families of APIs is ``EasyPrint``. It will -output to a debug window. If the debug window isn't open, then the first -call will open it. No need to do anything but stick a 'print' call in -your code. You can even replace your 'print' calls with calls to -EasyPrint by simply sticking the statement - -:: - - print = SG.EasyPrint - -at the top of your code. There are a number of names for the same -EasyPrint function. ``Print`` is one of the better ones to use as it's -easy to remember. It is simply ``print`` with a capital P. - -:: - - import PySimpleGUI as SG - - for i in range(100): - SG.Print(i) - -|snap0125| Or if you didn't want to change your code: - -:: - - import PySimpleGUI as SG - - print=SG.Print - for i in range(100): - print(i) - -Just like the standard print call, ``EasyPrint`` supports the ``sep`` -and ``end`` keyword arguments. Other names that can be used to call -``EasyPrint`` include Print, ``eprint``, If you want to close the -window, call the function ``EasyPrintClose``. - -A word of caution. There are known problems when multiple PySimpleGUI -windows are opened, particularly if the user closes them in an unusual -way. Not a reason to stay away from using it. Just something to keep in -mind if you encounter a problem. - -You can change the size of the debug window using the ``SetOptions`` -call with the ``debug_win_size`` parameter. - -All Widgets / Elements ----------------------- - -This code utilizes as many of the elements in one form as possible. - -:: - - with SG.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: - layout = [ - [SG.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [SG.Text('Here is some text.... and a place to enter text')], - [SG.InputText()], - [SG.Checkbox('My first checkbox!'), SG.Checkbox('My second checkbox!', default=True)], - [SG.Radio('My first Radio! ', "RADIO1", default=True), SG.Radio('My second Radio!', "RADIO1")], - [SG.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', - scale=(2, 10))], - [SG.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - SG.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [SG.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - SG.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [SG.Text('_' * 100, size=(70, 1))], - [SG.Text('Choose Source and Destination Folders', size=(35, 1))], - [SG.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Source'), SG.FolderBrowse()], - [SG.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), SG.InputText('Dest'), - SG.FolderBrowse()], - [SG.Submit(), SG.Cancel(), SG.SimpleButton('Customized', button_color=('white', 'green'))] - ] - - button, values = form.LayoutAndRead(layout) - -This is a somewhat complex form with quite a bit of custom sizing to -make things line up well. This is code you only have to write once. When -looking at the code, remember that what you're seeing is a list of -lists. Each row contains a list of Graphical Elements that are used to -create the form. - -.. figure:: https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg - :alt: everything example - - everything example -Clicking the Submit button caused the form call to return. The call to -MsgBox resulted in this dialog box. |results 2| - -**``Note, button value can be None``**. The value for ``button`` will be -the text that is displayed on the button element when it was created. If -the user closed the form using something other than a button, then -``button`` will be ``None``. - -You can see in the MsgBox that the values returned are a list. Each -input field in the form generates one item in the return values list. -All input fields return a ``string`` except for Check Boxes and Radio -Buttons. These return ``bool``. - -ProgressBar -^^^^^^^^^^^ - -The ``ProgressBar`` element is used to build custom Progress Bar forms. -It is HIGHLY recommended that you use the functions that provide a -complete progress meter solution for you. Progress Meters are not easy -to work with because the forms have to be non-blocking and they are -tricky to debug. - -The **easiest** way to get progress meters into your code is to use the -``EasyProgessMeter`` API. This consists of a pair of functions, -``EasyProgessMeter`` and ``EasyProgressMeterCancel``. You can easily -cancel any progress meter by calling it with the current value = max -value. This will mark the meter as expired and close the window. You've -already seen EasyProgressMeter calls presented earlier in this readme. - -:: - - SG.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') - -The return value for ``EasyProgressMeter`` is: ``True`` if meter updated -correctly ``False`` if user clicked the Cancel button, closed the form, -or vale reached the max value. **Customized Progress Bar** If you want a -bit more customization of your meter, then you can go up 1 level and use -the calls to ``ProgressMeter`` and ``ProgressMeterUpdate``. These APIs -behave like an object we're all used to. First you create the -``ProgressMeter`` object, then you call the ``Update`` method to update -it. - -You setup the progress meter by calling - -:: - - my_meter = ProgressMeter(title, - max_value, - *args, - orientantion=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, - button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), - border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) - -Then to update the bar within your loop - -:: - - return_code = ProgressMeterUpdate(my_meter, - value, - *args): - -Putting it all together you get this design pattern - -:: - - my_meter = SG.ProgressMeter('Meter Title', 100000, orentation='Vert') - - for i in range(0, 100000): - SG.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') - -The final way of using a Progress Meter with PySimpleGUI is to build a -custom form with a ``ProgressBar`` Element in the form. You will need to -run your form as a non-blocking form. When you are ready to update your -progress bar, you call the ``UpdateBar`` method for the ``ProgressBar`` -element itself. - -Output -^^^^^^ - -The Output Element is a re-direction of Stdout. Anything "printed" will -be displayed in this element. - -:: - - Output(scale=(None, None), - size=(None, None)) - -Here's a complete solution for a chat-window using an Async form with an -Output Element - -:: - - import PySimpleGUI as SG - # Blocking form that doesn't close - def ChatBot(): - with SG.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: - layout = [[(SG.Text('This is where standard out is being routed', size=[40, 1]))], - [SG.Output(size=(80, 20))], - [SG.Multiline(size=(70, 5), enter_submits=True), SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))]] - # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form - # if you call LayoutAndRead from here, then you will miss the first button click - form.Layout(layout) - # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # - while True: - button, value = form.Read() - if button == 'SEND': - print(value) - else: - break - -Tabbed Forms ------------- - -Tabbed forms are shown using the ``ShowTabbedForm`` call. The call has -the format - -:: - - results = ShowTabbedForm('Title for the form', - (form,layout,'Tab 1 label'), - (form2,layout2, 'Tab 2 label'), ...) - -Each of the tabs of the form is in fact a form. The same steps are taken -to create the form as before. A ``FlexForm`` is created, then rows are -filled with Elements, and finally the form is shown. When calling -``ShowTabbedForm``, each form is passed in as a tuple. The tuple has the -format: ``(the form, the rows, a string shown on the tab)`` - -Results are returned as a list of lists. For each form you'll get a list -that's in the same format as a normal form. A single tab's values would -be: - -:: - - (button, (values)) - -Recall that values is a list as well. Multiple tabs in the form would -return like this: - -:: - - ((button1, (values1)), (button2, (values2)) - -## Colors ## Starting in version 2.5 you can change the background -colors for the window and the Elements. - -Your forms can go from this: |snap0155| - -to this... with one function call... - -.. figure:: https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg - :alt: snap0156 - - snap0156 -While you can do it on an element by element or form level basis, the -easiest way, by far, is a call to ``SetOptions``. - -Be aware that once you change these options they are changed for the -rest of your program's execution. All of your forms will have that look -and feel, until you change it to something else (which could be the -system default colors. - -This call sets all of the different color options. - -:: - - SetOptions(background_color='#9FB8AD', - text_element_background_color='#9FB8AD', - element_background_color='#9FB8AD', - scrollbar_color=None, - input_elements_background_color='#F7F3EC', - progress_meter_color = ('green', 'blue') - button_color=('white','#475841')) - -Global Settings ---------------- - -**Global Settings** Let's have some fun customizing! Make PySimpleGUI -look the way you want it to look. You can set the global settings using -the function ``PySimpleGUI.SetOptions``. Each option has an optional -parameter that's used to set it. - -:: - - SetOptions(icon=None - button_color=(None,None) - element_size=(None,None), - margins=(None,None), - element_padding=(None,None) - auto_size_text=None - auto_size_buttons=None - font=None - border_width=None - slider_border_width=None - slider_relief=None - slider_orientation=None - autoclose_time=None - message_box_line_width=None - progress_meter_border_depth=None - progress_meter_style=None - progress_meter_relief=None - progress_meter_color=None - progress_meter_size=None - text_justification=None - background_color=None - element_background_color=None - text_element_background_color=None - input_elements_background_color=None - scrollbar_color=None, text_color=None - debug_win_size=(None,None) - window_location=(None,None) - -Explanation of parameters - -:: - - icon - filename of icon used for taskbar and title bar - button_color - button color (foreground, background) - element_size - element size (width, height) in characters - margins - tkinter margins around outsize - element_padding - tkinter padding around each element - auto_size_text - autosize the elements to fit their text - auto_size_buttons - autosize the buttons to fit their text - font - font used for elements - border_width - amount of bezel or border around sunken or raised elements - slider_border_width - changes the way sliders look - slider_relief - changes the way sliders look - slider_orientation - changes orientation of slider - autoclose_time - time in seconds for autoclose boxes - message_box_line_width - number of characers in a line of text in message boxes - progress_meter_border_depth - amount of border around raised or lowered progress meters - progress_meter_style - style of progress meter as defined by tkinter - progress_meter_relief - relief style - progress_meter_color - color of the bar and background of progress meters - progress_meter_size - size in (characters, pixels) - background_color - Color of the main window's background - element_background_color - Background color of the elements - text_element_background_color - Text element background color - input_elements_background_color - Input fields background color - scrollbar_color - Color for scrollbars (may not always work) - text_color - Text element default text color - text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' - debug_win_size - size of the Print output window - window_location - location on the screen (x,y) of window's top left cornder - -These settings apply to all forms ``SetOptions``. The Row options and -Element options will take precedence over these settings. Settings can -be thought of as levels of settings with the Form-level being the -highest and the Element-level the lowest. Thus the levels are: - -- Form level -- Row level -- Element level - -Each lower level overrides the settings of the higher level. Once -settings have been changed, they remain changed for the duration of the -program (unless changed again). - -Asynchronous (Non-Blocking) Forms ---------------------------------- - -So you want to be a wizard do ya? Well go boldly! While the majority of -GUIs are a simple exercise to "collect input values and return with -them", there are instances where we want to continue executing while the -form is open. These are "asynchronous" forms and require special -options, new SDK calls, and **great care**. With asynchronous forms the -form is shown, user input is read, but your code keeps right on -chugging. YOUR responsibility is to call ``PySimpleGUI.ReadNonBlocking`` -on a periodic basis. Once a second or more will produce a reasonably -snappy GUI. - -When do you use a non-blocking form? A couple of examples are \* A media -file player like an MP3 player \* A status dashboard that's periodically -updated \* Progress Meters - when you want to make your own progress -meters \* Output using print to a scrolled text element. Good for -debugging. - -Word of warning... version 2.2, the currently released, and upcoming -version 2.3 differ in the return code for the ``ReadNonBlocking`` call. -Previously the function returned 2 values, except when the form is -closed using the "X" which returned a single value of ``None``. The -*new* way is that ``ReadNonBlocking`` always returns 2 values. If the -user closed the form with the "X" then the return values will be None, -None. You will want to key off the second value to catch this case. The -proper code to check if the user has exited the form will be a -polling-loop that looks something like this: - -:: - - while True: - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': - break - -We're going to build an app that does the latter. It's going to update -our form with a running clock. - -The basic flow and functions you will be calling are: Setup - -:: - - form = FlexForm() - form_rows = ..... - form.LayoutAndRead(form_rows, non_blocking=True) - -Periodic refresh - -:: - - form.ReadNonBlocking() - -If you need to close the form - -:: - - form.CloseNonBlockingForm() - -Rather than the usual ``form.LayoutAndRead()`` call, we're manually -adding the rows (doing the layout) and then showing the form. After the -form is shown, you simply call ``form.ReadNonBlocking()`` every now and -then. - -When you are ready to close the form (assuming the form wasn't closed by -the user or a button click) you simply call -``form.CloseNonBlockingForm()`` - -**Example - Running timer that updates** See the sample code on the -GitHub named Demo Media Player for another example of Async Forms. We're -going to make a form and update one of the elements of that form every -.01 seconds. Here's the entire code to do that. - -:: - - import PySimpleGUI as sg - import time - - # form that doesn't block - # Make a form, but don't use context manager - form = sg.FlexForm('Running Timer', auto_size_text=True) - # Create a text element that will be updated with status information on the GUI itself - output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) - # Create the rows - form_rows = [[sg.Text('Non-blocking GUI with updates')], - [output_element], - [sg.SimpleButton('Quit')]] - # Layout the rows of the form and perform a read. Indicate the form is non-blocking! - form.LayoutAndRead(form_rows, non_blocking=True) - - # - # Some place later in your code... - # You need to perform a ReadNonBlocking on your form every now and then or - # else it won't refresh - # - - for i in range(1, 1000): - output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': - break - time.sleep(.01) - else: - form.CloseNonBlockingForm() - -What we have here is the same sequence of function calls as in the -description. Get a form, add rows to it, show the form, and then refresh -it every now and then. - -The new thing in this example is the call use of the Update method for -the Text Element. The first thing we do inside the loop is "update" the -text element that we made earlier. This changes the value of the text -field on the form. The new value will be displayed when -``form.ReadNonBlocking()`` is called. - -Note the ``else`` statement on the for loop. This is needed because -we're about to exit the loop while the form is still open. The user has -not closed the form using the X nor a button so it's up to the caller to -close the form using ``CloseNonBlockingForm``. - -That's it... this example follows the async design pattern well. - -Sample Applications -------------------- - -Use the example programs as a starting basis for your GUI. Copy, paste, -modify and run! The demo files are: - -``Demo Recipes.py`` - Sample forms for all major form types and -situations. This is the place to get your code template from. Includes -asynchronous forms, etc. - -``Demo DisplayHash1and256.py`` - Demonstrates using High Level API calls -to get a filename - -``Demo DupliucateFileFinder.py`` - Demonstrates High Level API to get a -folder & Easy Progress Meter to show progress of the file scanning - -``Demo HowDoI.py`` - An amazing little application. Acts as a front-end -to HowDoI. This one program could forever change how you code. It does -searches on Stack Overflow and returns the CODE found in the best answer -for your query. If anyone wants to help me package this application up, -I could use a hand. - -Fun Stuff ---------- - -Here are some things to try if you're bored or want to further customize - -**Colors - Random and predefined** To set a button or text to a random -color, use the string ``'random'`` as the color value. You can also call -``PySimpleGUI.GetRandomColor``. To get a random color pair call -``PySimpleGUI.GetRandomColorPair``. This returns a tuple containing a -random color and that color's compliment. - -**Debug Output** Be sure and check out the EasyPrint (Print) function -described in the high-level API section. Leave your code the way it is, -route your stdout and stderror to a scrolling window. - -For a fun time, add these lines to the top of your script - -:: - - import PySimpleGUI as sg - print = sg.Print - -This will turn all of your print statements into prints that display in -a window on your screen rather than to the terminal. - -**Look and Feel** Dial in the look and feel that you like with the -``SetOptions`` function. You can change all of the defaults in one -function call. One line of code to customize the entire GUI. - -**ObjToString** Ever wanted to easily display an objects contents -easily? Use ObjToString to get a nicely formatted recursive walk of your -objects. This statement: - -:: - - print(sg.ObjToSting(x)) - -And this was the output - -:: - - - abc = abc - attr12 = 12 - c = - b = - a = - attr1 = 1 - attr2 = 2 - attr3 = three - attr10 = 10 - attrx = x - -You'll quickly wonder how you ever coded without it. - --------------- - -Known Issues -============ - -While not an "issue" this is a ***stern warning*** - -**Do not attempt** to call ``PySimpleGUI`` from multiple threads! It's ``tkinter`` based and ``tkinter`` has issues with multiple threads ------------------------------------------------------------------------------------------------------------------------------------------ - -**Progress Meters** - the visual graphic portion of the meter may be -off. May return to the native tkinter progress meter solution in the -future. Right now a "custom" progress meter is used. On the bright side, -the statistics shown are extremely accurate and can tell you something -about the performance of your code. - -**Async Forms** - these include the 'easy' forms (EasyProgressMeter and -EasyPrint/Print). If you start overlapping having Async forms open with -normal forms then things get a littler squirrelly. Still tracking down -the issues and am making it more solid every day possible. You'll know -there's an issue when you see blank form. - -**EasyPrint** - EasyPrint is a new feature that's pretty awesome. You -print and the output goes to a window, with a scroll bar, that you can -copy and paste from. Being a new feature, it's got some potential -problems. There are known interaction problems with other GUI windows. -For example, closing a Print window can also close other windows you -have open. For now, don't close your debug print window until other -windows are closed too. - -Contributing ------------- - -A MikeTheWatchGuy production... entirely responsible for this code.... -unless it causes you trouble in which case I'm not at all responsible. - -Versions --------- - -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| Version | Description | -+===========+==================================================================================================================================================+ -| 1.0.9 | July 10, 2018 - Initial Release | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1.0.21 | July 13, 2018 - Readme updates | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all\_lower\_case | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.1.1 | July 18, 2018 - Global settings exposed, fixes | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.2.0 | July 20, 2018 - Image Elements, Print output | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.6.0 | July 27, 2018 - auto\_size\_button setting. License changed to LGPL 3+ | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| 2.6.5 | Aug XX, 2018 - window\_location default setting | -+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------+ - -Release Notes -~~~~~~~~~~~~~ - -2.3 - Sliders, Listbox's and Image elements (oh my!) - -If using Progress Meters, avoid cancelling them when you have another -window open. It could lead to future windows being blank. It's being -worked on. - -New debug printing capability. ``sg.Print`` - -2.5 Discovered issue with scroll bar on ``Output`` elements. The bar -will match size of ROW not the size of the element. Normally you never -notice this due to where on a form the ``Output`` element goes. - -Listboxes are still without scrollwheels. The mouse can drag to see more -items. The mouse scrollwheel will also scroll the list and will -``page up`` and ``page down`` keys. - -Upcoming -~~~~~~~~ - -Make suggestions people! Future release features - -Columns. How multiple columns would be specified in the SDK interface -are still being designed. - -Port to other graphic engines. Hook up the front-end interface to a -backend other than tkinter. Qt, WxPython, etc. - -Code Condition --------------- - -:: - - Make it run - Make it right - Make it fast - -It's a recipe for success if done right. PySimpleGUI has completed the -"Make it run" phase. It's far from "right" in many ways. These are being -worked on. The module is particularly poor for PEP 8 compliance. It was -a learning exercise that turned into a somewhat complete GUI solution -for lightweight problems. - -While the internals to PySimpleGUI are a tad sketchy, the public -interfaces into the SDK are more strictly defined and comply with PEP 8 -for the most part. - -Please log bugs and suggestions in the GitHub! It will only make the -code stronger and better in the end, a good thing for us all, right? - -Design ------- - -A moment about the design-spirit of ``PySimpleGUI``. From the beginning, -this package was meant to take advantage of Python's capabilities with -the goal of programming ease. - -**Single File** While not the best programming practice, the -implementation resulted in a single file solution. Only one file is -needed, PySimpleGUI.py. You can post this file, email it, and easily -import it using one statement. - -**Functions as objects** In Python, functions behave just like object. -When you're placing a Text Element into your form, you may be sometimes -calling a function and other times declaring an object. If you use the -word Text, then you're getting an object. If you're using ``Txt``, then -you're calling a function that returns a ``Text`` object. - -**Lists** It seemed quite natural to use Python's powerful list -constructs when possible. The form is specified as a series of lists. -Each "row" of the GUI is represented as a list of Elements. When the -form read returns the results to the user, all of the results are -presented as a single list. This makes reading a form's values -super-simple to do in a single line of Python code. - -Authors -------- - -MikeTheWatchGuy - -License -------- - -GNU Lesser General Public License (LGPL 3) + - -Acknowledgments ---------------- - -- Jorj McKie was the motivator behind the entire project. His - wxsimpleGUI concepts sparked PySimpleGUI into existence -- `Fredrik Lundh `__ for his - work on ``tkinter`` - -How Do I --------- - -Finally, I must thank the fine folks at How Do I. -https://github.com/gleitz/howdoi Their utility has forever changed the -way and pace in which I can program. I urge you to try the HowDoI.py -application here on GitHub. Trust me, **it's going to be worth the -effort!** Here are the steps to run that application - -:: - - Install howdoi: - pip install howdoi - Test your install: - python -m howdoi howdoi.py - To run it: - Python HowDoI.py - -The pip command is all there is to the setup. - -The way HowDoI works is that it uses your search term to look through -stack overflow posts. It finds the best answer, gets the code from the -answer, and presents it as a response. It gives you the correct answer -OFTEN. It's a miracle that it work SO well. For Python questions, I -simply start my query with 'Python'. Let's say you forgot how to reverse -a list in Python. When you run HowDoI and ask this question, this is -what you'll see. |snap0109| - -In the hands of a competent programmer, this tool is **amazing**. It's a -must-try kind of program that has completely changed my programming -process. I'm not afraid of asking for help! You just have to be smart -about using what you find. - -The PySimpleGUI window that the results are shown in is an 'input' field -which means you can copy and paste the results right into your code. - -.. |Downloads| image:: http://pepy.tech/badge/pysimplegui - :target: http://pepy.tech/project/pysimplegui -.. |snap0125| image:: https://user-images.githubusercontent.com/13696193/43114979-a696189e-8ecf-11e8-83c7-473fcf0ccc66.jpg -.. |results 2| image:: https://user-images.githubusercontent.com/13696193/43097502-44e3ed32-8e8a-11e8-9a51-2b8af0b1a682.jpg -.. |snap0155| image:: https://user-images.githubusercontent.com/13696193/43273879-a9fdc10a-90cb-11e8-8c20-4f6a244ebe2f.jpg -.. |snap0109| image:: https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg diff --git a/docs/readme.md b/docs/readme.md new file mode 100644 index 000000000..f03d65375 --- /dev/null +++ b/docs/readme.md @@ -0,0 +1,1506 @@ + + +![pysimplegui_logo](https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png) + +[![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 +# PySimpleGUI + (Ver 2.7) + +Super-simple GUI to grasp... Powerfully customizable. + +Note - *Python3* is required to run PySimpleGUI. It takes advantage of some Python3 features that do not translate well into Python2. + +Looking to take your Python code from the world of command lines and into the convenience of a GUI? Have a Raspberry Pi with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK? Look no further, you've found your GUI package. + + import PySimpleGUI as sg + + sg.MsgBox('Hello From PySimpleGUI!', 'This is the shortest GUI program ever!') + + +![snap0136](https://user-images.githubusercontent.com/13696193/43162494-33095ece-8f59-11e8-86de-b6d8bcc5a52f.jpg) + + Build beautiful customized forms that fit your specific problem. Let PySimpleGUI solve your GUI problem while you solve the real problems. Do you really want to plod through the mountains of code required to program tkinter? + +![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) + +Perhaps you're looking for a way to interact with your Raspberry Pi in a more friendly way. The is the same form as above, except shown on a Pi. + +![raspberry pi](https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg) + + +In addition to a primary GUI, you can add a Progress Meter to your code with ONE LINE of code. Slide this into any of your `for` loops and get a nice meter like this: + + EasyProgressMeter('My meter title', current_value, max value) + + ![snap0177](https://user-images.githubusercontent.com/13696193/43658025-947973d2-9725-11e8-902f-e2d5effb6e3e.jpg) + +You can build an async media player GUI with custom buttons in 30 lines of code. + +![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) + +I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? + +There are a number of 'easy to use' Python GUIs, but they're **very** limiting. PySimpleGUI takes the best of packages like `EasyGUI`and `WxSimpleGUI` , both really handy but limited. The primary difference between these and PySimpleGUI is that in addition to getting the simple Message Boxes you also get the ability to make your own forms that are highly customizeable. Don't like the standard Message Box? Then make your own! + +Every call has optional parameters so that you can change the look and feel. Don't like the button color? It's easy to change by adding a button_color parameter to your widget. + +GUI Packages with more functionality, like QT and WxPython, require configuring and can take a ***week*** to get *reasonably familiar* with the interfaces. Clearly there needs to be a middle ground between forms with 1 or two input fields and a full-blown GUI. You'll be making your own custom forms with PySimpleGUI within minutes, even Async forms. + +With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. + +The `PySimpleGUI` package is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? + + Features of PySimpleGUI include: + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Realtime + Checkboxes + Radio Buttons + Listbox + Slider + Icons + Multi-line Text Input + Scroll-able Output + Images + Progress Bar + Async/Non-Blocking Windows + Tabbed forms + Persistent Windows + Redirect Python Output/Errors to scrolling window + 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + Single-Line-Of-Coide Proress Bar & Debug Print + Complete control of colors, look and feel + Button images + + +An example of many widgets used on a single form. A little further down you'll find the TWENTY lines of code required to create this complex form. Try it if you don't believe it. Start Python, copy and paste the code below into the >>> prompt and hit enter. This will pop up... + +![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) + +Here is the code that produced the above screenshot. + + import PySimpleGUI as sg + + with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText()], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [sg.Text('_' * 100, size=(70, 1))], + [sg.Text('Choose Source and Destination Folders', size=(35, 1))], + [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], + [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), + sg.FolderBrowse()], + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + + **A note on screen shots** +You will see a number of different styles of buttons, data entry fields, etc, in this readme. They were all made with the same SDK, the only difference is in the settings that are specified on a per-element, row, form, or global basis. One setting in particular, border_width, can make a big difference on the look of the form. Some of the screenshots had a border_width of 6, others a value of 1. + + +--- +### Design Goals +> Copy, Paste, Run. + +`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the code to visually match what's on the screen. + + > Be Pythonic + + Be Pythonic... Attempted to use language constructs in a natural way and to exploit some of Python's interesting features. Python's lists and optional parameters make PySimpleGUI work. + - Forms are represented as Python lists. + - A form is a list of rows + - A row is a list of elements +- Return values are a list of button presses and input values. + +It's stunning that after so many years Python still hasn't put forth a GUI framework that truly fits the language's basic data structures, especially lists. It's hard to argue with the success to be had in quickly building GUI applications using this package's syntax. + + ----- +## Getting Started with PySimpleGUI + +### Installing + + pip install PySimpleGUI + or +Simply download the file - PySimpleGUI.py and import it into your code + + +### Prerequisites + +Python 3 +tkinter + +Runs on all Python platforms that have tkinter running on them. Thoroughly tested on Windows. Runs on Windows, Mac, Linux, Raspberry Pi. Even runs on `pypy3`. + +### Using + +To use in your code, simply import.... + `import PySimpleGUI as sg` + +Then use either "high level" API calls or build your own forms. + + sg.MsgBox('This is my first message box') + +![snap0178](https://user-images.githubusercontent.com/13696193/43658024-945c83f8-9725-11e8-8ddd-0bbe67a9fc5d.jpg) + + +Yes, it's just that easy to have a window appear on the screen using Python. With PySimpleGUI, making a custom form appear isn't much more difficult. The goal is to get you running on your GUI within ***minutes***, not hours nor days. + +--- +## APIs + +PySimpleGUI can be broken down into 2 types of API's: + * High Level single call functions + * Custom form functions + + +### Python Language Features + + There are a couple of Python language features that PySimpleGUI utilizes heavily that should be understood first... + * Variable number of arguments to a function call + * Optional parameters to a function call + +#### Variable Number of Arguments + + The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. + + sg.MsgBox('Variable number of parameters example', var1, var2, "etc") + +Each new item begins on a new line in the Message Box + + ![snap0179](https://user-images.githubusercontent.com/13696193/43658129-f6ca49c6-9725-11e8-9317-1f77443eb04a.jpg) + + + +#### Optional Parameters to a Function Call + +This feature of the Python language is utilized ***heavily*** as a method of customizing forms and form Elements. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. + +Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't *have* to be specified on each and every call. + + def MsgBox(*args, + button_color=None, + button_type=MSG_BOX_OK, + auto_close=False, + auto_close_duration=None, + icon=DEFAULT_WINDOW_ICON, + line_width=MESSAGE_BOX_LINE_WIDTH, + font=None): + +If the caller wanted to change the button color to be black on yellow, the call would look something like this: + + sg.MsgBox('This box has a custom button color', button_color=('black', 'yellow')) + + +![snap0180](https://user-images.githubusercontent.com/13696193/43658171-13a72bfe-9726-11e8-8c7a-0a46e46fb202.jpg) + + +--- + +### High Level API Calls + +The classic "input a value, print result" example. +Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. +This code prompts user to input a line of text and then displays that text in a messages box: + + + import PySimpleGUI as sg + + rc = sg.GetTextBox('Title', 'Please input something') + sg.MsgBox('Results', 'The value returned from GetTextBox', rc) + + + ![snap0181](https://user-images.githubusercontent.com/13696193/43658233-48cc7794-9726-11e8-8582-8844280c344e.jpg) + +![snap0182](https://user-images.githubusercontent.com/13696193/43658232-48aaad4e-9726-11e8-95f5-aa9b9213bb77.jpg) + + +#### Message Boxes +In addition to MsgBox, you'll find a several API calls that are shortcuts to common messages boxes. You can achieve similar results by calling MsgBox with the correct parameters. + +The differences tend to be the number and types of buttons. Here are the calls and the windows that are created. + + import PySimpleGUI as sg + + `sg.MsgBoxOK('This is an OK MsgBox')` + + ![ok](https://user-images.githubusercontent.com/13696193/43667331-723ac666-9745-11e8-8666-230c35a6afd6.jpg) + + + sg.MsgBoxOKCancel('This is an OK Cancel MsgBox') + +![ok cancel 2](https://user-images.githubusercontent.com/13696193/43667330-71d5bea6-9745-11e8-8944-b3900853aa62.jpg) + + sg.MsgBoxCancel('This is a Cancel MsgBox') + +![cancel](https://user-images.githubusercontent.com/13696193/43667329-71a007de-9745-11e8-974b-d028f68798e7.jpg) + + sg.MsgBoxYesNo('This is a Yes No MsgBox') + +![yesno](https://user-images.githubusercontent.com/13696193/43667327-717ff7dc-9745-11e8-9dce-52c305a85101.jpg) + + + sg.MsgBoxError('This is an error MsgBox') + +![error msgbox](https://user-images.githubusercontent.com/13696193/43667326-71621712-9745-11e8-87c4-56e2ab500f8e.jpg) + + sg.MsgBoxAutoClose('This is an autoclose MsgBox') + +![autoclose](https://user-images.githubusercontent.com/13696193/43667325-714997dc-9745-11e8-836a-7185dc80329f.jpg) + + sg.ScrolledTextBox(my_text, height=10) + +![scrolledtextbox 2](https://user-images.githubusercontent.com/13696193/43667324-712aa0d4-9745-11e8-83a9-a0d0570d0865.jpg) + + +Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing your printed text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. Your code could contain a line like: + + sprint(f'My variables values include x={x}', f'y={y}') + +This becomes a debug print of sorts that will route to a scrolled window. + +See also the `EasyPrint` and `Print` functions. + +#### High Level User Input + +There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. If you need only 1 value, then perhaps one of these high level functions will work. + - GetTextBox + - GetFileBox + - GetFolderBox + + `submit_clicked, value = sg.GetTextBox('Title', 'Please enter anything')` + +![gettextbox 2](https://user-images.githubusercontent.com/13696193/43667510-355b23a2-9746-11e8-9f1e-91c0dd0f4ed8.jpg) + + submit_clicked, value = sg.GetFileBox('Title', 'Choose a file') + +![getfilebox 2](https://user-images.githubusercontent.com/13696193/43667535-5821fc94-9746-11e8-95c3-82395099e994.jpg) + + submit_clicked, value = sg.GetPathBox('Title', 'Choose a folder') + +![getpathbox](https://user-images.githubusercontent.com/13696193/43667556-79874c22-9746-11e8-80f2-8262d32802c2.jpg) + + +#### Progress Meter! +We all have loops in our code. 'Isn't it joyful waiting, watching a counter scrolling past in a text window? How about one line of code to get a progress meter, that contains statistics about your code? + + + EasyProgressMeter(title, + current_value, + max_value, + *args, + orientation=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): + +Here's the one-line Progress Meter in action! + + for i in range(1,10000): + sg.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') + +That line of code resulted in this window popping up and updating. + +![preogress meter](https://user-images.githubusercontent.com/13696193/43667625-d47da702-9746-11e8-91e6-e5177883abae.jpg) + +A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. +With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. + +***Be sure and add one to your loop counter*** so that your counter goes from 1 to the max value. If you do not add one, your counter will never hit the max value. Instead it will go from 0 to max-1. + +#### Debug Output +Another call in the 'Easy' families of APIs is `EasyPrint`. It will output to a debug window. If the debug window isn't open, then the first call will open it. No need to do anything but stick a 'print' call in your code. You can even replace your 'print' calls with calls to EasyPrint by simply sticking the statement + + print = sg.EasyPrint + +at the top of your code. +There are a number of names for the same EasyPrint function. `Print` is one of the better ones to use as it's easy to remember. It is simply `print` with a capital P. + + import PySimpleGUI as sg + + for i in range(100): + sg.Print(i) + +![snap0125](https://user-images.githubusercontent.com/13696193/43114979-a696189e-8ecf-11e8-83c7-473fcf0ccc66.jpg) +Or if you didn't want to change your code: + + import PySimpleGUI as sg + + print=sg.Print + for i in range(100): + print(i) + +Just like the standard print call, `EasyPrint` supports the `sep` and `end` keyword arguments. Other names that can be used to call `EasyPrint` include Print, `eprint`, If you want to close the window, call the function `EasyPrintClose`. + +A word of caution. There are known problems when multiple PySimpleGUI windows are opened, particularly if the user closes them in an unusual way. Not a reason to stay away from using it. Just something to keep in mind if you encounter a problem. + +You can change the size of the debug window using the `SetOptions` call with the `debug_win_size` parameter. + +--- +# Custom Form API Calls (Your First Form) + +This is the FUN part of the programming of this GUI. In order to really get the most out of the API, you should be using an IDE that supports auto complete or will show you the definition of the function. This will make customizing go smoother. + +This first section on custom forms is for your typical, blocking, non-persistant form. By this I mean, when you "show" the form, the function will not return until the user has clicked a button or closed the window. When this happens, the form's window will be automatically closed. + +Two other types of forms exist. +1. Persistent form - rather than closing on button clicks, the show form function returns and the form continues to be visible. This is good for applications like a chat window. +2. Asynchronous form - the trickiest of the lot. Great care must be exercised. Examples are an MP3 player or status dashboard. Async forms are updated (refreshed) on a periodic basis. + +It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. Let's start with a basic Browse for a file and do something with it. +# Copy these design patterns! +## Pattern 1 - With Context Manager + + + with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: + form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], + [sg.InputText(), sg.FileBrowse()], + [sg.Submit(), sg.Cancel()]] + button, (source_filename,) = form.LayoutAndRead(form_rows) + +## Pattern 2 - No Context Manager + + + form = sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) + form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], + [sg.InputText(), sg.FileBrowse()], + [sg.Submit(), sg.Cancel()]] + button, (source_filename,) = form.LayoutAndRead(form_rows) + + + +These 2 design patters both produce this custom form: + +![snap0134](https://user-images.githubusercontent.com/13696193/43162410-e7775466-8f58-11e8-8d6a-da4772c00dd8.jpg) + +It's important to use the "with" context manager so that resources are freed as quickly as possible, using the currently executing thread. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. + +The second design pattern is not context manager based. If you are struggling with an unknown error, try modifying the code to run without a context manager. To do so, you simple remove the with, stick the form on the front of that statement, and un-indent the with-block code. + +You will use these design patterns or code templates for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. This is the most basic / normal of the design patterns. + +### How GUI Programming in Python Should Look + +GUI programming in Python is a mess. tkinter kinda sucks. Why is Python such a great teaching language and yet no GUI framework exists that lends itself to the basic building blocks of Python, the list? + +The key to custom forms in PySimpleGUI is to view forms as ROWS of Widgets (Elements). Each row is specified as a list of these widgets. Put the rows together and you've got a form. + +Let's look at this one. + + +![snap0131](https://user-images.githubusercontent.com/13696193/43417007-df6d8408-9407-11e8-9986-30f0415f08a5.jpg) + +Let's agree the form has 4 rows. + +The first row only has **text** that reads `Rename files or folders` + +The second row has 3 elements in it. First the **text** `Source for Folders`, then an **input** field, then a **browse** button. + +Now let's look at how those 2 rows and the other two row from Python code: + + layout = [[sg.Text('Rename files or folders')], + [sg.Text('Source for Folders', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], + [sg.Text('Source for Files ', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], + [sg.Submit(), sg.Cancel()]] + +See how the source code mirrors the layout? You simply make lists for each row, then submit that table to PySimpleGUI to show and get values from. + +And what about those return values? Most people simply want to show a form, get the input values and do something with them. So why break up the code into button callbacks, etc, when I simply want my form's input values to be given to me. + +The same "row" concept applies to return values. The form is scanned from top to bottom, left to right. Each field that's an input field will occupy a spot in the return values. + +In our example form, there are 2 fields, so the return values from this form will be a list with 2 values in it. + + button, (folder_path, file_path) = form.LayoutAndRead(layout) + +In the statement that shows and reads the form, the two input fields are directly assigned to the caller's variables `folder_path` and `file_path`, ready to use. No parsing no callbacks. + +Isn't this what almost every Python programmer looking for a GUI wants?? Something easy to work with to get the values and move on to the rest of the program, where the real action is taking place. Why write pages of tkinter code when the same layout can be achieved with PySimpleGUI in 3 or 4 lines of code. 4 lines or 40? I chose 4. + + +### Laying out your form +Your form is a 2 dimensional list in Python. The first dimension are rows, the second is a list of Elements for each row. The first thing you want to do is layout your form on paper. + + layout = [ [row 1], + [row 2], + [row 3] ] + +Simple enough... a list of lists. +A row is a list of Elements. For example this could be a row with a couple of elements on it. + + [ Input, Button] + +Turning back to our example. This GUI roughly looks like this: + + layout = [ [Text], + [InputText, FileBrowse] + [Submit, Cancel] ] + + Now let's put it all together into an entire program. + + +### Line by line explanation + +Going through each line of code in the above form will help explain how to use this design patter. Copy, modify and run it! + + with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: +This creates a new form, storing it in the variable `form`. + + form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], +The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. + + [sg.InputText(), sg.FileBrowse()], +Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. + + [sg.Submit(), sg.Cancel()]] + +The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its value to the caller. + + button, (source_filename, ) = form.LayoutAndRead(form_rows) +This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field. The result of the form is stored directly into the variable we wish to work with. + + +## Return values + + Return information from FlexForm, SG's primary form builder interface, is in this format: + + button, (value1, value2, ...) + +Each of the Elements that are Input Elements will have a value in the list of return values. You can unpack your GUI directly into the variables you want to use. + + button, (filename, folder1, folder2, should_overwrite) = form.LayoutAndRead(form_rows) + + Or, you can unpack the return results separately. + + button, values = form.LayoutAndRead(form_rows) + filename, folder1, folder2, should_overwrite = values + +If you have a SINGLE value being returned, it is written this way: + + button, (value1,) = form.LayoutAndRead(form_rows) + + + Another way of parsing the return values is to store the list of values into a variable representing the list of values. + + button, value_list = form.LayoutAndRead(form_rows) + value1 = value_list[0] + value2 = value_list[1] + ... + +--- +## All Widgets / Elements +This code utilizes as many of the elements in one form as possible. + + with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText()], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [sg.Text('_' * 100, size=(70, 1))], + [sg.Text('Choose Source and Destination Folders', size=(35, 1))], + [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], + [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), + sg.FolderBrowse()], + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + +This is a somewhat complex form with quite a bit of custom sizing to make things line up well. This is code you only have to write once. When looking at the code, remember that what you're seeing is a list of lists. Each row contains a list of Graphical Elements that are used to create the form. + +![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) + +Clicking the Submit button caused the form call to return. The call to MsgBox resulted in this dialog box. +![results 2](https://user-images.githubusercontent.com/13696193/43097502-44e3ed32-8e8a-11e8-9a51-2b8af0b1a682.jpg) + + +**`Note, button value can be None`**. The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. + +You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. + +--- +# Building Custom Forms +You will find it much easier to write code using PySimpleGUI if you use an IDE such as PyCharm. The features that show you documentation about the API call you are making will help you determine which settings you want to change, if any. In PyCharm, two commands are particularly helpful. + + Control-Q (when cursor is on function name) brings up a box with the function definition + Control-P (when cursor inside function call "()") shows a list of parameters and their default values + +## Synchronous Forms +The most common use of PySimpleGUI is to display and collect information from the user. The most straightforward way to do this is using a "blocking" GUI call. Execution is "blocked" while waiting for the user to close the GUI form/dialog box. +You've already seen a number of examples above that use blocking forms. Anytime you see a context manager used (see the `with` statement) it's most likely a blocking form. You can examine the show calls to be sure. If the form is a non-blocking form, it must indicate that in the call to `form.show`. + +NON-BLOCKING form call: + + form.Show(non_blocking=True) + +### Beginning a Form +The first step is to create the form object using the desired form customization. + + with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: + +This is the definition of the FlexForm object: + + def FlexForm(title, + default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), + auto_size_text=None, + auto_size_buttons=None, + scale=(None, None), + location=(None, None), + button_color=None,Font=None, + progress_bar_color=(None,None), + is_tabbed_form=False, + border_depth=None, + auto_close=False, + auto_close_duration=DEFAULT_AUTOCLOSE_TIME, + icon=DEFAULT_WINDOW_ICON): + +Parameter Descriptions. You will find these same parameters specified for each `Element` and some of them in `Row` specifications. The `Element` specified value will take precedence over the `Row` and `Form` values. + + default_element_size - Size of elements in form in characters (width, height) + auto_size_text - Bool. True if elements should size themselves according to contents + auto_size_buttons - Bool. True if button elements should size themselves according to their text label + scale - Set size of element to be a multiple of the Element size + location - Location to place window in pixels + button_color - Default color for buttons (foreground, background). Can be text or hex + progress_bar_color - Foreground and background colors for progress bars + is_tabbed_form - Bool. If True then form is a tabbed form + border_depth - Amount of 'bezel' to put on input boxes, buttons, etc. + auto_close - Bool. If True form will autoclose + auto_close_duration - Duration in seconds before form closes + icon - .ICO file that will appear on the Task Bar and end of Title Bar + + +#### Sizes +Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. + +The default Element size for PySimpleGUI is `(45,1)`. + +Sizes can be set at the element level, or in this case, the size variables apply to all elements in the form. Setting `size=(20,1)` in the form creation call will set all elements in the form to that size. + +In addition to `size` there is a `scale` option. `scale` will take the Element's size and scale it up or down depending on the scale value. `scale=(1,1)` doesn't change the Element's size. `scale=(2,1)` will set the Element's size to be twice as wide as the size setting. + +There are a couple of widgets where one of the size values is in pixels rather than characters. This is true for Progress Meters and Sliders. The second parameter is the 'height' in pixels. + +#### FlexForm - form-level variables overview +A summary of the variables that can be changed when a FlexForm is created + + default_element_size - set default size for all elements in the form + auto_size_text- true/false autosizing turned on / off + scale - set scale value for all elements + button_color- default button color (foreground, background) + font - font name and size for all text items + progress_bar_color - progress bar colors + is_tabbed_form - true/false indicates form is a tabbed or normal form + border_depth - style setting for buttons, input fields + auto_close - true/false indicates if form will automatically close + auto_close_duration - how long in seconds before closing form + icon - filename for icon that's displayed on the window on taskbar + + +## Elements +"Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. + + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Realtime + Checkboxes + Radio Buttons + Listbox + Slider + Multi-line Text Input + Scroll-able Output + Progress Bar + Async/Non-Blocking Windows + Tabbed forms + Persistent Windows + Redirect Python Output/Errors to scrolling Window + "Higher level" APIs (e.g. MessageBox, YesNobox, ...) + + +### Output Elements +Building a form is simply making lists of Elements. Each list is a row in the overall GUI dialog box. The definition looks something like this: + + layout = [ [row 1 element, row 1 element], + [row 2 element, row 2 element, row 2 element] ] +The code is a crude representation of the GUI, laid out in text. +#### Text Element + + layout = [[sg.Text('This is what a Text Element looks like')]] + + + ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) + + +The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. + + Text(Text, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None, + text_color=None, + justification=None) +. + + Text - The text that's displayed + size - Element's size + auto_size_text - Bool. Change width to match size of text + font - Font name and size to use + text_color - text color + justification - Justification for the text. String - 'left', 'right', 'center' + +Some commonly used elements have 'shorthand' versions of the functions to make the code more compact. The functions `T` and `Txt` are the same as calling `Text`. + +**Fonts** in PySimpleGUI are always in this format: + + (font_name, point_size) + +The default font setting is + + ("Helvetica", 10) + +**Color** in PySimpleGUI are always in this format: + + (foreground, background) + +The values foreground and background can be the color names or the hex value formatted as a string: + + "#RRGGBB" + +**auto_size_text** +A `True` value for `auto_size_text`, when placed on any Element, indicates that the width of the Element should be shrunk do the width of the text. This is particularly useful with `Buttons` as fixed-width buttons are somewhat crude looking. The default value is `False`. You will often see this setting on FlexForm definitions. + +**Shorthand functions** +The shorthand functions for `Text` are `Txt` and `T` + + +#### Multiline Text Element + + layout = [[sg.Multiline('This is what a Multi-line Text Element looks like', size=(45,5))]] +![multiline text](https://user-images.githubusercontent.com/13696193/42670464-0824c754-8629-11e8-9741-6ed08f924618.jpg) +This Element doubles as both an input and output Element. The `DefaultText` optional parameter is used to indicate what to output to the window. + + Multiline(default_text='', + enter_submits = False, + scale=(None, None), + size=(None, None), + auto_size_text=None) +. + + default_text - Text to display in the text box + enter_submits - Bool. If True, pressing Enter key submits form + scale - Element's scale + size - Element's size + auto_size_text - Bool. Change width to match size of text + +#### Output Element +Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. More on this later. + + form.AddRow(gg.Output(size=(100,20))) + +![output element](https://user-images.githubusercontent.com/13696193/42704820-5446959c-869f-11e8-849e-047ea280387a.jpg) + + Output(scale=(None, None), + size=(None, None)) +. + + scale - How much to scale size of element + size - Size of element (width, height) in characters + +### Input Elements + These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. + +#### Text Input Element + + layout = [[sg.InputText('Default text')]] +![inputtext](https://user-images.githubusercontent.com/13696193/42693515-610a716c-867d-11e8-9a00-7e7fcf771230.jpg) + + def InputText(default_text = '', + scale=(None, None), + size=(None, None), + auto_size_text=None, + password_char='') +. + + default_text - Text initially shown in the input box + scale - Amount size is scaled by + size - (width, height) of element in characters + auto_size_text- Bool. True is element should be sized to fit text + password_char - Character that will be used to replace each entered character. Setting to a value indicates this field is a password entry field + +Shorthand functions that are equivalent to `InputText` are `Input` and `In` + + +#### Combo Element +Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. + + layout = [[sg.InputCombo(['choice 1', 'choice 2'])]] + +![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) + + InputCombo(values, + scale=(None, None), + size=(None, None), + auto_size_text=None) +. + + values - Choices to be displayed. List of strings + scale - Amount to scale size by + size - (width, height) of element in characters + auto_size_text - Bool. True if size should fit the text length + +#### Listbox Element +The standard listbox like you'll find in most GUIs. Note that the return values from this element will be a ***list of results, not a single result***. This is because the user can select more than 1 item from the list (if you set the right mode). + + layout = [[sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6))]] + +![snap0130](https://user-images.githubusercontent.com/13696193/43115859-2fbf0646-8ed3-11e8-9979-bbee8eaebfab.jpg) + + + Listbox(values, + select_mode=None, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None) +. + + values - Choices to be displayed. List of strings + select_mode - Defines how to list is to operate. + Choices include constants or strings: + Constants version: + LISTBOX_SELECT_MODE_BROWSE + LISTBOX_SELECT_MODE_EXTENDED + LISTBOX_SELECT_MODE_MULTIPLE + LISTBOX_SELECT_MODE_SINGLE - the default + Strings version: + 'browse' + 'extended' + 'multiple' + 'single' + scale - Amount to scale size by + size - (width, height) of element in characters + auto_size_text - Bool. True if size should fit the text length + +The `select_mode` option can be a string or a constant value defined as a variable. Generally speaking strings are used for these kinds of options. + +#### Slider Element +Sliders have a couple of slider-specific settings as well as appearance settings. Examples include the `orientation` and `range` settings. + + layout = [[sg.Slider(range=(1,500), default_value=222, size=(20,15), orientation='horizontal', font=('Helvetica', 12))]] + +![snap0129](https://user-images.githubusercontent.com/13696193/43115741-e1cb52c8-8ed2-11e8-80bb-0e99ae846ec1.jpg) + + Slider(range=(None,None), + default_value=None, + orientation=None, + border_width=None, + relief=None, + scale=(None, None), + size=(None, None), + font=None): +. + + range - (min, max) slider's range + default_value - default setting (within range) + orientation - 'horizontal' or 'vertical' ('h' or 'v' work) + border_width - how deep the widget looks + relief - relief style. Values are same as progress meter relief values. Can be a constant or a string: + RELIEF_RAISED= 'raised' + RELIEF_SUNKEN= 'sunken' + RELIEF_FLAT= 'flat' + RELIEF_RIDGE= 'ridge' + RELIEF_GROOVE= 'groove' + RELIEF_SOLID = 'solid' + scale - Amount to scale size by + size - (width, height) of element in characters + auto_size_text - Bool. True if size should fit the text + +#### Radio Button Element +Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. + + layout = [[sg.Radio('My first Radio!', "RADIO1", default=True), sg.Radio('My second radio!', "RADIO1")]] + +![radio element](https://user-images.githubusercontent.com/13696193/42705705-327b4b6c-86a2-11e8-81a7-740e57646ba8.jpg) + + Radio(text, + group_id, + default=False, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None) + +. + + text - Text to display next to button + group_id - Groups together multiple Radio Buttons. Can be any value + default - Bool. Initial state + scale - Amount to scale size of element + size- (width, height) size of element in characters + auto_size_text - Bool. True if should size width to fit text + font - Font type and size for text display + + +#### Checkbox Element +Checkbox elements are like Radio Button elements. They return a bool indicating whether or not they are checked. + + layout = [[sg.Checkbox('My first Checkbox!', default=True), sg.Checkbox('My second Checkbox!')]] + +![checkbox element](https://user-images.githubusercontent.com/13696193/42717015-655d73d2-86cc-11e8-9c69-3c810f48e578.jpg) + + + Checkbox(text, + default=False, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None): +. + + text - Text to display next to checkbox + default- Bool. Initial state + scale - Amount to scale size of element + size - (width, height) size of element in characters + auto_size_text- Bool. True if should size width to fit text + font- Font type and size for text display + + +#### Spin Element +An up/down spinner control. The valid values are passed in as a list. + + layout = [[sg.Spin([i for i in range(1,11)], initial_value=1), sg.Text('Volume level')]] + +![spin element](https://user-images.githubusercontent.com/13696193/42717231-8ddb51d4-86cd-11e8-827a-75f2237477fa.jpg) + + Spin(values, + intiial_value=None, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None) +. + + values - List of valid values + initial_value - String with initial value + scale - Amount to scale size of element + size - (width, height) size of element in characters + auto_size_text - Bool. True if should size width to fit text + font - Font type and size for text display + +#### Button Element +Buttons are the most important element of all! They cause the majority of the action to happen. After all, it's a button press that will get you out of a form, whether it but Submit or Cancel, one way or another a button is involved in all forms. The only exception is to this is when the user closes the window using the "X" in the upper corner which means no button was involved. + +The Types of buttons include: +* Folder Browse +* File Browse +* Close Form +* Read Form +* Realtime + + + Close Form - Normal buttons like Submit, Cancel, Yes, No, etc, are "Close Form" buttons. They cause the input values to be read and then the form is closed, returning the values to the caller. + +Folder Browse - When clicked a folder browse dialog box is opened. The results of the Folder Browse dialog box are written into one of the input fields of the form. + +File Browse - Same as the Folder Browse except rather than choosing a folder, a single file is chosen. + +Read Form - This is an async form button that will read a snapshot of all of the input fields, but does not close the form after it's clicked. + +Realtime - This is another async form button. Normal button clicks occur after a button's click is released. Realtime buttons report a click the entire time the button is held down. + +While it's possible to build forms using the Button Element directly, you should never need to do that. There are pre-made buttons and shortcuts that will make life much easier. The most basic Button element call to use is `SimpleButton` + + SimpleButton(text, + scale=(None, None), + size=(None, None), + auto_size_button=None, + button_color=None, + font=None) + +Pre-made buttons include: + + OK + Ok + Submit + Cancel + Yes + No + FileBrowse + FolderBrowse +. + layout = [[sg.OK(), sg.Cancel()]] + +![ok cancel](https://user-images.githubusercontent.com/13696193/42717733-1803f584-86d1-11e8-9223-36b782971b9f.jpg) + +The FileBrowse and FolderBrowse buttons both fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. + +The default value for `Target` is `(ThisRow, -1)`. ThisRow is a special value that tells the GUI to use the same row as the button. The Y-value of -1 means the field one value to the left of the button. For a File or Folder Browse button, the field that it fills are generally to the left of the button is most cases. + +Let's examine this form as an example: + +![button target example](https://user-images.githubusercontent.com/13696193/42718075-b4dcb61e-86d3-11e8-904c-d709dd364108.jpg) + +The `InputText` element is located at (1,0)... row 1, column 0. The `Browse` button is located at position (2,0). The Target for the button could be any of these values: + + Target = (1,0) + Target = (-1,0) +The code for the entire form could be: + + layout = [[sg.T('Source Folder')], + [sg.In()], + [sg.FolderBrowse(Target=(-1,0)), sg.OK()]] + +**Custom Buttons** +Not all buttons are created equal. A button that closes a form is different that a button that returns from the form without closing it. If you want to define your own button, you will generally do this with the Button Element `SimpleButton`, which closes the form when clicked. + +layout = [[sg.SimpleButton('My Button')]] + +![singlebutton](https://user-images.githubusercontent.com/13696193/42718281-9453deca-86d5-11e8-83c7-4b6d33720858.jpg) + +All buttons can have their text changed by changing the `button_text` variable in the button call. It is this text that is returned when a form is read. This text will be what tells you which button is called so make it unique. Most of the convenience buttons (Submit, Cancel, Yes, etc) are all SimpleButtons. The two that are not are `FileBrowse` and `FolderBrowse`. They clearly do not close the form. Instead they bring up a file or folder browser dialog box. + +**Button Images** +Now this is an exciting feature not found in many simplified packages.... images on buttons! You can make a pretty spiffy user interface with the help of a few button images. + +Your button images need to be in PNG or GIF format. When you make a button with an image, set the button background to the same color as the background. There's a button color TRANSPARENT_BUTTON that you can set your button color to in order for it to blend into the background. Note that this value is currently the same as the color as the default system background on Windows. + +This example comes from the `Demo Media Player.py` example program. Because it's a non-blocking button, it's defined as `ReadFormButton`. You also put images on blocking buttons by using `SimpleButton`. + + + sg.ReadFormButton('Restart Song', button_color=sg.TRANSPARENT_BUTTON, + image_filename=image_restart, image_size=(50, 50), image_subsample=2, border_width=0) + +Three parameters are used for button images. + + image_filename - Filename. Can be a relative path + image_size - Size of image file in pixels + image_subsample - Amount to divide the size by. 2 means your image will be 1/2 the size. 3 means 1/3 + +Here's an example form made with button images. + +![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) + +You'll find the source code in the file Demo Media Player. Here is what the button calls look like to create media player form + + sg.ReadFormButton('Pause', button_color=sg.TRANSPARENT_BUTTON, + image_filename=image_pause, image_size=(50, 50), image_subsample=2, border_width=0) + +This is one you'll have to experiment with at this point. Not up for an exhaustive explanation. + + **Realtime Buttons** + + Normally buttons are considered "clicked" when the mouse button is let UP after a downward click on the button. What about times when you need to read the raw up/down button values. A classic example for this is a robotic remote control. Building a remote control using a GUI is easy enough. One button for each of the directions is a start. Perhaps something like this: + +![snap0135](https://user-images.githubusercontent.com/13696193/43440841-bcf8d184-9466-11e8-9f7b-30a1d5ce32d3.jpg) + +This form has 2 button types. There's the normal "Simple Button" (Quit) and 4 "Realtime Buttons". + +Here is the code to make, show and get results from this form: + + form = sg.FlexForm('Robotics Remote Control', auto_size_text=True) + + form_rows = [[sg.Text('Robotics Remote Control')], + [sg.T(' '*10), sg.RealtimeButton('Forward')], + [ sg.RealtimeButton('Left'), sg.T(' '*15), sg.RealtimeButton('Right')], + [sg.T(' '*10), sg.RealtimeButton('Reverse')], + [sg.T('')], + [sg.Quit(button_color=('black', 'orange'))] + ] + + form.LayoutAndRead(form_rows, non_blocking=True) + +Somewhere later in your code will be your main event loop. This is where you do your polling of devices, do input/output, etc. It's here that you will read your form's buttons. + + while (True): + # This is the code that reads and updates your window + button, values = form.ReadNonBlocking() + if button is not None: + sg.Print(button) + if button == 'Quit' or values is None: + break + time.sleep(.01) + +This loop will read button values and print them. When one of the Realtime buttons is clicked, the call to `form.ReadNonBlocking` will return a button name matching the name on the button that was depressed. It will continue to return values as long as the button remains depressed. Once released, the ReadNonBlocking will return None for buttons ules anutton was clicked. + +**File Types** +The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is + + FileTypes=(("ALL Files", "*.*"),) + +This code produces a form where the Browse button only shows files of type .TXT + + layout = [[sg.In() ,sg.FileBrowse(file_types=(("Text Files", "*.txt"),))]] + + ***The ENTER key*** + The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. + + --- +#### ProgressBar +The `ProgressBar` element is used to build custom Progress Bar forms. It is HIGHLY recommended that you use the functions that provide a complete progress meter solution for you. Progress Meters are not easy to work with because the forms have to be non-blocking and they are tricky to debug. + +The **easiest** way to get progress meters into your code is to use the `EasyProgessMeter` API. This consists of a pair of functions, `EasyProgessMeter` and `EasyProgressMeterCancel`. You can easily cancel any progress meter by calling it with the current value = max value. This will mark the meter as expired and close the window. +You've already seen EasyProgressMeter calls presented earlier in this readme. + + sg.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') + +The return value for `EasyProgressMeter` is: +`True` if meter updated correctly +`False` if user clicked the Cancel button, closed the form, or vale reached the max value. +**Customized Progress Bar** +If you want a bit more customization of your meter, then you can go up 1 level and use the calls to `ProgressMeter` and `ProgressMeterUpdate`. These APIs behave like an object we're all used to. First you create the `ProgressMeter` object, then you call the `Update` method to update it. + +You setup the progress meter by calling + + my_meter = ProgressMeter(title, + max_value, + *args, + orientantion=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) +Then to update the bar within your loop + + return_code = ProgressMeterUpdate(my_meter, + value, + *args): +Putting it all together you get this design pattern + + my_meter = sg.ProgressMeter('Meter Title', 100000, orentation='Vert') + + for i in range(0, 100000): + sg.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') + + +The final way of using a Progress Meter with PySimpleGUI is to build a custom form with a `ProgressBar` Element in the form. You will need to run your form as a non-blocking form. When you are ready to update your progress bar, you call the `UpdateBar` method for the `ProgressBar` element itself. + + +#### Output +The Output Element is a re-direction of Stdout. Anything "printed" will be displayed in this element. + + Output(scale=(None, None), + size=(None, None)) + +Here's a complete solution for a chat-window using an Async form with an Output Element + + import PySimpleGUI as sg + # Blocking form that doesn't close + def ChatBot(): + with sg.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + layout = [[(sg.Text('This is where standard out is being routed', size=[40, 1]))], + [sg.Output(size=(80, 20))], + [sg.Multiline(size=(70, 5), enter_submits=True), sg.ReadFormButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0])), sg.SimpleButton('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]] + # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form + # if you call LayoutAndRead from here, then you will miss the first button click + form.Layout(layout) + # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # + while True: + button, value = form.Read() + if button == 'SEND': + print(value) + else: + break + + +## Tabbed Forms +Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format + + results = ShowTabbedForm('Title for the form', + (form,layout,'Tab 1 label'), + (form2,layout2, 'Tab 2 label'), ...) + +Each of the tabs of the form is in fact a form. The same steps are taken to create the form as before. A `FlexForm` is created, then rows are filled with Elements, and finally the form is shown. When calling `ShowTabbedForm`, each form is passed in as a tuple. The tuple has the format: `(the form, the rows, a string shown on the tab)` + +Results are returned as a list of lists. For each form you'll get a list that's in the same format as a normal form. A single tab's values would be: + + (button, (values)) + +Recall that values is a list as well. Multiple tabs in the form would return like this: + + ((button1, (values1)), (button2, (values2)) + + ## Colors ## +Starting in version 2.5 you can change the background colors for the window and the Elements. + +Your forms can go from this: +![snap0155](https://user-images.githubusercontent.com/13696193/43273879-a9fdc10a-90cb-11e8-8c20-4f6a244ebe2f.jpg) + + +to this... with one function call... + +![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) + + + +While you can do it on an element by element or form level basis, the easiest way, by far, is a call to `SetOptions`. + +Be aware that once you change these options they are changed for the rest of your program's execution. All of your forms will have that look and feel, until you change it to something else (which could be the system default colors. + +This call sets all of the different color options. + + SetOptions(background_color='#9FB8AD', + text_element_background_color='#9FB8AD', + element_background_color='#9FB8AD', + scrollbar_color=None, + input_elements_background_color='#F7F3EC', + progress_meter_color = ('green', 'blue') + button_color=('white','#475841')) + + + +## Global Settings +**Global Settings** +Let's have some fun customizing! Make PySimpleGUI look the way you want it to look. You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. + + SetOptions(icon=None + button_color=(None,None) + element_size=(None,None), + margins=(None,None), + element_padding=(None,None) + auto_size_text=None + auto_size_buttons=None + font=None + border_width=None + slider_border_width=None + slider_relief=None + slider_orientation=None + autoclose_time=None + message_box_line_width=None + progress_meter_border_depth=None + progress_meter_style=None + progress_meter_relief=None + progress_meter_color=None + progress_meter_size=None + text_justification=None + background_color=None + element_background_color=None + text_element_background_color=None + input_elements_background_color=None + scrollbar_color=None, text_color=None + debug_win_size=(None,None) + window_location=(None,None) + +Explanation of parameters + + icon - filename of icon used for taskbar and title bar + button_color - button color (foreground, background) + element_size - element size (width, height) in characters + margins - tkinter margins around outsize + element_padding - tkinter padding around each element + auto_size_text - autosize the elements to fit their text + auto_size_buttons - autosize the buttons to fit their text + font - font used for elements + border_width - amount of bezel or border around sunken or raised elements + slider_border_width - changes the way sliders look + slider_relief - changes the way sliders look + slider_orientation - changes orientation of slider + autoclose_time - time in seconds for autoclose boxes + message_box_line_width - number of characers in a line of text in message boxes + progress_meter_border_depth - amount of border around raised or lowered progress meters + progress_meter_style - style of progress meter as defined by tkinter + progress_meter_relief - relief style + progress_meter_color - color of the bar and background of progress meters + progress_meter_size - size in (characters, pixels) + background_color - Color of the main window's background + element_background_color - Background color of the elements + text_element_background_color - Text element background color + input_elements_background_color - Input fields background color + scrollbar_color - Color for scrollbars (may not always work) + text_color - Text element default text color + text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' + debug_win_size - size of the Print output window + window_location - location on the screen (x,y) of window's top left cornder + + +These settings apply to all forms `SetOptions`. The Row options and Element options will take precedence over these settings. Settings can be thought of as levels of settings with the Form-level being the highest and the Element-level the lowest. Thus the levels are: + + - Form level + - Row level + - Element level + +Each lower level overrides the settings of the higher level. Once settings have been changed, they remain changed for the duration of the program (unless changed again). + +## Asynchronous (Non-Blocking) Forms +So you want to be a wizard do ya? Well go boldly! While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. With asynchronous forms the form is shown, user input is read, but your code keeps right on chugging. YOUR responsibility is to call `PySimpleGUI.ReadNonBlocking` on a periodic basis. Once a second or more will produce a reasonably snappy GUI. + +When do you use a non-blocking form? A couple of examples are +* A media file player like an MP3 player +* A status dashboard that's periodically updated +* Progress Meters - when you want to make your own progress meters +* Output using print to a scrolled text element. Good for debugging. + +Word of warning... version 2.2, the currently released, and upcoming version 2.3 differ in the return code for the `ReadNonBlocking` call. Previously the function returned 2 values, except when the form is closed using the "X" which returned a single value of `None`. The *new* way is that `ReadNonBlocking` always returns 2 values. If the user closed the form with the "X" then the return values will be None, None. You will want to key off the second value to catch this case. +The proper code to check if the user has exited the form will be a polling-loop that looks something like this: + + while True: + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + +We're going to build an app that does the latter. It's going to update our form with a running clock. + +The basic flow and functions you will be calling are: +Setup + + + form = FlexForm() + form_rows = ..... + form.LayoutAndRead(form_rows, non_blocking=True) + + +Periodic refresh + + form.ReadNonBlocking() +If you need to close the form + + form.CloseNonBlockingForm() + +Rather than the usual `form.LayoutAndRead()` call, we're manually adding the rows (doing the layout) and then showing the form. After the form is shown, you simply call `form.ReadNonBlocking()` every now and then. + +When you are ready to close the form (assuming the form wasn't closed by the user or a button click) you simply call `form.CloseNonBlockingForm()` + +**Example - Running timer that updates** +See the sample code on the GitHub named Demo Media Player for another example of Async Forms. We're going to make a form and update one of the elements of that form every .01 seconds. Here's the entire code to do that. + + + import PySimpleGUI as sg + import time + + # form that doesn't block + # Make a form, but don't use context manager + form = sg.FlexForm('Running Timer', auto_size_text=True) + # Create a text element that will be updated with status information on the GUI itself + output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) + # Create the rows + form_rows = [[sg.Text('Non-blocking GUI with updates')], + [output_element], + [sg.SimpleButton('Quit')]] + # Layout the rows of the form and perform a read. Indicate the form is non-blocking! + form.LayoutAndRead(form_rows, non_blocking=True) + + # + # Some place later in your code... + # You need to perform a ReadNonBlocking on your form every now and then or + # else it won't refresh + # + + for i in range(1, 1000): + output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + time.sleep(.01) + else: + form.CloseNonBlockingForm() + + + +What we have here is the same sequence of function calls as in the description. Get a form, add rows to it, show the form, and then refresh it every now and then. + +The new thing in this example is the call use of the Update method for the Text Element. The first thing we do inside the loop is "update" the text element that we made earlier. This changes the value of the text field on the form. The new value will be displayed when `form.ReadNonBlocking()` is called. + +Note the `else` statement on the for loop. This is needed because we're about to exit the loop while the form is still open. The user has not closed the form using the X nor a button so it's up to the caller to close the form using `CloseNonBlockingForm`. + +That's it... this example follows the async design pattern well. + + + +## Sample Applications +Use the example programs as a starting basis for your GUI. Copy, paste, modify and run! The demo files are: + +`Demo Recipes.py` - Sample forms for all major form types and situations. This is the place to get your code template from. Includes asynchronous forms, etc. + +`Demo DisplayHash1and256.py` - Demonstrates using High Level API calls to get a filename + +`Demo DupliucateFileFinder.py` - Demonstrates High Level API to get a folder & Easy Progress Meter to show progress of the file scanning + +`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. If anyone wants to help me package this application up, I could use a hand. + +## Fun Stuff +Here are some things to try if you're bored or want to further customize + +**Debug Output** +Be sure and check out the EasyPrint (Print) function described in the high-level API section. Leave your code the way it is, route your stdout and stderror to a scrolling window. + +For a fun time, add these lines to the top of your script + + import PySimpleGUI as sg + print = sg.Print + +This will turn all of your print statements into prints that display in a window on your screen rather than to the terminal. + +**Look and Feel** +Dial in the look and feel that you like with the `SetOptions` function. You can change all of the defaults in one function call. One line of code to customize the entire GUI. + +**ObjToString** +Ever wanted to easily display an objects contents easily? Use ObjToString to get a nicely formatted recursive walk of your objects. +This statement: + + print(sg.ObjToSting(x)) + +And this was the output + + + abc = abc + attr12 = 12 + c = + b = + a = + attr1 = 1 + attr2 = 2 + attr3 = three + attr10 = 10 + attrx = x + +You'll quickly wonder how you ever coded without it. + +--- +# Known Issues +While not an "issue" this is a ***stern warning*** + +## **Do not attempt** to call `PySimpleGUI` from multiple threads! It's `tkinter` based and `tkinter` has issues with multiple threads + +**Progress Meters** - the visual graphic portion of the meter may be off. May return to the native tkinter progress meter solution in the future. Right now a "custom" progress meter is used. On the bright side, the statistics shown are extremely accurate and can tell you something about the performance of your code. + +**Async Forms** - these include the 'easy' forms (EasyProgressMeter and EasyPrint/Print). If you start overlapping having Async forms open with normal forms then things get a littler squirrelly. Still tracking down the issues and am making it more solid every day possible. You'll know there's an issue when you see blank form. + +**EasyPrint** - EasyPrint is a new feature that's pretty awesome. You print and the output goes to a window, with a scroll bar, that you can copy and paste from. Being a new feature, it's got some potential problems. There are known interaction problems with other GUI windows. For example, closing a Print window can also close other windows you have open. For now, don't close your debug print window until other windows are closed too. + +## Contributing + +A MikeTheWatchGuy production... entirely responsible for this code.... unless it causes you trouble in which case I'm not at all responsible. + +## Versions +|Version | Description | +|--|--| +| 1.0.9 | July 10, 2018 - Initial Release | +| 1.0.21 | July 13, 2018 - Readme updates | +| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case +| 2.1.1 | July 18, 2018 - Global settings exposed, fixes +| 2.2.0| July 20, 2018 - Image Elements, Print output +| 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. +| 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi +| 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. +| 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ +| 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting + + +### Release Notes +2.3 - Sliders, Listbox's and Image elements (oh my!) + +If using Progress Meters, avoid cancelling them when you have another window open. It could lead to future windows being blank. It's being worked on. + +New debug printing capability. `sg.Print` + +2.5 Discovered issue with scroll bar on `Output` elements. The bar will match size of ROW not the size of the element. Normally you never notice this due to where on a form the `Output` element goes. + +Listboxes are still without scrollwheels. The mouse can drag to see more items. The mouse scrollwheel will also scroll the list and will `page up` and `page down` keys. + +2.7 Is the "feature complete" release. Pretty much all features are done and in the code + + +### Upcoming +Make suggestions people! Future release features + +Columns. How multiple columns would be specified in the SDK interface are still being designed. + +Port to other graphic engines. Hook up the front-end interface to a backend other than tkinter. Qt, WxPython, etc. + + + +## Code Condition + + Make it run + Make it right + Make it fast + +It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor for PEP 8 compliance. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. + +While the internals to PySimpleGUI are a tad sketchy, the public interfaces into the SDK are more strictly defined and comply with PEP 8 for the most part. + +Please log bugs and suggestions in the GitHub! It will only make the code stronger and better in the end, a good thing for us all, right? + +## Design + +A moment about the design-spirit of `PySimpleGUI`. From the beginning, this package was meant to take advantage of Python's capabilities with the goal of programming ease. + +**Single File** +While not the best programming practice, the implementation resulted in a single file solution. Only one file is needed, PySimpleGUI.py. You can post this file, email it, and easily import it using one statement. + +**Functions as objects** +In Python, functions behave just like object. When you're placing a Text Element into your form, you may be sometimes calling a function and other times declaring an object. If you use the word Text, then you're getting an object. If you're using `Txt`, then you're calling a function that returns a `Text` object. + +**Lists** +It seemed quite natural to use Python's powerful list constructs when possible. The form is specified as a series of lists. Each "row" of the GUI is represented as a list of Elements. When the form read returns the results to the user, all of the results are presented as a single list. This makes reading a form's values super-simple to do in a single line of Python code. + + +## Authors +MikeTheWatchGuy + +## License + +GNU Lesser General Public License (LGPL 3) + + +## Acknowledgments + +* Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence +* [Fredrik Lundh](https://wiki.python.org/moin/FredrikLundh) for his work on `tkinter` + + +## How Do I +Finally, I must thank the fine folks at How Do I. +https://github.com/gleitz/howdoi +Their utility has forever changed the way and pace in which I can program. I urge you to try the HowDoI.py application here on GitHub. Trust me, **it's going to be worth the effort!** +Here are the steps to run that application + + Install howdoi: + pip install howdoi + Test your install: + python -m howdoi howdoi.py + To run it: + Python HowDoI.py + +The pip command is all there is to the setup. + +The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. +For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. +![snap0109](https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg) + +In the hands of a competent programmer, this tool is **amazing**. It's a must-try kind of program that has completely changed my programming process. I'm not afraid of asking for help! You just have to be smart about using what you find. + +The PySimpleGUI window that the results are shown in is an 'input' field which means you can copy and paste the results right into your code. \ No newline at end of file From e2385939c7260fbee23ab6751958e2d0f5b9efee Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 3 Aug 2018 19:00:21 -0400 Subject: [PATCH 099/209] Delete readme.md --- docs/readme.md | 1506 ------------------------------------------------ 1 file changed, 1506 deletions(-) delete mode 100644 docs/readme.md diff --git a/docs/readme.md b/docs/readme.md deleted file mode 100644 index f03d65375..000000000 --- a/docs/readme.md +++ /dev/null @@ -1,1506 +0,0 @@ - - -![pysimplegui_logo](https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png) - -[![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 -# PySimpleGUI - (Ver 2.7) - -Super-simple GUI to grasp... Powerfully customizable. - -Note - *Python3* is required to run PySimpleGUI. It takes advantage of some Python3 features that do not translate well into Python2. - -Looking to take your Python code from the world of command lines and into the convenience of a GUI? Have a Raspberry Pi with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK? Look no further, you've found your GUI package. - - import PySimpleGUI as sg - - sg.MsgBox('Hello From PySimpleGUI!', 'This is the shortest GUI program ever!') - - -![snap0136](https://user-images.githubusercontent.com/13696193/43162494-33095ece-8f59-11e8-86de-b6d8bcc5a52f.jpg) - - Build beautiful customized forms that fit your specific problem. Let PySimpleGUI solve your GUI problem while you solve the real problems. Do you really want to plod through the mountains of code required to program tkinter? - -![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) - -Perhaps you're looking for a way to interact with your Raspberry Pi in a more friendly way. The is the same form as above, except shown on a Pi. - -![raspberry pi](https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg) - - -In addition to a primary GUI, you can add a Progress Meter to your code with ONE LINE of code. Slide this into any of your `for` loops and get a nice meter like this: - - EasyProgressMeter('My meter title', current_value, max value) - - ![snap0177](https://user-images.githubusercontent.com/13696193/43658025-947973d2-9725-11e8-902f-e2d5effb6e3e.jpg) - -You can build an async media player GUI with custom buttons in 30 lines of code. - -![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) - -I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? - -There are a number of 'easy to use' Python GUIs, but they're **very** limiting. PySimpleGUI takes the best of packages like `EasyGUI`and `WxSimpleGUI` , both really handy but limited. The primary difference between these and PySimpleGUI is that in addition to getting the simple Message Boxes you also get the ability to make your own forms that are highly customizeable. Don't like the standard Message Box? Then make your own! - -Every call has optional parameters so that you can change the look and feel. Don't like the button color? It's easy to change by adding a button_color parameter to your widget. - -GUI Packages with more functionality, like QT and WxPython, require configuring and can take a ***week*** to get *reasonably familiar* with the interfaces. Clearly there needs to be a middle ground between forms with 1 or two input fields and a full-blown GUI. You'll be making your own custom forms with PySimpleGUI within minutes, even Async forms. - -With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. - -The `PySimpleGUI` package is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? - - Features of PySimpleGUI include: - Text - Single Line Input - Buttons including these types: - File Browse - Folder Browse - Non-closing return - Close form - Realtime - Checkboxes - Radio Buttons - Listbox - Slider - Icons - Multi-line Text Input - Scroll-able Output - Images - Progress Bar - Async/Non-Blocking Windows - Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling window - 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) - Single-Line-Of-Coide Proress Bar & Debug Print - Complete control of colors, look and feel - Button images - - -An example of many widgets used on a single form. A little further down you'll find the TWENTY lines of code required to create this complex form. Try it if you don't believe it. Start Python, copy and paste the code below into the >>> prompt and hit enter. This will pop up... - -![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) - -Here is the code that produced the above screenshot. - - import PySimpleGUI as sg - - with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: - layout = [ - [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [sg.Text('Here is some text.... and a place to enter text')], - [sg.InputText()], - [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], - [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], - [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', - scale=(2, 10))], - [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [sg.Text('_' * 100, size=(70, 1))], - [sg.Text('Choose Source and Destination Folders', size=(35, 1))], - [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], - [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), - sg.FolderBrowse()], - [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] - ] - - button, values = form.LayoutAndRead(layout) - - **A note on screen shots** -You will see a number of different styles of buttons, data entry fields, etc, in this readme. They were all made with the same SDK, the only difference is in the settings that are specified on a per-element, row, form, or global basis. One setting in particular, border_width, can make a big difference on the look of the form. Some of the screenshots had a border_width of 6, others a value of 1. - - ---- -### Design Goals -> Copy, Paste, Run. - -`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the code to visually match what's on the screen. - - > Be Pythonic - - Be Pythonic... Attempted to use language constructs in a natural way and to exploit some of Python's interesting features. Python's lists and optional parameters make PySimpleGUI work. - - Forms are represented as Python lists. - - A form is a list of rows - - A row is a list of elements -- Return values are a list of button presses and input values. - -It's stunning that after so many years Python still hasn't put forth a GUI framework that truly fits the language's basic data structures, especially lists. It's hard to argue with the success to be had in quickly building GUI applications using this package's syntax. - - ----- -## Getting Started with PySimpleGUI - -### Installing - - pip install PySimpleGUI - or -Simply download the file - PySimpleGUI.py and import it into your code - - -### Prerequisites - -Python 3 -tkinter - -Runs on all Python platforms that have tkinter running on them. Thoroughly tested on Windows. Runs on Windows, Mac, Linux, Raspberry Pi. Even runs on `pypy3`. - -### Using - -To use in your code, simply import.... - `import PySimpleGUI as sg` - -Then use either "high level" API calls or build your own forms. - - sg.MsgBox('This is my first message box') - -![snap0178](https://user-images.githubusercontent.com/13696193/43658024-945c83f8-9725-11e8-8ddd-0bbe67a9fc5d.jpg) - - -Yes, it's just that easy to have a window appear on the screen using Python. With PySimpleGUI, making a custom form appear isn't much more difficult. The goal is to get you running on your GUI within ***minutes***, not hours nor days. - ---- -## APIs - -PySimpleGUI can be broken down into 2 types of API's: - * High Level single call functions - * Custom form functions - - -### Python Language Features - - There are a couple of Python language features that PySimpleGUI utilizes heavily that should be understood first... - * Variable number of arguments to a function call - * Optional parameters to a function call - -#### Variable Number of Arguments - - The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. - - sg.MsgBox('Variable number of parameters example', var1, var2, "etc") - -Each new item begins on a new line in the Message Box - - ![snap0179](https://user-images.githubusercontent.com/13696193/43658129-f6ca49c6-9725-11e8-9317-1f77443eb04a.jpg) - - - -#### Optional Parameters to a Function Call - -This feature of the Python language is utilized ***heavily*** as a method of customizing forms and form Elements. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. - -Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't *have* to be specified on each and every call. - - def MsgBox(*args, - button_color=None, - button_type=MSG_BOX_OK, - auto_close=False, - auto_close_duration=None, - icon=DEFAULT_WINDOW_ICON, - line_width=MESSAGE_BOX_LINE_WIDTH, - font=None): - -If the caller wanted to change the button color to be black on yellow, the call would look something like this: - - sg.MsgBox('This box has a custom button color', button_color=('black', 'yellow')) - - -![snap0180](https://user-images.githubusercontent.com/13696193/43658171-13a72bfe-9726-11e8-8c7a-0a46e46fb202.jpg) - - ---- - -### High Level API Calls - -The classic "input a value, print result" example. -Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. -This code prompts user to input a line of text and then displays that text in a messages box: - - - import PySimpleGUI as sg - - rc = sg.GetTextBox('Title', 'Please input something') - sg.MsgBox('Results', 'The value returned from GetTextBox', rc) - - - ![snap0181](https://user-images.githubusercontent.com/13696193/43658233-48cc7794-9726-11e8-8582-8844280c344e.jpg) - -![snap0182](https://user-images.githubusercontent.com/13696193/43658232-48aaad4e-9726-11e8-95f5-aa9b9213bb77.jpg) - - -#### Message Boxes -In addition to MsgBox, you'll find a several API calls that are shortcuts to common messages boxes. You can achieve similar results by calling MsgBox with the correct parameters. - -The differences tend to be the number and types of buttons. Here are the calls and the windows that are created. - - import PySimpleGUI as sg - - `sg.MsgBoxOK('This is an OK MsgBox')` - - ![ok](https://user-images.githubusercontent.com/13696193/43667331-723ac666-9745-11e8-8666-230c35a6afd6.jpg) - - - sg.MsgBoxOKCancel('This is an OK Cancel MsgBox') - -![ok cancel 2](https://user-images.githubusercontent.com/13696193/43667330-71d5bea6-9745-11e8-8944-b3900853aa62.jpg) - - sg.MsgBoxCancel('This is a Cancel MsgBox') - -![cancel](https://user-images.githubusercontent.com/13696193/43667329-71a007de-9745-11e8-974b-d028f68798e7.jpg) - - sg.MsgBoxYesNo('This is a Yes No MsgBox') - -![yesno](https://user-images.githubusercontent.com/13696193/43667327-717ff7dc-9745-11e8-9dce-52c305a85101.jpg) - - - sg.MsgBoxError('This is an error MsgBox') - -![error msgbox](https://user-images.githubusercontent.com/13696193/43667326-71621712-9745-11e8-87c4-56e2ab500f8e.jpg) - - sg.MsgBoxAutoClose('This is an autoclose MsgBox') - -![autoclose](https://user-images.githubusercontent.com/13696193/43667325-714997dc-9745-11e8-836a-7185dc80329f.jpg) - - sg.ScrolledTextBox(my_text, height=10) - -![scrolledtextbox 2](https://user-images.githubusercontent.com/13696193/43667324-712aa0d4-9745-11e8-83a9-a0d0570d0865.jpg) - - -Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing your printed text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. Your code could contain a line like: - - sprint(f'My variables values include x={x}', f'y={y}') - -This becomes a debug print of sorts that will route to a scrolled window. - -See also the `EasyPrint` and `Print` functions. - -#### High Level User Input - -There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. If you need only 1 value, then perhaps one of these high level functions will work. - - GetTextBox - - GetFileBox - - GetFolderBox - - `submit_clicked, value = sg.GetTextBox('Title', 'Please enter anything')` - -![gettextbox 2](https://user-images.githubusercontent.com/13696193/43667510-355b23a2-9746-11e8-9f1e-91c0dd0f4ed8.jpg) - - submit_clicked, value = sg.GetFileBox('Title', 'Choose a file') - -![getfilebox 2](https://user-images.githubusercontent.com/13696193/43667535-5821fc94-9746-11e8-95c3-82395099e994.jpg) - - submit_clicked, value = sg.GetPathBox('Title', 'Choose a folder') - -![getpathbox](https://user-images.githubusercontent.com/13696193/43667556-79874c22-9746-11e8-80f2-8262d32802c2.jpg) - - -#### Progress Meter! -We all have loops in our code. 'Isn't it joyful waiting, watching a counter scrolling past in a text window? How about one line of code to get a progress meter, that contains statistics about your code? - - - EasyProgressMeter(title, - current_value, - max_value, - *args, - orientation=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, - button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), - border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): - -Here's the one-line Progress Meter in action! - - for i in range(1,10000): - sg.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') - -That line of code resulted in this window popping up and updating. - -![preogress meter](https://user-images.githubusercontent.com/13696193/43667625-d47da702-9746-11e8-91e6-e5177883abae.jpg) - -A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. -With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. - -***Be sure and add one to your loop counter*** so that your counter goes from 1 to the max value. If you do not add one, your counter will never hit the max value. Instead it will go from 0 to max-1. - -#### Debug Output -Another call in the 'Easy' families of APIs is `EasyPrint`. It will output to a debug window. If the debug window isn't open, then the first call will open it. No need to do anything but stick a 'print' call in your code. You can even replace your 'print' calls with calls to EasyPrint by simply sticking the statement - - print = sg.EasyPrint - -at the top of your code. -There are a number of names for the same EasyPrint function. `Print` is one of the better ones to use as it's easy to remember. It is simply `print` with a capital P. - - import PySimpleGUI as sg - - for i in range(100): - sg.Print(i) - -![snap0125](https://user-images.githubusercontent.com/13696193/43114979-a696189e-8ecf-11e8-83c7-473fcf0ccc66.jpg) -Or if you didn't want to change your code: - - import PySimpleGUI as sg - - print=sg.Print - for i in range(100): - print(i) - -Just like the standard print call, `EasyPrint` supports the `sep` and `end` keyword arguments. Other names that can be used to call `EasyPrint` include Print, `eprint`, If you want to close the window, call the function `EasyPrintClose`. - -A word of caution. There are known problems when multiple PySimpleGUI windows are opened, particularly if the user closes them in an unusual way. Not a reason to stay away from using it. Just something to keep in mind if you encounter a problem. - -You can change the size of the debug window using the `SetOptions` call with the `debug_win_size` parameter. - ---- -# Custom Form API Calls (Your First Form) - -This is the FUN part of the programming of this GUI. In order to really get the most out of the API, you should be using an IDE that supports auto complete or will show you the definition of the function. This will make customizing go smoother. - -This first section on custom forms is for your typical, blocking, non-persistant form. By this I mean, when you "show" the form, the function will not return until the user has clicked a button or closed the window. When this happens, the form's window will be automatically closed. - -Two other types of forms exist. -1. Persistent form - rather than closing on button clicks, the show form function returns and the form continues to be visible. This is good for applications like a chat window. -2. Asynchronous form - the trickiest of the lot. Great care must be exercised. Examples are an MP3 player or status dashboard. Async forms are updated (refreshed) on a periodic basis. - -It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. Let's start with a basic Browse for a file and do something with it. -# Copy these design patterns! -## Pattern 1 - With Context Manager - - - with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: - form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], - [sg.InputText(), sg.FileBrowse()], - [sg.Submit(), sg.Cancel()]] - button, (source_filename,) = form.LayoutAndRead(form_rows) - -## Pattern 2 - No Context Manager - - - form = sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) - form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], - [sg.InputText(), sg.FileBrowse()], - [sg.Submit(), sg.Cancel()]] - button, (source_filename,) = form.LayoutAndRead(form_rows) - - - -These 2 design patters both produce this custom form: - -![snap0134](https://user-images.githubusercontent.com/13696193/43162410-e7775466-8f58-11e8-8d6a-da4772c00dd8.jpg) - -It's important to use the "with" context manager so that resources are freed as quickly as possible, using the currently executing thread. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. - -The second design pattern is not context manager based. If you are struggling with an unknown error, try modifying the code to run without a context manager. To do so, you simple remove the with, stick the form on the front of that statement, and un-indent the with-block code. - -You will use these design patterns or code templates for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. This is the most basic / normal of the design patterns. - -### How GUI Programming in Python Should Look - -GUI programming in Python is a mess. tkinter kinda sucks. Why is Python such a great teaching language and yet no GUI framework exists that lends itself to the basic building blocks of Python, the list? - -The key to custom forms in PySimpleGUI is to view forms as ROWS of Widgets (Elements). Each row is specified as a list of these widgets. Put the rows together and you've got a form. - -Let's look at this one. - - -![snap0131](https://user-images.githubusercontent.com/13696193/43417007-df6d8408-9407-11e8-9986-30f0415f08a5.jpg) - -Let's agree the form has 4 rows. - -The first row only has **text** that reads `Rename files or folders` - -The second row has 3 elements in it. First the **text** `Source for Folders`, then an **input** field, then a **browse** button. - -Now let's look at how those 2 rows and the other two row from Python code: - - layout = [[sg.Text('Rename files or folders')], - [sg.Text('Source for Folders', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], - [sg.Text('Source for Files ', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], - [sg.Submit(), sg.Cancel()]] - -See how the source code mirrors the layout? You simply make lists for each row, then submit that table to PySimpleGUI to show and get values from. - -And what about those return values? Most people simply want to show a form, get the input values and do something with them. So why break up the code into button callbacks, etc, when I simply want my form's input values to be given to me. - -The same "row" concept applies to return values. The form is scanned from top to bottom, left to right. Each field that's an input field will occupy a spot in the return values. - -In our example form, there are 2 fields, so the return values from this form will be a list with 2 values in it. - - button, (folder_path, file_path) = form.LayoutAndRead(layout) - -In the statement that shows and reads the form, the two input fields are directly assigned to the caller's variables `folder_path` and `file_path`, ready to use. No parsing no callbacks. - -Isn't this what almost every Python programmer looking for a GUI wants?? Something easy to work with to get the values and move on to the rest of the program, where the real action is taking place. Why write pages of tkinter code when the same layout can be achieved with PySimpleGUI in 3 or 4 lines of code. 4 lines or 40? I chose 4. - - -### Laying out your form -Your form is a 2 dimensional list in Python. The first dimension are rows, the second is a list of Elements for each row. The first thing you want to do is layout your form on paper. - - layout = [ [row 1], - [row 2], - [row 3] ] - -Simple enough... a list of lists. -A row is a list of Elements. For example this could be a row with a couple of elements on it. - - [ Input, Button] - -Turning back to our example. This GUI roughly looks like this: - - layout = [ [Text], - [InputText, FileBrowse] - [Submit, Cancel] ] - - Now let's put it all together into an entire program. - - -### Line by line explanation - -Going through each line of code in the above form will help explain how to use this design patter. Copy, modify and run it! - - with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: -This creates a new form, storing it in the variable `form`. - - form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], -The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. - - [sg.InputText(), sg.FileBrowse()], -Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. - - [sg.Submit(), sg.Cancel()]] - -The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its value to the caller. - - button, (source_filename, ) = form.LayoutAndRead(form_rows) -This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field. The result of the form is stored directly into the variable we wish to work with. - - -## Return values - - Return information from FlexForm, SG's primary form builder interface, is in this format: - - button, (value1, value2, ...) - -Each of the Elements that are Input Elements will have a value in the list of return values. You can unpack your GUI directly into the variables you want to use. - - button, (filename, folder1, folder2, should_overwrite) = form.LayoutAndRead(form_rows) - - Or, you can unpack the return results separately. - - button, values = form.LayoutAndRead(form_rows) - filename, folder1, folder2, should_overwrite = values - -If you have a SINGLE value being returned, it is written this way: - - button, (value1,) = form.LayoutAndRead(form_rows) - - - Another way of parsing the return values is to store the list of values into a variable representing the list of values. - - button, value_list = form.LayoutAndRead(form_rows) - value1 = value_list[0] - value2 = value_list[1] - ... - ---- -## All Widgets / Elements -This code utilizes as many of the elements in one form as possible. - - with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: - layout = [ - [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [sg.Text('Here is some text.... and a place to enter text')], - [sg.InputText()], - [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], - [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], - [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', - scale=(2, 10))], - [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [sg.Text('_' * 100, size=(70, 1))], - [sg.Text('Choose Source and Destination Folders', size=(35, 1))], - [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], - [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), - sg.FolderBrowse()], - [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] - ] - - button, values = form.LayoutAndRead(layout) - -This is a somewhat complex form with quite a bit of custom sizing to make things line up well. This is code you only have to write once. When looking at the code, remember that what you're seeing is a list of lists. Each row contains a list of Graphical Elements that are used to create the form. - -![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) - -Clicking the Submit button caused the form call to return. The call to MsgBox resulted in this dialog box. -![results 2](https://user-images.githubusercontent.com/13696193/43097502-44e3ed32-8e8a-11e8-9a51-2b8af0b1a682.jpg) - - -**`Note, button value can be None`**. The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. - -You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. - ---- -# Building Custom Forms -You will find it much easier to write code using PySimpleGUI if you use an IDE such as PyCharm. The features that show you documentation about the API call you are making will help you determine which settings you want to change, if any. In PyCharm, two commands are particularly helpful. - - Control-Q (when cursor is on function name) brings up a box with the function definition - Control-P (when cursor inside function call "()") shows a list of parameters and their default values - -## Synchronous Forms -The most common use of PySimpleGUI is to display and collect information from the user. The most straightforward way to do this is using a "blocking" GUI call. Execution is "blocked" while waiting for the user to close the GUI form/dialog box. -You've already seen a number of examples above that use blocking forms. Anytime you see a context manager used (see the `with` statement) it's most likely a blocking form. You can examine the show calls to be sure. If the form is a non-blocking form, it must indicate that in the call to `form.show`. - -NON-BLOCKING form call: - - form.Show(non_blocking=True) - -### Beginning a Form -The first step is to create the form object using the desired form customization. - - with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: - -This is the definition of the FlexForm object: - - def FlexForm(title, - default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), - auto_size_text=None, - auto_size_buttons=None, - scale=(None, None), - location=(None, None), - button_color=None,Font=None, - progress_bar_color=(None,None), - is_tabbed_form=False, - border_depth=None, - auto_close=False, - auto_close_duration=DEFAULT_AUTOCLOSE_TIME, - icon=DEFAULT_WINDOW_ICON): - -Parameter Descriptions. You will find these same parameters specified for each `Element` and some of them in `Row` specifications. The `Element` specified value will take precedence over the `Row` and `Form` values. - - default_element_size - Size of elements in form in characters (width, height) - auto_size_text - Bool. True if elements should size themselves according to contents - auto_size_buttons - Bool. True if button elements should size themselves according to their text label - scale - Set size of element to be a multiple of the Element size - location - Location to place window in pixels - button_color - Default color for buttons (foreground, background). Can be text or hex - progress_bar_color - Foreground and background colors for progress bars - is_tabbed_form - Bool. If True then form is a tabbed form - border_depth - Amount of 'bezel' to put on input boxes, buttons, etc. - auto_close - Bool. If True form will autoclose - auto_close_duration - Duration in seconds before form closes - icon - .ICO file that will appear on the Task Bar and end of Title Bar - - -#### Sizes -Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. - -The default Element size for PySimpleGUI is `(45,1)`. - -Sizes can be set at the element level, or in this case, the size variables apply to all elements in the form. Setting `size=(20,1)` in the form creation call will set all elements in the form to that size. - -In addition to `size` there is a `scale` option. `scale` will take the Element's size and scale it up or down depending on the scale value. `scale=(1,1)` doesn't change the Element's size. `scale=(2,1)` will set the Element's size to be twice as wide as the size setting. - -There are a couple of widgets where one of the size values is in pixels rather than characters. This is true for Progress Meters and Sliders. The second parameter is the 'height' in pixels. - -#### FlexForm - form-level variables overview -A summary of the variables that can be changed when a FlexForm is created - - default_element_size - set default size for all elements in the form - auto_size_text- true/false autosizing turned on / off - scale - set scale value for all elements - button_color- default button color (foreground, background) - font - font name and size for all text items - progress_bar_color - progress bar colors - is_tabbed_form - true/false indicates form is a tabbed or normal form - border_depth - style setting for buttons, input fields - auto_close - true/false indicates if form will automatically close - auto_close_duration - how long in seconds before closing form - icon - filename for icon that's displayed on the window on taskbar - - -## Elements -"Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. - - Text - Single Line Input - Buttons including these types: - File Browse - Folder Browse - Non-closing return - Close form - Realtime - Checkboxes - Radio Buttons - Listbox - Slider - Multi-line Text Input - Scroll-able Output - Progress Bar - Async/Non-Blocking Windows - Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling Window - "Higher level" APIs (e.g. MessageBox, YesNobox, ...) - - -### Output Elements -Building a form is simply making lists of Elements. Each list is a row in the overall GUI dialog box. The definition looks something like this: - - layout = [ [row 1 element, row 1 element], - [row 2 element, row 2 element, row 2 element] ] -The code is a crude representation of the GUI, laid out in text. -#### Text Element - - layout = [[sg.Text('This is what a Text Element looks like')]] - - - ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) - - -The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. - - Text(Text, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None, - text_color=None, - justification=None) -. - - Text - The text that's displayed - size - Element's size - auto_size_text - Bool. Change width to match size of text - font - Font name and size to use - text_color - text color - justification - Justification for the text. String - 'left', 'right', 'center' - -Some commonly used elements have 'shorthand' versions of the functions to make the code more compact. The functions `T` and `Txt` are the same as calling `Text`. - -**Fonts** in PySimpleGUI are always in this format: - - (font_name, point_size) - -The default font setting is - - ("Helvetica", 10) - -**Color** in PySimpleGUI are always in this format: - - (foreground, background) - -The values foreground and background can be the color names or the hex value formatted as a string: - - "#RRGGBB" - -**auto_size_text** -A `True` value for `auto_size_text`, when placed on any Element, indicates that the width of the Element should be shrunk do the width of the text. This is particularly useful with `Buttons` as fixed-width buttons are somewhat crude looking. The default value is `False`. You will often see this setting on FlexForm definitions. - -**Shorthand functions** -The shorthand functions for `Text` are `Txt` and `T` - - -#### Multiline Text Element - - layout = [[sg.Multiline('This is what a Multi-line Text Element looks like', size=(45,5))]] -![multiline text](https://user-images.githubusercontent.com/13696193/42670464-0824c754-8629-11e8-9741-6ed08f924618.jpg) -This Element doubles as both an input and output Element. The `DefaultText` optional parameter is used to indicate what to output to the window. - - Multiline(default_text='', - enter_submits = False, - scale=(None, None), - size=(None, None), - auto_size_text=None) -. - - default_text - Text to display in the text box - enter_submits - Bool. If True, pressing Enter key submits form - scale - Element's scale - size - Element's size - auto_size_text - Bool. Change width to match size of text - -#### Output Element -Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. More on this later. - - form.AddRow(gg.Output(size=(100,20))) - -![output element](https://user-images.githubusercontent.com/13696193/42704820-5446959c-869f-11e8-849e-047ea280387a.jpg) - - Output(scale=(None, None), - size=(None, None)) -. - - scale - How much to scale size of element - size - Size of element (width, height) in characters - -### Input Elements - These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. - -#### Text Input Element - - layout = [[sg.InputText('Default text')]] -![inputtext](https://user-images.githubusercontent.com/13696193/42693515-610a716c-867d-11e8-9a00-7e7fcf771230.jpg) - - def InputText(default_text = '', - scale=(None, None), - size=(None, None), - auto_size_text=None, - password_char='') -. - - default_text - Text initially shown in the input box - scale - Amount size is scaled by - size - (width, height) of element in characters - auto_size_text- Bool. True is element should be sized to fit text - password_char - Character that will be used to replace each entered character. Setting to a value indicates this field is a password entry field - -Shorthand functions that are equivalent to `InputText` are `Input` and `In` - - -#### Combo Element -Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. - - layout = [[sg.InputCombo(['choice 1', 'choice 2'])]] - -![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) - - InputCombo(values, - scale=(None, None), - size=(None, None), - auto_size_text=None) -. - - values - Choices to be displayed. List of strings - scale - Amount to scale size by - size - (width, height) of element in characters - auto_size_text - Bool. True if size should fit the text length - -#### Listbox Element -The standard listbox like you'll find in most GUIs. Note that the return values from this element will be a ***list of results, not a single result***. This is because the user can select more than 1 item from the list (if you set the right mode). - - layout = [[sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6))]] - -![snap0130](https://user-images.githubusercontent.com/13696193/43115859-2fbf0646-8ed3-11e8-9979-bbee8eaebfab.jpg) - - - Listbox(values, - select_mode=None, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None) -. - - values - Choices to be displayed. List of strings - select_mode - Defines how to list is to operate. - Choices include constants or strings: - Constants version: - LISTBOX_SELECT_MODE_BROWSE - LISTBOX_SELECT_MODE_EXTENDED - LISTBOX_SELECT_MODE_MULTIPLE - LISTBOX_SELECT_MODE_SINGLE - the default - Strings version: - 'browse' - 'extended' - 'multiple' - 'single' - scale - Amount to scale size by - size - (width, height) of element in characters - auto_size_text - Bool. True if size should fit the text length - -The `select_mode` option can be a string or a constant value defined as a variable. Generally speaking strings are used for these kinds of options. - -#### Slider Element -Sliders have a couple of slider-specific settings as well as appearance settings. Examples include the `orientation` and `range` settings. - - layout = [[sg.Slider(range=(1,500), default_value=222, size=(20,15), orientation='horizontal', font=('Helvetica', 12))]] - -![snap0129](https://user-images.githubusercontent.com/13696193/43115741-e1cb52c8-8ed2-11e8-80bb-0e99ae846ec1.jpg) - - Slider(range=(None,None), - default_value=None, - orientation=None, - border_width=None, - relief=None, - scale=(None, None), - size=(None, None), - font=None): -. - - range - (min, max) slider's range - default_value - default setting (within range) - orientation - 'horizontal' or 'vertical' ('h' or 'v' work) - border_width - how deep the widget looks - relief - relief style. Values are same as progress meter relief values. Can be a constant or a string: - RELIEF_RAISED= 'raised' - RELIEF_SUNKEN= 'sunken' - RELIEF_FLAT= 'flat' - RELIEF_RIDGE= 'ridge' - RELIEF_GROOVE= 'groove' - RELIEF_SOLID = 'solid' - scale - Amount to scale size by - size - (width, height) of element in characters - auto_size_text - Bool. True if size should fit the text - -#### Radio Button Element -Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. - - layout = [[sg.Radio('My first Radio!', "RADIO1", default=True), sg.Radio('My second radio!', "RADIO1")]] - -![radio element](https://user-images.githubusercontent.com/13696193/42705705-327b4b6c-86a2-11e8-81a7-740e57646ba8.jpg) - - Radio(text, - group_id, - default=False, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None) - -. - - text - Text to display next to button - group_id - Groups together multiple Radio Buttons. Can be any value - default - Bool. Initial state - scale - Amount to scale size of element - size- (width, height) size of element in characters - auto_size_text - Bool. True if should size width to fit text - font - Font type and size for text display - - -#### Checkbox Element -Checkbox elements are like Radio Button elements. They return a bool indicating whether or not they are checked. - - layout = [[sg.Checkbox('My first Checkbox!', default=True), sg.Checkbox('My second Checkbox!')]] - -![checkbox element](https://user-images.githubusercontent.com/13696193/42717015-655d73d2-86cc-11e8-9c69-3c810f48e578.jpg) - - - Checkbox(text, - default=False, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None): -. - - text - Text to display next to checkbox - default- Bool. Initial state - scale - Amount to scale size of element - size - (width, height) size of element in characters - auto_size_text- Bool. True if should size width to fit text - font- Font type and size for text display - - -#### Spin Element -An up/down spinner control. The valid values are passed in as a list. - - layout = [[sg.Spin([i for i in range(1,11)], initial_value=1), sg.Text('Volume level')]] - -![spin element](https://user-images.githubusercontent.com/13696193/42717231-8ddb51d4-86cd-11e8-827a-75f2237477fa.jpg) - - Spin(values, - intiial_value=None, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None) -. - - values - List of valid values - initial_value - String with initial value - scale - Amount to scale size of element - size - (width, height) size of element in characters - auto_size_text - Bool. True if should size width to fit text - font - Font type and size for text display - -#### Button Element -Buttons are the most important element of all! They cause the majority of the action to happen. After all, it's a button press that will get you out of a form, whether it but Submit or Cancel, one way or another a button is involved in all forms. The only exception is to this is when the user closes the window using the "X" in the upper corner which means no button was involved. - -The Types of buttons include: -* Folder Browse -* File Browse -* Close Form -* Read Form -* Realtime - - - Close Form - Normal buttons like Submit, Cancel, Yes, No, etc, are "Close Form" buttons. They cause the input values to be read and then the form is closed, returning the values to the caller. - -Folder Browse - When clicked a folder browse dialog box is opened. The results of the Folder Browse dialog box are written into one of the input fields of the form. - -File Browse - Same as the Folder Browse except rather than choosing a folder, a single file is chosen. - -Read Form - This is an async form button that will read a snapshot of all of the input fields, but does not close the form after it's clicked. - -Realtime - This is another async form button. Normal button clicks occur after a button's click is released. Realtime buttons report a click the entire time the button is held down. - -While it's possible to build forms using the Button Element directly, you should never need to do that. There are pre-made buttons and shortcuts that will make life much easier. The most basic Button element call to use is `SimpleButton` - - SimpleButton(text, - scale=(None, None), - size=(None, None), - auto_size_button=None, - button_color=None, - font=None) - -Pre-made buttons include: - - OK - Ok - Submit - Cancel - Yes - No - FileBrowse - FolderBrowse -. - layout = [[sg.OK(), sg.Cancel()]] - -![ok cancel](https://user-images.githubusercontent.com/13696193/42717733-1803f584-86d1-11e8-9223-36b782971b9f.jpg) - -The FileBrowse and FolderBrowse buttons both fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. - -The default value for `Target` is `(ThisRow, -1)`. ThisRow is a special value that tells the GUI to use the same row as the button. The Y-value of -1 means the field one value to the left of the button. For a File or Folder Browse button, the field that it fills are generally to the left of the button is most cases. - -Let's examine this form as an example: - -![button target example](https://user-images.githubusercontent.com/13696193/42718075-b4dcb61e-86d3-11e8-904c-d709dd364108.jpg) - -The `InputText` element is located at (1,0)... row 1, column 0. The `Browse` button is located at position (2,0). The Target for the button could be any of these values: - - Target = (1,0) - Target = (-1,0) -The code for the entire form could be: - - layout = [[sg.T('Source Folder')], - [sg.In()], - [sg.FolderBrowse(Target=(-1,0)), sg.OK()]] - -**Custom Buttons** -Not all buttons are created equal. A button that closes a form is different that a button that returns from the form without closing it. If you want to define your own button, you will generally do this with the Button Element `SimpleButton`, which closes the form when clicked. - -layout = [[sg.SimpleButton('My Button')]] - -![singlebutton](https://user-images.githubusercontent.com/13696193/42718281-9453deca-86d5-11e8-83c7-4b6d33720858.jpg) - -All buttons can have their text changed by changing the `button_text` variable in the button call. It is this text that is returned when a form is read. This text will be what tells you which button is called so make it unique. Most of the convenience buttons (Submit, Cancel, Yes, etc) are all SimpleButtons. The two that are not are `FileBrowse` and `FolderBrowse`. They clearly do not close the form. Instead they bring up a file or folder browser dialog box. - -**Button Images** -Now this is an exciting feature not found in many simplified packages.... images on buttons! You can make a pretty spiffy user interface with the help of a few button images. - -Your button images need to be in PNG or GIF format. When you make a button with an image, set the button background to the same color as the background. There's a button color TRANSPARENT_BUTTON that you can set your button color to in order for it to blend into the background. Note that this value is currently the same as the color as the default system background on Windows. - -This example comes from the `Demo Media Player.py` example program. Because it's a non-blocking button, it's defined as `ReadFormButton`. You also put images on blocking buttons by using `SimpleButton`. - - - sg.ReadFormButton('Restart Song', button_color=sg.TRANSPARENT_BUTTON, - image_filename=image_restart, image_size=(50, 50), image_subsample=2, border_width=0) - -Three parameters are used for button images. - - image_filename - Filename. Can be a relative path - image_size - Size of image file in pixels - image_subsample - Amount to divide the size by. 2 means your image will be 1/2 the size. 3 means 1/3 - -Here's an example form made with button images. - -![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) - -You'll find the source code in the file Demo Media Player. Here is what the button calls look like to create media player form - - sg.ReadFormButton('Pause', button_color=sg.TRANSPARENT_BUTTON, - image_filename=image_pause, image_size=(50, 50), image_subsample=2, border_width=0) - -This is one you'll have to experiment with at this point. Not up for an exhaustive explanation. - - **Realtime Buttons** - - Normally buttons are considered "clicked" when the mouse button is let UP after a downward click on the button. What about times when you need to read the raw up/down button values. A classic example for this is a robotic remote control. Building a remote control using a GUI is easy enough. One button for each of the directions is a start. Perhaps something like this: - -![snap0135](https://user-images.githubusercontent.com/13696193/43440841-bcf8d184-9466-11e8-9f7b-30a1d5ce32d3.jpg) - -This form has 2 button types. There's the normal "Simple Button" (Quit) and 4 "Realtime Buttons". - -Here is the code to make, show and get results from this form: - - form = sg.FlexForm('Robotics Remote Control', auto_size_text=True) - - form_rows = [[sg.Text('Robotics Remote Control')], - [sg.T(' '*10), sg.RealtimeButton('Forward')], - [ sg.RealtimeButton('Left'), sg.T(' '*15), sg.RealtimeButton('Right')], - [sg.T(' '*10), sg.RealtimeButton('Reverse')], - [sg.T('')], - [sg.Quit(button_color=('black', 'orange'))] - ] - - form.LayoutAndRead(form_rows, non_blocking=True) - -Somewhere later in your code will be your main event loop. This is where you do your polling of devices, do input/output, etc. It's here that you will read your form's buttons. - - while (True): - # This is the code that reads and updates your window - button, values = form.ReadNonBlocking() - if button is not None: - sg.Print(button) - if button == 'Quit' or values is None: - break - time.sleep(.01) - -This loop will read button values and print them. When one of the Realtime buttons is clicked, the call to `form.ReadNonBlocking` will return a button name matching the name on the button that was depressed. It will continue to return values as long as the button remains depressed. Once released, the ReadNonBlocking will return None for buttons ules anutton was clicked. - -**File Types** -The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is - - FileTypes=(("ALL Files", "*.*"),) - -This code produces a form where the Browse button only shows files of type .TXT - - layout = [[sg.In() ,sg.FileBrowse(file_types=(("Text Files", "*.txt"),))]] - - ***The ENTER key*** - The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. - - --- -#### ProgressBar -The `ProgressBar` element is used to build custom Progress Bar forms. It is HIGHLY recommended that you use the functions that provide a complete progress meter solution for you. Progress Meters are not easy to work with because the forms have to be non-blocking and they are tricky to debug. - -The **easiest** way to get progress meters into your code is to use the `EasyProgessMeter` API. This consists of a pair of functions, `EasyProgessMeter` and `EasyProgressMeterCancel`. You can easily cancel any progress meter by calling it with the current value = max value. This will mark the meter as expired and close the window. -You've already seen EasyProgressMeter calls presented earlier in this readme. - - sg.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') - -The return value for `EasyProgressMeter` is: -`True` if meter updated correctly -`False` if user clicked the Cancel button, closed the form, or vale reached the max value. -**Customized Progress Bar** -If you want a bit more customization of your meter, then you can go up 1 level and use the calls to `ProgressMeter` and `ProgressMeterUpdate`. These APIs behave like an object we're all used to. First you create the `ProgressMeter` object, then you call the `Update` method to update it. - -You setup the progress meter by calling - - my_meter = ProgressMeter(title, - max_value, - *args, - orientantion=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, - button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), - border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) -Then to update the bar within your loop - - return_code = ProgressMeterUpdate(my_meter, - value, - *args): -Putting it all together you get this design pattern - - my_meter = sg.ProgressMeter('Meter Title', 100000, orentation='Vert') - - for i in range(0, 100000): - sg.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') - - -The final way of using a Progress Meter with PySimpleGUI is to build a custom form with a `ProgressBar` Element in the form. You will need to run your form as a non-blocking form. When you are ready to update your progress bar, you call the `UpdateBar` method for the `ProgressBar` element itself. - - -#### Output -The Output Element is a re-direction of Stdout. Anything "printed" will be displayed in this element. - - Output(scale=(None, None), - size=(None, None)) - -Here's a complete solution for a chat-window using an Async form with an Output Element - - import PySimpleGUI as sg - # Blocking form that doesn't close - def ChatBot(): - with sg.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: - layout = [[(sg.Text('This is where standard out is being routed', size=[40, 1]))], - [sg.Output(size=(80, 20))], - [sg.Multiline(size=(70, 5), enter_submits=True), sg.ReadFormButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0])), sg.SimpleButton('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]] - # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form - # if you call LayoutAndRead from here, then you will miss the first button click - form.Layout(layout) - # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # - while True: - button, value = form.Read() - if button == 'SEND': - print(value) - else: - break - - -## Tabbed Forms -Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format - - results = ShowTabbedForm('Title for the form', - (form,layout,'Tab 1 label'), - (form2,layout2, 'Tab 2 label'), ...) - -Each of the tabs of the form is in fact a form. The same steps are taken to create the form as before. A `FlexForm` is created, then rows are filled with Elements, and finally the form is shown. When calling `ShowTabbedForm`, each form is passed in as a tuple. The tuple has the format: `(the form, the rows, a string shown on the tab)` - -Results are returned as a list of lists. For each form you'll get a list that's in the same format as a normal form. A single tab's values would be: - - (button, (values)) - -Recall that values is a list as well. Multiple tabs in the form would return like this: - - ((button1, (values1)), (button2, (values2)) - - ## Colors ## -Starting in version 2.5 you can change the background colors for the window and the Elements. - -Your forms can go from this: -![snap0155](https://user-images.githubusercontent.com/13696193/43273879-a9fdc10a-90cb-11e8-8c20-4f6a244ebe2f.jpg) - - -to this... with one function call... - -![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) - - - -While you can do it on an element by element or form level basis, the easiest way, by far, is a call to `SetOptions`. - -Be aware that once you change these options they are changed for the rest of your program's execution. All of your forms will have that look and feel, until you change it to something else (which could be the system default colors. - -This call sets all of the different color options. - - SetOptions(background_color='#9FB8AD', - text_element_background_color='#9FB8AD', - element_background_color='#9FB8AD', - scrollbar_color=None, - input_elements_background_color='#F7F3EC', - progress_meter_color = ('green', 'blue') - button_color=('white','#475841')) - - - -## Global Settings -**Global Settings** -Let's have some fun customizing! Make PySimpleGUI look the way you want it to look. You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. - - SetOptions(icon=None - button_color=(None,None) - element_size=(None,None), - margins=(None,None), - element_padding=(None,None) - auto_size_text=None - auto_size_buttons=None - font=None - border_width=None - slider_border_width=None - slider_relief=None - slider_orientation=None - autoclose_time=None - message_box_line_width=None - progress_meter_border_depth=None - progress_meter_style=None - progress_meter_relief=None - progress_meter_color=None - progress_meter_size=None - text_justification=None - background_color=None - element_background_color=None - text_element_background_color=None - input_elements_background_color=None - scrollbar_color=None, text_color=None - debug_win_size=(None,None) - window_location=(None,None) - -Explanation of parameters - - icon - filename of icon used for taskbar and title bar - button_color - button color (foreground, background) - element_size - element size (width, height) in characters - margins - tkinter margins around outsize - element_padding - tkinter padding around each element - auto_size_text - autosize the elements to fit their text - auto_size_buttons - autosize the buttons to fit their text - font - font used for elements - border_width - amount of bezel or border around sunken or raised elements - slider_border_width - changes the way sliders look - slider_relief - changes the way sliders look - slider_orientation - changes orientation of slider - autoclose_time - time in seconds for autoclose boxes - message_box_line_width - number of characers in a line of text in message boxes - progress_meter_border_depth - amount of border around raised or lowered progress meters - progress_meter_style - style of progress meter as defined by tkinter - progress_meter_relief - relief style - progress_meter_color - color of the bar and background of progress meters - progress_meter_size - size in (characters, pixels) - background_color - Color of the main window's background - element_background_color - Background color of the elements - text_element_background_color - Text element background color - input_elements_background_color - Input fields background color - scrollbar_color - Color for scrollbars (may not always work) - text_color - Text element default text color - text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' - debug_win_size - size of the Print output window - window_location - location on the screen (x,y) of window's top left cornder - - -These settings apply to all forms `SetOptions`. The Row options and Element options will take precedence over these settings. Settings can be thought of as levels of settings with the Form-level being the highest and the Element-level the lowest. Thus the levels are: - - - Form level - - Row level - - Element level - -Each lower level overrides the settings of the higher level. Once settings have been changed, they remain changed for the duration of the program (unless changed again). - -## Asynchronous (Non-Blocking) Forms -So you want to be a wizard do ya? Well go boldly! While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. With asynchronous forms the form is shown, user input is read, but your code keeps right on chugging. YOUR responsibility is to call `PySimpleGUI.ReadNonBlocking` on a periodic basis. Once a second or more will produce a reasonably snappy GUI. - -When do you use a non-blocking form? A couple of examples are -* A media file player like an MP3 player -* A status dashboard that's periodically updated -* Progress Meters - when you want to make your own progress meters -* Output using print to a scrolled text element. Good for debugging. - -Word of warning... version 2.2, the currently released, and upcoming version 2.3 differ in the return code for the `ReadNonBlocking` call. Previously the function returned 2 values, except when the form is closed using the "X" which returned a single value of `None`. The *new* way is that `ReadNonBlocking` always returns 2 values. If the user closed the form with the "X" then the return values will be None, None. You will want to key off the second value to catch this case. -The proper code to check if the user has exited the form will be a polling-loop that looks something like this: - - while True: - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': - break - -We're going to build an app that does the latter. It's going to update our form with a running clock. - -The basic flow and functions you will be calling are: -Setup - - - form = FlexForm() - form_rows = ..... - form.LayoutAndRead(form_rows, non_blocking=True) - - -Periodic refresh - - form.ReadNonBlocking() -If you need to close the form - - form.CloseNonBlockingForm() - -Rather than the usual `form.LayoutAndRead()` call, we're manually adding the rows (doing the layout) and then showing the form. After the form is shown, you simply call `form.ReadNonBlocking()` every now and then. - -When you are ready to close the form (assuming the form wasn't closed by the user or a button click) you simply call `form.CloseNonBlockingForm()` - -**Example - Running timer that updates** -See the sample code on the GitHub named Demo Media Player for another example of Async Forms. We're going to make a form and update one of the elements of that form every .01 seconds. Here's the entire code to do that. - - - import PySimpleGUI as sg - import time - - # form that doesn't block - # Make a form, but don't use context manager - form = sg.FlexForm('Running Timer', auto_size_text=True) - # Create a text element that will be updated with status information on the GUI itself - output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) - # Create the rows - form_rows = [[sg.Text('Non-blocking GUI with updates')], - [output_element], - [sg.SimpleButton('Quit')]] - # Layout the rows of the form and perform a read. Indicate the form is non-blocking! - form.LayoutAndRead(form_rows, non_blocking=True) - - # - # Some place later in your code... - # You need to perform a ReadNonBlocking on your form every now and then or - # else it won't refresh - # - - for i in range(1, 1000): - output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': - break - time.sleep(.01) - else: - form.CloseNonBlockingForm() - - - -What we have here is the same sequence of function calls as in the description. Get a form, add rows to it, show the form, and then refresh it every now and then. - -The new thing in this example is the call use of the Update method for the Text Element. The first thing we do inside the loop is "update" the text element that we made earlier. This changes the value of the text field on the form. The new value will be displayed when `form.ReadNonBlocking()` is called. - -Note the `else` statement on the for loop. This is needed because we're about to exit the loop while the form is still open. The user has not closed the form using the X nor a button so it's up to the caller to close the form using `CloseNonBlockingForm`. - -That's it... this example follows the async design pattern well. - - - -## Sample Applications -Use the example programs as a starting basis for your GUI. Copy, paste, modify and run! The demo files are: - -`Demo Recipes.py` - Sample forms for all major form types and situations. This is the place to get your code template from. Includes asynchronous forms, etc. - -`Demo DisplayHash1and256.py` - Demonstrates using High Level API calls to get a filename - -`Demo DupliucateFileFinder.py` - Demonstrates High Level API to get a folder & Easy Progress Meter to show progress of the file scanning - -`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. If anyone wants to help me package this application up, I could use a hand. - -## Fun Stuff -Here are some things to try if you're bored or want to further customize - -**Debug Output** -Be sure and check out the EasyPrint (Print) function described in the high-level API section. Leave your code the way it is, route your stdout and stderror to a scrolling window. - -For a fun time, add these lines to the top of your script - - import PySimpleGUI as sg - print = sg.Print - -This will turn all of your print statements into prints that display in a window on your screen rather than to the terminal. - -**Look and Feel** -Dial in the look and feel that you like with the `SetOptions` function. You can change all of the defaults in one function call. One line of code to customize the entire GUI. - -**ObjToString** -Ever wanted to easily display an objects contents easily? Use ObjToString to get a nicely formatted recursive walk of your objects. -This statement: - - print(sg.ObjToSting(x)) - -And this was the output - - - abc = abc - attr12 = 12 - c = - b = - a = - attr1 = 1 - attr2 = 2 - attr3 = three - attr10 = 10 - attrx = x - -You'll quickly wonder how you ever coded without it. - ---- -# Known Issues -While not an "issue" this is a ***stern warning*** - -## **Do not attempt** to call `PySimpleGUI` from multiple threads! It's `tkinter` based and `tkinter` has issues with multiple threads - -**Progress Meters** - the visual graphic portion of the meter may be off. May return to the native tkinter progress meter solution in the future. Right now a "custom" progress meter is used. On the bright side, the statistics shown are extremely accurate and can tell you something about the performance of your code. - -**Async Forms** - these include the 'easy' forms (EasyProgressMeter and EasyPrint/Print). If you start overlapping having Async forms open with normal forms then things get a littler squirrelly. Still tracking down the issues and am making it more solid every day possible. You'll know there's an issue when you see blank form. - -**EasyPrint** - EasyPrint is a new feature that's pretty awesome. You print and the output goes to a window, with a scroll bar, that you can copy and paste from. Being a new feature, it's got some potential problems. There are known interaction problems with other GUI windows. For example, closing a Print window can also close other windows you have open. For now, don't close your debug print window until other windows are closed too. - -## Contributing - -A MikeTheWatchGuy production... entirely responsible for this code.... unless it causes you trouble in which case I'm not at all responsible. - -## Versions -|Version | Description | -|--|--| -| 1.0.9 | July 10, 2018 - Initial Release | -| 1.0.21 | July 13, 2018 - Readme updates | -| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case -| 2.1.1 | July 18, 2018 - Global settings exposed, fixes -| 2.2.0| July 20, 2018 - Image Elements, Print output -| 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. -| 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi -| 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. -| 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ -| 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting - - -### Release Notes -2.3 - Sliders, Listbox's and Image elements (oh my!) - -If using Progress Meters, avoid cancelling them when you have another window open. It could lead to future windows being blank. It's being worked on. - -New debug printing capability. `sg.Print` - -2.5 Discovered issue with scroll bar on `Output` elements. The bar will match size of ROW not the size of the element. Normally you never notice this due to where on a form the `Output` element goes. - -Listboxes are still without scrollwheels. The mouse can drag to see more items. The mouse scrollwheel will also scroll the list and will `page up` and `page down` keys. - -2.7 Is the "feature complete" release. Pretty much all features are done and in the code - - -### Upcoming -Make suggestions people! Future release features - -Columns. How multiple columns would be specified in the SDK interface are still being designed. - -Port to other graphic engines. Hook up the front-end interface to a backend other than tkinter. Qt, WxPython, etc. - - - -## Code Condition - - Make it run - Make it right - Make it fast - -It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor for PEP 8 compliance. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. - -While the internals to PySimpleGUI are a tad sketchy, the public interfaces into the SDK are more strictly defined and comply with PEP 8 for the most part. - -Please log bugs and suggestions in the GitHub! It will only make the code stronger and better in the end, a good thing for us all, right? - -## Design - -A moment about the design-spirit of `PySimpleGUI`. From the beginning, this package was meant to take advantage of Python's capabilities with the goal of programming ease. - -**Single File** -While not the best programming practice, the implementation resulted in a single file solution. Only one file is needed, PySimpleGUI.py. You can post this file, email it, and easily import it using one statement. - -**Functions as objects** -In Python, functions behave just like object. When you're placing a Text Element into your form, you may be sometimes calling a function and other times declaring an object. If you use the word Text, then you're getting an object. If you're using `Txt`, then you're calling a function that returns a `Text` object. - -**Lists** -It seemed quite natural to use Python's powerful list constructs when possible. The form is specified as a series of lists. Each "row" of the GUI is represented as a list of Elements. When the form read returns the results to the user, all of the results are presented as a single list. This makes reading a form's values super-simple to do in a single line of Python code. - - -## Authors -MikeTheWatchGuy - -## License - -GNU Lesser General Public License (LGPL 3) + - -## Acknowledgments - -* Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence -* [Fredrik Lundh](https://wiki.python.org/moin/FredrikLundh) for his work on `tkinter` - - -## How Do I -Finally, I must thank the fine folks at How Do I. -https://github.com/gleitz/howdoi -Their utility has forever changed the way and pace in which I can program. I urge you to try the HowDoI.py application here on GitHub. Trust me, **it's going to be worth the effort!** -Here are the steps to run that application - - Install howdoi: - pip install howdoi - Test your install: - python -m howdoi howdoi.py - To run it: - Python HowDoI.py - -The pip command is all there is to the setup. - -The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. -For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. -![snap0109](https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg) - -In the hands of a competent programmer, this tool is **amazing**. It's a must-try kind of program that has completely changed my programming process. I'm not afraid of asking for help! You just have to be smart about using what you find. - -The PySimpleGUI window that the results are shown in is an 'input' field which means you can copy and paste the results right into your code. \ No newline at end of file From c58066c167a6fad04d2ef18ad65d5dd88712f0bf Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 3 Aug 2018 19:01:16 -0400 Subject: [PATCH 100/209] Renamed to README --- docs/README.md | 1506 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1506 insertions(+) create mode 100644 docs/README.md diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 000000000..f03d65375 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,1506 @@ + + +![pysimplegui_logo](https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png) + +[![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 +# PySimpleGUI + (Ver 2.7) + +Super-simple GUI to grasp... Powerfully customizable. + +Note - *Python3* is required to run PySimpleGUI. It takes advantage of some Python3 features that do not translate well into Python2. + +Looking to take your Python code from the world of command lines and into the convenience of a GUI? Have a Raspberry Pi with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK? Look no further, you've found your GUI package. + + import PySimpleGUI as sg + + sg.MsgBox('Hello From PySimpleGUI!', 'This is the shortest GUI program ever!') + + +![snap0136](https://user-images.githubusercontent.com/13696193/43162494-33095ece-8f59-11e8-86de-b6d8bcc5a52f.jpg) + + Build beautiful customized forms that fit your specific problem. Let PySimpleGUI solve your GUI problem while you solve the real problems. Do you really want to plod through the mountains of code required to program tkinter? + +![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) + +Perhaps you're looking for a way to interact with your Raspberry Pi in a more friendly way. The is the same form as above, except shown on a Pi. + +![raspberry pi](https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg) + + +In addition to a primary GUI, you can add a Progress Meter to your code with ONE LINE of code. Slide this into any of your `for` loops and get a nice meter like this: + + EasyProgressMeter('My meter title', current_value, max value) + + ![snap0177](https://user-images.githubusercontent.com/13696193/43658025-947973d2-9725-11e8-902f-e2d5effb6e3e.jpg) + +You can build an async media player GUI with custom buttons in 30 lines of code. + +![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) + +I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? + +There are a number of 'easy to use' Python GUIs, but they're **very** limiting. PySimpleGUI takes the best of packages like `EasyGUI`and `WxSimpleGUI` , both really handy but limited. The primary difference between these and PySimpleGUI is that in addition to getting the simple Message Boxes you also get the ability to make your own forms that are highly customizeable. Don't like the standard Message Box? Then make your own! + +Every call has optional parameters so that you can change the look and feel. Don't like the button color? It's easy to change by adding a button_color parameter to your widget. + +GUI Packages with more functionality, like QT and WxPython, require configuring and can take a ***week*** to get *reasonably familiar* with the interfaces. Clearly there needs to be a middle ground between forms with 1 or two input fields and a full-blown GUI. You'll be making your own custom forms with PySimpleGUI within minutes, even Async forms. + +With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. + +The `PySimpleGUI` package is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? + + Features of PySimpleGUI include: + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Realtime + Checkboxes + Radio Buttons + Listbox + Slider + Icons + Multi-line Text Input + Scroll-able Output + Images + Progress Bar + Async/Non-Blocking Windows + Tabbed forms + Persistent Windows + Redirect Python Output/Errors to scrolling window + 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + Single-Line-Of-Coide Proress Bar & Debug Print + Complete control of colors, look and feel + Button images + + +An example of many widgets used on a single form. A little further down you'll find the TWENTY lines of code required to create this complex form. Try it if you don't believe it. Start Python, copy and paste the code below into the >>> prompt and hit enter. This will pop up... + +![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) + +Here is the code that produced the above screenshot. + + import PySimpleGUI as sg + + with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText()], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [sg.Text('_' * 100, size=(70, 1))], + [sg.Text('Choose Source and Destination Folders', size=(35, 1))], + [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], + [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), + sg.FolderBrowse()], + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + + **A note on screen shots** +You will see a number of different styles of buttons, data entry fields, etc, in this readme. They were all made with the same SDK, the only difference is in the settings that are specified on a per-element, row, form, or global basis. One setting in particular, border_width, can make a big difference on the look of the form. Some of the screenshots had a border_width of 6, others a value of 1. + + +--- +### Design Goals +> Copy, Paste, Run. + +`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the code to visually match what's on the screen. + + > Be Pythonic + + Be Pythonic... Attempted to use language constructs in a natural way and to exploit some of Python's interesting features. Python's lists and optional parameters make PySimpleGUI work. + - Forms are represented as Python lists. + - A form is a list of rows + - A row is a list of elements +- Return values are a list of button presses and input values. + +It's stunning that after so many years Python still hasn't put forth a GUI framework that truly fits the language's basic data structures, especially lists. It's hard to argue with the success to be had in quickly building GUI applications using this package's syntax. + + ----- +## Getting Started with PySimpleGUI + +### Installing + + pip install PySimpleGUI + or +Simply download the file - PySimpleGUI.py and import it into your code + + +### Prerequisites + +Python 3 +tkinter + +Runs on all Python platforms that have tkinter running on them. Thoroughly tested on Windows. Runs on Windows, Mac, Linux, Raspberry Pi. Even runs on `pypy3`. + +### Using + +To use in your code, simply import.... + `import PySimpleGUI as sg` + +Then use either "high level" API calls or build your own forms. + + sg.MsgBox('This is my first message box') + +![snap0178](https://user-images.githubusercontent.com/13696193/43658024-945c83f8-9725-11e8-8ddd-0bbe67a9fc5d.jpg) + + +Yes, it's just that easy to have a window appear on the screen using Python. With PySimpleGUI, making a custom form appear isn't much more difficult. The goal is to get you running on your GUI within ***minutes***, not hours nor days. + +--- +## APIs + +PySimpleGUI can be broken down into 2 types of API's: + * High Level single call functions + * Custom form functions + + +### Python Language Features + + There are a couple of Python language features that PySimpleGUI utilizes heavily that should be understood first... + * Variable number of arguments to a function call + * Optional parameters to a function call + +#### Variable Number of Arguments + + The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. + + sg.MsgBox('Variable number of parameters example', var1, var2, "etc") + +Each new item begins on a new line in the Message Box + + ![snap0179](https://user-images.githubusercontent.com/13696193/43658129-f6ca49c6-9725-11e8-9317-1f77443eb04a.jpg) + + + +#### Optional Parameters to a Function Call + +This feature of the Python language is utilized ***heavily*** as a method of customizing forms and form Elements. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. + +Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't *have* to be specified on each and every call. + + def MsgBox(*args, + button_color=None, + button_type=MSG_BOX_OK, + auto_close=False, + auto_close_duration=None, + icon=DEFAULT_WINDOW_ICON, + line_width=MESSAGE_BOX_LINE_WIDTH, + font=None): + +If the caller wanted to change the button color to be black on yellow, the call would look something like this: + + sg.MsgBox('This box has a custom button color', button_color=('black', 'yellow')) + + +![snap0180](https://user-images.githubusercontent.com/13696193/43658171-13a72bfe-9726-11e8-8c7a-0a46e46fb202.jpg) + + +--- + +### High Level API Calls + +The classic "input a value, print result" example. +Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. +This code prompts user to input a line of text and then displays that text in a messages box: + + + import PySimpleGUI as sg + + rc = sg.GetTextBox('Title', 'Please input something') + sg.MsgBox('Results', 'The value returned from GetTextBox', rc) + + + ![snap0181](https://user-images.githubusercontent.com/13696193/43658233-48cc7794-9726-11e8-8582-8844280c344e.jpg) + +![snap0182](https://user-images.githubusercontent.com/13696193/43658232-48aaad4e-9726-11e8-95f5-aa9b9213bb77.jpg) + + +#### Message Boxes +In addition to MsgBox, you'll find a several API calls that are shortcuts to common messages boxes. You can achieve similar results by calling MsgBox with the correct parameters. + +The differences tend to be the number and types of buttons. Here are the calls and the windows that are created. + + import PySimpleGUI as sg + + `sg.MsgBoxOK('This is an OK MsgBox')` + + ![ok](https://user-images.githubusercontent.com/13696193/43667331-723ac666-9745-11e8-8666-230c35a6afd6.jpg) + + + sg.MsgBoxOKCancel('This is an OK Cancel MsgBox') + +![ok cancel 2](https://user-images.githubusercontent.com/13696193/43667330-71d5bea6-9745-11e8-8944-b3900853aa62.jpg) + + sg.MsgBoxCancel('This is a Cancel MsgBox') + +![cancel](https://user-images.githubusercontent.com/13696193/43667329-71a007de-9745-11e8-974b-d028f68798e7.jpg) + + sg.MsgBoxYesNo('This is a Yes No MsgBox') + +![yesno](https://user-images.githubusercontent.com/13696193/43667327-717ff7dc-9745-11e8-9dce-52c305a85101.jpg) + + + sg.MsgBoxError('This is an error MsgBox') + +![error msgbox](https://user-images.githubusercontent.com/13696193/43667326-71621712-9745-11e8-87c4-56e2ab500f8e.jpg) + + sg.MsgBoxAutoClose('This is an autoclose MsgBox') + +![autoclose](https://user-images.githubusercontent.com/13696193/43667325-714997dc-9745-11e8-836a-7185dc80329f.jpg) + + sg.ScrolledTextBox(my_text, height=10) + +![scrolledtextbox 2](https://user-images.githubusercontent.com/13696193/43667324-712aa0d4-9745-11e8-83a9-a0d0570d0865.jpg) + + +Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing your printed text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. Your code could contain a line like: + + sprint(f'My variables values include x={x}', f'y={y}') + +This becomes a debug print of sorts that will route to a scrolled window. + +See also the `EasyPrint` and `Print` functions. + +#### High Level User Input + +There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. If you need only 1 value, then perhaps one of these high level functions will work. + - GetTextBox + - GetFileBox + - GetFolderBox + + `submit_clicked, value = sg.GetTextBox('Title', 'Please enter anything')` + +![gettextbox 2](https://user-images.githubusercontent.com/13696193/43667510-355b23a2-9746-11e8-9f1e-91c0dd0f4ed8.jpg) + + submit_clicked, value = sg.GetFileBox('Title', 'Choose a file') + +![getfilebox 2](https://user-images.githubusercontent.com/13696193/43667535-5821fc94-9746-11e8-95c3-82395099e994.jpg) + + submit_clicked, value = sg.GetPathBox('Title', 'Choose a folder') + +![getpathbox](https://user-images.githubusercontent.com/13696193/43667556-79874c22-9746-11e8-80f2-8262d32802c2.jpg) + + +#### Progress Meter! +We all have loops in our code. 'Isn't it joyful waiting, watching a counter scrolling past in a text window? How about one line of code to get a progress meter, that contains statistics about your code? + + + EasyProgressMeter(title, + current_value, + max_value, + *args, + orientation=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): + +Here's the one-line Progress Meter in action! + + for i in range(1,10000): + sg.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') + +That line of code resulted in this window popping up and updating. + +![preogress meter](https://user-images.githubusercontent.com/13696193/43667625-d47da702-9746-11e8-91e6-e5177883abae.jpg) + +A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. +With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. + +***Be sure and add one to your loop counter*** so that your counter goes from 1 to the max value. If you do not add one, your counter will never hit the max value. Instead it will go from 0 to max-1. + +#### Debug Output +Another call in the 'Easy' families of APIs is `EasyPrint`. It will output to a debug window. If the debug window isn't open, then the first call will open it. No need to do anything but stick a 'print' call in your code. You can even replace your 'print' calls with calls to EasyPrint by simply sticking the statement + + print = sg.EasyPrint + +at the top of your code. +There are a number of names for the same EasyPrint function. `Print` is one of the better ones to use as it's easy to remember. It is simply `print` with a capital P. + + import PySimpleGUI as sg + + for i in range(100): + sg.Print(i) + +![snap0125](https://user-images.githubusercontent.com/13696193/43114979-a696189e-8ecf-11e8-83c7-473fcf0ccc66.jpg) +Or if you didn't want to change your code: + + import PySimpleGUI as sg + + print=sg.Print + for i in range(100): + print(i) + +Just like the standard print call, `EasyPrint` supports the `sep` and `end` keyword arguments. Other names that can be used to call `EasyPrint` include Print, `eprint`, If you want to close the window, call the function `EasyPrintClose`. + +A word of caution. There are known problems when multiple PySimpleGUI windows are opened, particularly if the user closes them in an unusual way. Not a reason to stay away from using it. Just something to keep in mind if you encounter a problem. + +You can change the size of the debug window using the `SetOptions` call with the `debug_win_size` parameter. + +--- +# Custom Form API Calls (Your First Form) + +This is the FUN part of the programming of this GUI. In order to really get the most out of the API, you should be using an IDE that supports auto complete or will show you the definition of the function. This will make customizing go smoother. + +This first section on custom forms is for your typical, blocking, non-persistant form. By this I mean, when you "show" the form, the function will not return until the user has clicked a button or closed the window. When this happens, the form's window will be automatically closed. + +Two other types of forms exist. +1. Persistent form - rather than closing on button clicks, the show form function returns and the form continues to be visible. This is good for applications like a chat window. +2. Asynchronous form - the trickiest of the lot. Great care must be exercised. Examples are an MP3 player or status dashboard. Async forms are updated (refreshed) on a periodic basis. + +It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. Let's start with a basic Browse for a file and do something with it. +# Copy these design patterns! +## Pattern 1 - With Context Manager + + + with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: + form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], + [sg.InputText(), sg.FileBrowse()], + [sg.Submit(), sg.Cancel()]] + button, (source_filename,) = form.LayoutAndRead(form_rows) + +## Pattern 2 - No Context Manager + + + form = sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) + form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], + [sg.InputText(), sg.FileBrowse()], + [sg.Submit(), sg.Cancel()]] + button, (source_filename,) = form.LayoutAndRead(form_rows) + + + +These 2 design patters both produce this custom form: + +![snap0134](https://user-images.githubusercontent.com/13696193/43162410-e7775466-8f58-11e8-8d6a-da4772c00dd8.jpg) + +It's important to use the "with" context manager so that resources are freed as quickly as possible, using the currently executing thread. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. + +The second design pattern is not context manager based. If you are struggling with an unknown error, try modifying the code to run without a context manager. To do so, you simple remove the with, stick the form on the front of that statement, and un-indent the with-block code. + +You will use these design patterns or code templates for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. This is the most basic / normal of the design patterns. + +### How GUI Programming in Python Should Look + +GUI programming in Python is a mess. tkinter kinda sucks. Why is Python such a great teaching language and yet no GUI framework exists that lends itself to the basic building blocks of Python, the list? + +The key to custom forms in PySimpleGUI is to view forms as ROWS of Widgets (Elements). Each row is specified as a list of these widgets. Put the rows together and you've got a form. + +Let's look at this one. + + +![snap0131](https://user-images.githubusercontent.com/13696193/43417007-df6d8408-9407-11e8-9986-30f0415f08a5.jpg) + +Let's agree the form has 4 rows. + +The first row only has **text** that reads `Rename files or folders` + +The second row has 3 elements in it. First the **text** `Source for Folders`, then an **input** field, then a **browse** button. + +Now let's look at how those 2 rows and the other two row from Python code: + + layout = [[sg.Text('Rename files or folders')], + [sg.Text('Source for Folders', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], + [sg.Text('Source for Files ', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], + [sg.Submit(), sg.Cancel()]] + +See how the source code mirrors the layout? You simply make lists for each row, then submit that table to PySimpleGUI to show and get values from. + +And what about those return values? Most people simply want to show a form, get the input values and do something with them. So why break up the code into button callbacks, etc, when I simply want my form's input values to be given to me. + +The same "row" concept applies to return values. The form is scanned from top to bottom, left to right. Each field that's an input field will occupy a spot in the return values. + +In our example form, there are 2 fields, so the return values from this form will be a list with 2 values in it. + + button, (folder_path, file_path) = form.LayoutAndRead(layout) + +In the statement that shows and reads the form, the two input fields are directly assigned to the caller's variables `folder_path` and `file_path`, ready to use. No parsing no callbacks. + +Isn't this what almost every Python programmer looking for a GUI wants?? Something easy to work with to get the values and move on to the rest of the program, where the real action is taking place. Why write pages of tkinter code when the same layout can be achieved with PySimpleGUI in 3 or 4 lines of code. 4 lines or 40? I chose 4. + + +### Laying out your form +Your form is a 2 dimensional list in Python. The first dimension are rows, the second is a list of Elements for each row. The first thing you want to do is layout your form on paper. + + layout = [ [row 1], + [row 2], + [row 3] ] + +Simple enough... a list of lists. +A row is a list of Elements. For example this could be a row with a couple of elements on it. + + [ Input, Button] + +Turning back to our example. This GUI roughly looks like this: + + layout = [ [Text], + [InputText, FileBrowse] + [Submit, Cancel] ] + + Now let's put it all together into an entire program. + + +### Line by line explanation + +Going through each line of code in the above form will help explain how to use this design patter. Copy, modify and run it! + + with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: +This creates a new form, storing it in the variable `form`. + + form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], +The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. + + [sg.InputText(), sg.FileBrowse()], +Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. + + [sg.Submit(), sg.Cancel()]] + +The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its value to the caller. + + button, (source_filename, ) = form.LayoutAndRead(form_rows) +This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field. The result of the form is stored directly into the variable we wish to work with. + + +## Return values + + Return information from FlexForm, SG's primary form builder interface, is in this format: + + button, (value1, value2, ...) + +Each of the Elements that are Input Elements will have a value in the list of return values. You can unpack your GUI directly into the variables you want to use. + + button, (filename, folder1, folder2, should_overwrite) = form.LayoutAndRead(form_rows) + + Or, you can unpack the return results separately. + + button, values = form.LayoutAndRead(form_rows) + filename, folder1, folder2, should_overwrite = values + +If you have a SINGLE value being returned, it is written this way: + + button, (value1,) = form.LayoutAndRead(form_rows) + + + Another way of parsing the return values is to store the list of values into a variable representing the list of values. + + button, value_list = form.LayoutAndRead(form_rows) + value1 = value_list[0] + value2 = value_list[1] + ... + +--- +## All Widgets / Elements +This code utilizes as many of the elements in one form as possible. + + with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText()], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [sg.Text('_' * 100, size=(70, 1))], + [sg.Text('Choose Source and Destination Folders', size=(35, 1))], + [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], + [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), + sg.FolderBrowse()], + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + +This is a somewhat complex form with quite a bit of custom sizing to make things line up well. This is code you only have to write once. When looking at the code, remember that what you're seeing is a list of lists. Each row contains a list of Graphical Elements that are used to create the form. + +![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) + +Clicking the Submit button caused the form call to return. The call to MsgBox resulted in this dialog box. +![results 2](https://user-images.githubusercontent.com/13696193/43097502-44e3ed32-8e8a-11e8-9a51-2b8af0b1a682.jpg) + + +**`Note, button value can be None`**. The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. + +You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. + +--- +# Building Custom Forms +You will find it much easier to write code using PySimpleGUI if you use an IDE such as PyCharm. The features that show you documentation about the API call you are making will help you determine which settings you want to change, if any. In PyCharm, two commands are particularly helpful. + + Control-Q (when cursor is on function name) brings up a box with the function definition + Control-P (when cursor inside function call "()") shows a list of parameters and their default values + +## Synchronous Forms +The most common use of PySimpleGUI is to display and collect information from the user. The most straightforward way to do this is using a "blocking" GUI call. Execution is "blocked" while waiting for the user to close the GUI form/dialog box. +You've already seen a number of examples above that use blocking forms. Anytime you see a context manager used (see the `with` statement) it's most likely a blocking form. You can examine the show calls to be sure. If the form is a non-blocking form, it must indicate that in the call to `form.show`. + +NON-BLOCKING form call: + + form.Show(non_blocking=True) + +### Beginning a Form +The first step is to create the form object using the desired form customization. + + with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: + +This is the definition of the FlexForm object: + + def FlexForm(title, + default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), + auto_size_text=None, + auto_size_buttons=None, + scale=(None, None), + location=(None, None), + button_color=None,Font=None, + progress_bar_color=(None,None), + is_tabbed_form=False, + border_depth=None, + auto_close=False, + auto_close_duration=DEFAULT_AUTOCLOSE_TIME, + icon=DEFAULT_WINDOW_ICON): + +Parameter Descriptions. You will find these same parameters specified for each `Element` and some of them in `Row` specifications. The `Element` specified value will take precedence over the `Row` and `Form` values. + + default_element_size - Size of elements in form in characters (width, height) + auto_size_text - Bool. True if elements should size themselves according to contents + auto_size_buttons - Bool. True if button elements should size themselves according to their text label + scale - Set size of element to be a multiple of the Element size + location - Location to place window in pixels + button_color - Default color for buttons (foreground, background). Can be text or hex + progress_bar_color - Foreground and background colors for progress bars + is_tabbed_form - Bool. If True then form is a tabbed form + border_depth - Amount of 'bezel' to put on input boxes, buttons, etc. + auto_close - Bool. If True form will autoclose + auto_close_duration - Duration in seconds before form closes + icon - .ICO file that will appear on the Task Bar and end of Title Bar + + +#### Sizes +Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. + +The default Element size for PySimpleGUI is `(45,1)`. + +Sizes can be set at the element level, or in this case, the size variables apply to all elements in the form. Setting `size=(20,1)` in the form creation call will set all elements in the form to that size. + +In addition to `size` there is a `scale` option. `scale` will take the Element's size and scale it up or down depending on the scale value. `scale=(1,1)` doesn't change the Element's size. `scale=(2,1)` will set the Element's size to be twice as wide as the size setting. + +There are a couple of widgets where one of the size values is in pixels rather than characters. This is true for Progress Meters and Sliders. The second parameter is the 'height' in pixels. + +#### FlexForm - form-level variables overview +A summary of the variables that can be changed when a FlexForm is created + + default_element_size - set default size for all elements in the form + auto_size_text- true/false autosizing turned on / off + scale - set scale value for all elements + button_color- default button color (foreground, background) + font - font name and size for all text items + progress_bar_color - progress bar colors + is_tabbed_form - true/false indicates form is a tabbed or normal form + border_depth - style setting for buttons, input fields + auto_close - true/false indicates if form will automatically close + auto_close_duration - how long in seconds before closing form + icon - filename for icon that's displayed on the window on taskbar + + +## Elements +"Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. + + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Realtime + Checkboxes + Radio Buttons + Listbox + Slider + Multi-line Text Input + Scroll-able Output + Progress Bar + Async/Non-Blocking Windows + Tabbed forms + Persistent Windows + Redirect Python Output/Errors to scrolling Window + "Higher level" APIs (e.g. MessageBox, YesNobox, ...) + + +### Output Elements +Building a form is simply making lists of Elements. Each list is a row in the overall GUI dialog box. The definition looks something like this: + + layout = [ [row 1 element, row 1 element], + [row 2 element, row 2 element, row 2 element] ] +The code is a crude representation of the GUI, laid out in text. +#### Text Element + + layout = [[sg.Text('This is what a Text Element looks like')]] + + + ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) + + +The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. + + Text(Text, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None, + text_color=None, + justification=None) +. + + Text - The text that's displayed + size - Element's size + auto_size_text - Bool. Change width to match size of text + font - Font name and size to use + text_color - text color + justification - Justification for the text. String - 'left', 'right', 'center' + +Some commonly used elements have 'shorthand' versions of the functions to make the code more compact. The functions `T` and `Txt` are the same as calling `Text`. + +**Fonts** in PySimpleGUI are always in this format: + + (font_name, point_size) + +The default font setting is + + ("Helvetica", 10) + +**Color** in PySimpleGUI are always in this format: + + (foreground, background) + +The values foreground and background can be the color names or the hex value formatted as a string: + + "#RRGGBB" + +**auto_size_text** +A `True` value for `auto_size_text`, when placed on any Element, indicates that the width of the Element should be shrunk do the width of the text. This is particularly useful with `Buttons` as fixed-width buttons are somewhat crude looking. The default value is `False`. You will often see this setting on FlexForm definitions. + +**Shorthand functions** +The shorthand functions for `Text` are `Txt` and `T` + + +#### Multiline Text Element + + layout = [[sg.Multiline('This is what a Multi-line Text Element looks like', size=(45,5))]] +![multiline text](https://user-images.githubusercontent.com/13696193/42670464-0824c754-8629-11e8-9741-6ed08f924618.jpg) +This Element doubles as both an input and output Element. The `DefaultText` optional parameter is used to indicate what to output to the window. + + Multiline(default_text='', + enter_submits = False, + scale=(None, None), + size=(None, None), + auto_size_text=None) +. + + default_text - Text to display in the text box + enter_submits - Bool. If True, pressing Enter key submits form + scale - Element's scale + size - Element's size + auto_size_text - Bool. Change width to match size of text + +#### Output Element +Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. More on this later. + + form.AddRow(gg.Output(size=(100,20))) + +![output element](https://user-images.githubusercontent.com/13696193/42704820-5446959c-869f-11e8-849e-047ea280387a.jpg) + + Output(scale=(None, None), + size=(None, None)) +. + + scale - How much to scale size of element + size - Size of element (width, height) in characters + +### Input Elements + These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. + +#### Text Input Element + + layout = [[sg.InputText('Default text')]] +![inputtext](https://user-images.githubusercontent.com/13696193/42693515-610a716c-867d-11e8-9a00-7e7fcf771230.jpg) + + def InputText(default_text = '', + scale=(None, None), + size=(None, None), + auto_size_text=None, + password_char='') +. + + default_text - Text initially shown in the input box + scale - Amount size is scaled by + size - (width, height) of element in characters + auto_size_text- Bool. True is element should be sized to fit text + password_char - Character that will be used to replace each entered character. Setting to a value indicates this field is a password entry field + +Shorthand functions that are equivalent to `InputText` are `Input` and `In` + + +#### Combo Element +Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. + + layout = [[sg.InputCombo(['choice 1', 'choice 2'])]] + +![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) + + InputCombo(values, + scale=(None, None), + size=(None, None), + auto_size_text=None) +. + + values - Choices to be displayed. List of strings + scale - Amount to scale size by + size - (width, height) of element in characters + auto_size_text - Bool. True if size should fit the text length + +#### Listbox Element +The standard listbox like you'll find in most GUIs. Note that the return values from this element will be a ***list of results, not a single result***. This is because the user can select more than 1 item from the list (if you set the right mode). + + layout = [[sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6))]] + +![snap0130](https://user-images.githubusercontent.com/13696193/43115859-2fbf0646-8ed3-11e8-9979-bbee8eaebfab.jpg) + + + Listbox(values, + select_mode=None, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None) +. + + values - Choices to be displayed. List of strings + select_mode - Defines how to list is to operate. + Choices include constants or strings: + Constants version: + LISTBOX_SELECT_MODE_BROWSE + LISTBOX_SELECT_MODE_EXTENDED + LISTBOX_SELECT_MODE_MULTIPLE + LISTBOX_SELECT_MODE_SINGLE - the default + Strings version: + 'browse' + 'extended' + 'multiple' + 'single' + scale - Amount to scale size by + size - (width, height) of element in characters + auto_size_text - Bool. True if size should fit the text length + +The `select_mode` option can be a string or a constant value defined as a variable. Generally speaking strings are used for these kinds of options. + +#### Slider Element +Sliders have a couple of slider-specific settings as well as appearance settings. Examples include the `orientation` and `range` settings. + + layout = [[sg.Slider(range=(1,500), default_value=222, size=(20,15), orientation='horizontal', font=('Helvetica', 12))]] + +![snap0129](https://user-images.githubusercontent.com/13696193/43115741-e1cb52c8-8ed2-11e8-80bb-0e99ae846ec1.jpg) + + Slider(range=(None,None), + default_value=None, + orientation=None, + border_width=None, + relief=None, + scale=(None, None), + size=(None, None), + font=None): +. + + range - (min, max) slider's range + default_value - default setting (within range) + orientation - 'horizontal' or 'vertical' ('h' or 'v' work) + border_width - how deep the widget looks + relief - relief style. Values are same as progress meter relief values. Can be a constant or a string: + RELIEF_RAISED= 'raised' + RELIEF_SUNKEN= 'sunken' + RELIEF_FLAT= 'flat' + RELIEF_RIDGE= 'ridge' + RELIEF_GROOVE= 'groove' + RELIEF_SOLID = 'solid' + scale - Amount to scale size by + size - (width, height) of element in characters + auto_size_text - Bool. True if size should fit the text + +#### Radio Button Element +Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. + + layout = [[sg.Radio('My first Radio!', "RADIO1", default=True), sg.Radio('My second radio!', "RADIO1")]] + +![radio element](https://user-images.githubusercontent.com/13696193/42705705-327b4b6c-86a2-11e8-81a7-740e57646ba8.jpg) + + Radio(text, + group_id, + default=False, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None) + +. + + text - Text to display next to button + group_id - Groups together multiple Radio Buttons. Can be any value + default - Bool. Initial state + scale - Amount to scale size of element + size- (width, height) size of element in characters + auto_size_text - Bool. True if should size width to fit text + font - Font type and size for text display + + +#### Checkbox Element +Checkbox elements are like Radio Button elements. They return a bool indicating whether or not they are checked. + + layout = [[sg.Checkbox('My first Checkbox!', default=True), sg.Checkbox('My second Checkbox!')]] + +![checkbox element](https://user-images.githubusercontent.com/13696193/42717015-655d73d2-86cc-11e8-9c69-3c810f48e578.jpg) + + + Checkbox(text, + default=False, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None): +. + + text - Text to display next to checkbox + default- Bool. Initial state + scale - Amount to scale size of element + size - (width, height) size of element in characters + auto_size_text- Bool. True if should size width to fit text + font- Font type and size for text display + + +#### Spin Element +An up/down spinner control. The valid values are passed in as a list. + + layout = [[sg.Spin([i for i in range(1,11)], initial_value=1), sg.Text('Volume level')]] + +![spin element](https://user-images.githubusercontent.com/13696193/42717231-8ddb51d4-86cd-11e8-827a-75f2237477fa.jpg) + + Spin(values, + intiial_value=None, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None) +. + + values - List of valid values + initial_value - String with initial value + scale - Amount to scale size of element + size - (width, height) size of element in characters + auto_size_text - Bool. True if should size width to fit text + font - Font type and size for text display + +#### Button Element +Buttons are the most important element of all! They cause the majority of the action to happen. After all, it's a button press that will get you out of a form, whether it but Submit or Cancel, one way or another a button is involved in all forms. The only exception is to this is when the user closes the window using the "X" in the upper corner which means no button was involved. + +The Types of buttons include: +* Folder Browse +* File Browse +* Close Form +* Read Form +* Realtime + + + Close Form - Normal buttons like Submit, Cancel, Yes, No, etc, are "Close Form" buttons. They cause the input values to be read and then the form is closed, returning the values to the caller. + +Folder Browse - When clicked a folder browse dialog box is opened. The results of the Folder Browse dialog box are written into one of the input fields of the form. + +File Browse - Same as the Folder Browse except rather than choosing a folder, a single file is chosen. + +Read Form - This is an async form button that will read a snapshot of all of the input fields, but does not close the form after it's clicked. + +Realtime - This is another async form button. Normal button clicks occur after a button's click is released. Realtime buttons report a click the entire time the button is held down. + +While it's possible to build forms using the Button Element directly, you should never need to do that. There are pre-made buttons and shortcuts that will make life much easier. The most basic Button element call to use is `SimpleButton` + + SimpleButton(text, + scale=(None, None), + size=(None, None), + auto_size_button=None, + button_color=None, + font=None) + +Pre-made buttons include: + + OK + Ok + Submit + Cancel + Yes + No + FileBrowse + FolderBrowse +. + layout = [[sg.OK(), sg.Cancel()]] + +![ok cancel](https://user-images.githubusercontent.com/13696193/42717733-1803f584-86d1-11e8-9223-36b782971b9f.jpg) + +The FileBrowse and FolderBrowse buttons both fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. + +The default value for `Target` is `(ThisRow, -1)`. ThisRow is a special value that tells the GUI to use the same row as the button. The Y-value of -1 means the field one value to the left of the button. For a File or Folder Browse button, the field that it fills are generally to the left of the button is most cases. + +Let's examine this form as an example: + +![button target example](https://user-images.githubusercontent.com/13696193/42718075-b4dcb61e-86d3-11e8-904c-d709dd364108.jpg) + +The `InputText` element is located at (1,0)... row 1, column 0. The `Browse` button is located at position (2,0). The Target for the button could be any of these values: + + Target = (1,0) + Target = (-1,0) +The code for the entire form could be: + + layout = [[sg.T('Source Folder')], + [sg.In()], + [sg.FolderBrowse(Target=(-1,0)), sg.OK()]] + +**Custom Buttons** +Not all buttons are created equal. A button that closes a form is different that a button that returns from the form without closing it. If you want to define your own button, you will generally do this with the Button Element `SimpleButton`, which closes the form when clicked. + +layout = [[sg.SimpleButton('My Button')]] + +![singlebutton](https://user-images.githubusercontent.com/13696193/42718281-9453deca-86d5-11e8-83c7-4b6d33720858.jpg) + +All buttons can have their text changed by changing the `button_text` variable in the button call. It is this text that is returned when a form is read. This text will be what tells you which button is called so make it unique. Most of the convenience buttons (Submit, Cancel, Yes, etc) are all SimpleButtons. The two that are not are `FileBrowse` and `FolderBrowse`. They clearly do not close the form. Instead they bring up a file or folder browser dialog box. + +**Button Images** +Now this is an exciting feature not found in many simplified packages.... images on buttons! You can make a pretty spiffy user interface with the help of a few button images. + +Your button images need to be in PNG or GIF format. When you make a button with an image, set the button background to the same color as the background. There's a button color TRANSPARENT_BUTTON that you can set your button color to in order for it to blend into the background. Note that this value is currently the same as the color as the default system background on Windows. + +This example comes from the `Demo Media Player.py` example program. Because it's a non-blocking button, it's defined as `ReadFormButton`. You also put images on blocking buttons by using `SimpleButton`. + + + sg.ReadFormButton('Restart Song', button_color=sg.TRANSPARENT_BUTTON, + image_filename=image_restart, image_size=(50, 50), image_subsample=2, border_width=0) + +Three parameters are used for button images. + + image_filename - Filename. Can be a relative path + image_size - Size of image file in pixels + image_subsample - Amount to divide the size by. 2 means your image will be 1/2 the size. 3 means 1/3 + +Here's an example form made with button images. + +![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) + +You'll find the source code in the file Demo Media Player. Here is what the button calls look like to create media player form + + sg.ReadFormButton('Pause', button_color=sg.TRANSPARENT_BUTTON, + image_filename=image_pause, image_size=(50, 50), image_subsample=2, border_width=0) + +This is one you'll have to experiment with at this point. Not up for an exhaustive explanation. + + **Realtime Buttons** + + Normally buttons are considered "clicked" when the mouse button is let UP after a downward click on the button. What about times when you need to read the raw up/down button values. A classic example for this is a robotic remote control. Building a remote control using a GUI is easy enough. One button for each of the directions is a start. Perhaps something like this: + +![snap0135](https://user-images.githubusercontent.com/13696193/43440841-bcf8d184-9466-11e8-9f7b-30a1d5ce32d3.jpg) + +This form has 2 button types. There's the normal "Simple Button" (Quit) and 4 "Realtime Buttons". + +Here is the code to make, show and get results from this form: + + form = sg.FlexForm('Robotics Remote Control', auto_size_text=True) + + form_rows = [[sg.Text('Robotics Remote Control')], + [sg.T(' '*10), sg.RealtimeButton('Forward')], + [ sg.RealtimeButton('Left'), sg.T(' '*15), sg.RealtimeButton('Right')], + [sg.T(' '*10), sg.RealtimeButton('Reverse')], + [sg.T('')], + [sg.Quit(button_color=('black', 'orange'))] + ] + + form.LayoutAndRead(form_rows, non_blocking=True) + +Somewhere later in your code will be your main event loop. This is where you do your polling of devices, do input/output, etc. It's here that you will read your form's buttons. + + while (True): + # This is the code that reads and updates your window + button, values = form.ReadNonBlocking() + if button is not None: + sg.Print(button) + if button == 'Quit' or values is None: + break + time.sleep(.01) + +This loop will read button values and print them. When one of the Realtime buttons is clicked, the call to `form.ReadNonBlocking` will return a button name matching the name on the button that was depressed. It will continue to return values as long as the button remains depressed. Once released, the ReadNonBlocking will return None for buttons ules anutton was clicked. + +**File Types** +The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is + + FileTypes=(("ALL Files", "*.*"),) + +This code produces a form where the Browse button only shows files of type .TXT + + layout = [[sg.In() ,sg.FileBrowse(file_types=(("Text Files", "*.txt"),))]] + + ***The ENTER key*** + The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. + + --- +#### ProgressBar +The `ProgressBar` element is used to build custom Progress Bar forms. It is HIGHLY recommended that you use the functions that provide a complete progress meter solution for you. Progress Meters are not easy to work with because the forms have to be non-blocking and they are tricky to debug. + +The **easiest** way to get progress meters into your code is to use the `EasyProgessMeter` API. This consists of a pair of functions, `EasyProgessMeter` and `EasyProgressMeterCancel`. You can easily cancel any progress meter by calling it with the current value = max value. This will mark the meter as expired and close the window. +You've already seen EasyProgressMeter calls presented earlier in this readme. + + sg.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') + +The return value for `EasyProgressMeter` is: +`True` if meter updated correctly +`False` if user clicked the Cancel button, closed the form, or vale reached the max value. +**Customized Progress Bar** +If you want a bit more customization of your meter, then you can go up 1 level and use the calls to `ProgressMeter` and `ProgressMeterUpdate`. These APIs behave like an object we're all used to. First you create the `ProgressMeter` object, then you call the `Update` method to update it. + +You setup the progress meter by calling + + my_meter = ProgressMeter(title, + max_value, + *args, + orientantion=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) +Then to update the bar within your loop + + return_code = ProgressMeterUpdate(my_meter, + value, + *args): +Putting it all together you get this design pattern + + my_meter = sg.ProgressMeter('Meter Title', 100000, orentation='Vert') + + for i in range(0, 100000): + sg.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') + + +The final way of using a Progress Meter with PySimpleGUI is to build a custom form with a `ProgressBar` Element in the form. You will need to run your form as a non-blocking form. When you are ready to update your progress bar, you call the `UpdateBar` method for the `ProgressBar` element itself. + + +#### Output +The Output Element is a re-direction of Stdout. Anything "printed" will be displayed in this element. + + Output(scale=(None, None), + size=(None, None)) + +Here's a complete solution for a chat-window using an Async form with an Output Element + + import PySimpleGUI as sg + # Blocking form that doesn't close + def ChatBot(): + with sg.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + layout = [[(sg.Text('This is where standard out is being routed', size=[40, 1]))], + [sg.Output(size=(80, 20))], + [sg.Multiline(size=(70, 5), enter_submits=True), sg.ReadFormButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0])), sg.SimpleButton('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]] + # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form + # if you call LayoutAndRead from here, then you will miss the first button click + form.Layout(layout) + # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # + while True: + button, value = form.Read() + if button == 'SEND': + print(value) + else: + break + + +## Tabbed Forms +Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format + + results = ShowTabbedForm('Title for the form', + (form,layout,'Tab 1 label'), + (form2,layout2, 'Tab 2 label'), ...) + +Each of the tabs of the form is in fact a form. The same steps are taken to create the form as before. A `FlexForm` is created, then rows are filled with Elements, and finally the form is shown. When calling `ShowTabbedForm`, each form is passed in as a tuple. The tuple has the format: `(the form, the rows, a string shown on the tab)` + +Results are returned as a list of lists. For each form you'll get a list that's in the same format as a normal form. A single tab's values would be: + + (button, (values)) + +Recall that values is a list as well. Multiple tabs in the form would return like this: + + ((button1, (values1)), (button2, (values2)) + + ## Colors ## +Starting in version 2.5 you can change the background colors for the window and the Elements. + +Your forms can go from this: +![snap0155](https://user-images.githubusercontent.com/13696193/43273879-a9fdc10a-90cb-11e8-8c20-4f6a244ebe2f.jpg) + + +to this... with one function call... + +![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) + + + +While you can do it on an element by element or form level basis, the easiest way, by far, is a call to `SetOptions`. + +Be aware that once you change these options they are changed for the rest of your program's execution. All of your forms will have that look and feel, until you change it to something else (which could be the system default colors. + +This call sets all of the different color options. + + SetOptions(background_color='#9FB8AD', + text_element_background_color='#9FB8AD', + element_background_color='#9FB8AD', + scrollbar_color=None, + input_elements_background_color='#F7F3EC', + progress_meter_color = ('green', 'blue') + button_color=('white','#475841')) + + + +## Global Settings +**Global Settings** +Let's have some fun customizing! Make PySimpleGUI look the way you want it to look. You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. + + SetOptions(icon=None + button_color=(None,None) + element_size=(None,None), + margins=(None,None), + element_padding=(None,None) + auto_size_text=None + auto_size_buttons=None + font=None + border_width=None + slider_border_width=None + slider_relief=None + slider_orientation=None + autoclose_time=None + message_box_line_width=None + progress_meter_border_depth=None + progress_meter_style=None + progress_meter_relief=None + progress_meter_color=None + progress_meter_size=None + text_justification=None + background_color=None + element_background_color=None + text_element_background_color=None + input_elements_background_color=None + scrollbar_color=None, text_color=None + debug_win_size=(None,None) + window_location=(None,None) + +Explanation of parameters + + icon - filename of icon used for taskbar and title bar + button_color - button color (foreground, background) + element_size - element size (width, height) in characters + margins - tkinter margins around outsize + element_padding - tkinter padding around each element + auto_size_text - autosize the elements to fit their text + auto_size_buttons - autosize the buttons to fit their text + font - font used for elements + border_width - amount of bezel or border around sunken or raised elements + slider_border_width - changes the way sliders look + slider_relief - changes the way sliders look + slider_orientation - changes orientation of slider + autoclose_time - time in seconds for autoclose boxes + message_box_line_width - number of characers in a line of text in message boxes + progress_meter_border_depth - amount of border around raised or lowered progress meters + progress_meter_style - style of progress meter as defined by tkinter + progress_meter_relief - relief style + progress_meter_color - color of the bar and background of progress meters + progress_meter_size - size in (characters, pixels) + background_color - Color of the main window's background + element_background_color - Background color of the elements + text_element_background_color - Text element background color + input_elements_background_color - Input fields background color + scrollbar_color - Color for scrollbars (may not always work) + text_color - Text element default text color + text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' + debug_win_size - size of the Print output window + window_location - location on the screen (x,y) of window's top left cornder + + +These settings apply to all forms `SetOptions`. The Row options and Element options will take precedence over these settings. Settings can be thought of as levels of settings with the Form-level being the highest and the Element-level the lowest. Thus the levels are: + + - Form level + - Row level + - Element level + +Each lower level overrides the settings of the higher level. Once settings have been changed, they remain changed for the duration of the program (unless changed again). + +## Asynchronous (Non-Blocking) Forms +So you want to be a wizard do ya? Well go boldly! While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. With asynchronous forms the form is shown, user input is read, but your code keeps right on chugging. YOUR responsibility is to call `PySimpleGUI.ReadNonBlocking` on a periodic basis. Once a second or more will produce a reasonably snappy GUI. + +When do you use a non-blocking form? A couple of examples are +* A media file player like an MP3 player +* A status dashboard that's periodically updated +* Progress Meters - when you want to make your own progress meters +* Output using print to a scrolled text element. Good for debugging. + +Word of warning... version 2.2, the currently released, and upcoming version 2.3 differ in the return code for the `ReadNonBlocking` call. Previously the function returned 2 values, except when the form is closed using the "X" which returned a single value of `None`. The *new* way is that `ReadNonBlocking` always returns 2 values. If the user closed the form with the "X" then the return values will be None, None. You will want to key off the second value to catch this case. +The proper code to check if the user has exited the form will be a polling-loop that looks something like this: + + while True: + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + +We're going to build an app that does the latter. It's going to update our form with a running clock. + +The basic flow and functions you will be calling are: +Setup + + + form = FlexForm() + form_rows = ..... + form.LayoutAndRead(form_rows, non_blocking=True) + + +Periodic refresh + + form.ReadNonBlocking() +If you need to close the form + + form.CloseNonBlockingForm() + +Rather than the usual `form.LayoutAndRead()` call, we're manually adding the rows (doing the layout) and then showing the form. After the form is shown, you simply call `form.ReadNonBlocking()` every now and then. + +When you are ready to close the form (assuming the form wasn't closed by the user or a button click) you simply call `form.CloseNonBlockingForm()` + +**Example - Running timer that updates** +See the sample code on the GitHub named Demo Media Player for another example of Async Forms. We're going to make a form and update one of the elements of that form every .01 seconds. Here's the entire code to do that. + + + import PySimpleGUI as sg + import time + + # form that doesn't block + # Make a form, but don't use context manager + form = sg.FlexForm('Running Timer', auto_size_text=True) + # Create a text element that will be updated with status information on the GUI itself + output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) + # Create the rows + form_rows = [[sg.Text('Non-blocking GUI with updates')], + [output_element], + [sg.SimpleButton('Quit')]] + # Layout the rows of the form and perform a read. Indicate the form is non-blocking! + form.LayoutAndRead(form_rows, non_blocking=True) + + # + # Some place later in your code... + # You need to perform a ReadNonBlocking on your form every now and then or + # else it won't refresh + # + + for i in range(1, 1000): + output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + time.sleep(.01) + else: + form.CloseNonBlockingForm() + + + +What we have here is the same sequence of function calls as in the description. Get a form, add rows to it, show the form, and then refresh it every now and then. + +The new thing in this example is the call use of the Update method for the Text Element. The first thing we do inside the loop is "update" the text element that we made earlier. This changes the value of the text field on the form. The new value will be displayed when `form.ReadNonBlocking()` is called. + +Note the `else` statement on the for loop. This is needed because we're about to exit the loop while the form is still open. The user has not closed the form using the X nor a button so it's up to the caller to close the form using `CloseNonBlockingForm`. + +That's it... this example follows the async design pattern well. + + + +## Sample Applications +Use the example programs as a starting basis for your GUI. Copy, paste, modify and run! The demo files are: + +`Demo Recipes.py` - Sample forms for all major form types and situations. This is the place to get your code template from. Includes asynchronous forms, etc. + +`Demo DisplayHash1and256.py` - Demonstrates using High Level API calls to get a filename + +`Demo DupliucateFileFinder.py` - Demonstrates High Level API to get a folder & Easy Progress Meter to show progress of the file scanning + +`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. If anyone wants to help me package this application up, I could use a hand. + +## Fun Stuff +Here are some things to try if you're bored or want to further customize + +**Debug Output** +Be sure and check out the EasyPrint (Print) function described in the high-level API section. Leave your code the way it is, route your stdout and stderror to a scrolling window. + +For a fun time, add these lines to the top of your script + + import PySimpleGUI as sg + print = sg.Print + +This will turn all of your print statements into prints that display in a window on your screen rather than to the terminal. + +**Look and Feel** +Dial in the look and feel that you like with the `SetOptions` function. You can change all of the defaults in one function call. One line of code to customize the entire GUI. + +**ObjToString** +Ever wanted to easily display an objects contents easily? Use ObjToString to get a nicely formatted recursive walk of your objects. +This statement: + + print(sg.ObjToSting(x)) + +And this was the output + + + abc = abc + attr12 = 12 + c = + b = + a = + attr1 = 1 + attr2 = 2 + attr3 = three + attr10 = 10 + attrx = x + +You'll quickly wonder how you ever coded without it. + +--- +# Known Issues +While not an "issue" this is a ***stern warning*** + +## **Do not attempt** to call `PySimpleGUI` from multiple threads! It's `tkinter` based and `tkinter` has issues with multiple threads + +**Progress Meters** - the visual graphic portion of the meter may be off. May return to the native tkinter progress meter solution in the future. Right now a "custom" progress meter is used. On the bright side, the statistics shown are extremely accurate and can tell you something about the performance of your code. + +**Async Forms** - these include the 'easy' forms (EasyProgressMeter and EasyPrint/Print). If you start overlapping having Async forms open with normal forms then things get a littler squirrelly. Still tracking down the issues and am making it more solid every day possible. You'll know there's an issue when you see blank form. + +**EasyPrint** - EasyPrint is a new feature that's pretty awesome. You print and the output goes to a window, with a scroll bar, that you can copy and paste from. Being a new feature, it's got some potential problems. There are known interaction problems with other GUI windows. For example, closing a Print window can also close other windows you have open. For now, don't close your debug print window until other windows are closed too. + +## Contributing + +A MikeTheWatchGuy production... entirely responsible for this code.... unless it causes you trouble in which case I'm not at all responsible. + +## Versions +|Version | Description | +|--|--| +| 1.0.9 | July 10, 2018 - Initial Release | +| 1.0.21 | July 13, 2018 - Readme updates | +| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case +| 2.1.1 | July 18, 2018 - Global settings exposed, fixes +| 2.2.0| July 20, 2018 - Image Elements, Print output +| 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. +| 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi +| 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. +| 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ +| 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting + + +### Release Notes +2.3 - Sliders, Listbox's and Image elements (oh my!) + +If using Progress Meters, avoid cancelling them when you have another window open. It could lead to future windows being blank. It's being worked on. + +New debug printing capability. `sg.Print` + +2.5 Discovered issue with scroll bar on `Output` elements. The bar will match size of ROW not the size of the element. Normally you never notice this due to where on a form the `Output` element goes. + +Listboxes are still without scrollwheels. The mouse can drag to see more items. The mouse scrollwheel will also scroll the list and will `page up` and `page down` keys. + +2.7 Is the "feature complete" release. Pretty much all features are done and in the code + + +### Upcoming +Make suggestions people! Future release features + +Columns. How multiple columns would be specified in the SDK interface are still being designed. + +Port to other graphic engines. Hook up the front-end interface to a backend other than tkinter. Qt, WxPython, etc. + + + +## Code Condition + + Make it run + Make it right + Make it fast + +It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor for PEP 8 compliance. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. + +While the internals to PySimpleGUI are a tad sketchy, the public interfaces into the SDK are more strictly defined and comply with PEP 8 for the most part. + +Please log bugs and suggestions in the GitHub! It will only make the code stronger and better in the end, a good thing for us all, right? + +## Design + +A moment about the design-spirit of `PySimpleGUI`. From the beginning, this package was meant to take advantage of Python's capabilities with the goal of programming ease. + +**Single File** +While not the best programming practice, the implementation resulted in a single file solution. Only one file is needed, PySimpleGUI.py. You can post this file, email it, and easily import it using one statement. + +**Functions as objects** +In Python, functions behave just like object. When you're placing a Text Element into your form, you may be sometimes calling a function and other times declaring an object. If you use the word Text, then you're getting an object. If you're using `Txt`, then you're calling a function that returns a `Text` object. + +**Lists** +It seemed quite natural to use Python's powerful list constructs when possible. The form is specified as a series of lists. Each "row" of the GUI is represented as a list of Elements. When the form read returns the results to the user, all of the results are presented as a single list. This makes reading a form's values super-simple to do in a single line of Python code. + + +## Authors +MikeTheWatchGuy + +## License + +GNU Lesser General Public License (LGPL 3) + + +## Acknowledgments + +* Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence +* [Fredrik Lundh](https://wiki.python.org/moin/FredrikLundh) for his work on `tkinter` + + +## How Do I +Finally, I must thank the fine folks at How Do I. +https://github.com/gleitz/howdoi +Their utility has forever changed the way and pace in which I can program. I urge you to try the HowDoI.py application here on GitHub. Trust me, **it's going to be worth the effort!** +Here are the steps to run that application + + Install howdoi: + pip install howdoi + Test your install: + python -m howdoi howdoi.py + To run it: + Python HowDoI.py + +The pip command is all there is to the setup. + +The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. +For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. +![snap0109](https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg) + +In the hands of a competent programmer, this tool is **amazing**. It's a must-try kind of program that has completely changed my programming process. I'm not afraid of asking for help! You just have to be smart about using what you find. + +The PySimpleGUI window that the results are shown in is an 'input' field which means you can copy and paste the results right into your code. \ No newline at end of file From dd23c814c5c509708f996b915928efae0e6c7fcb Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 3 Aug 2018 19:02:57 -0400 Subject: [PATCH 101/209] Deleted --- docs/README.md | 1506 ------------------------------------------------ 1 file changed, 1506 deletions(-) delete mode 100644 docs/README.md diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index f03d65375..000000000 --- a/docs/README.md +++ /dev/null @@ -1,1506 +0,0 @@ - - -![pysimplegui_logo](https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png) - -[![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 -# PySimpleGUI - (Ver 2.7) - -Super-simple GUI to grasp... Powerfully customizable. - -Note - *Python3* is required to run PySimpleGUI. It takes advantage of some Python3 features that do not translate well into Python2. - -Looking to take your Python code from the world of command lines and into the convenience of a GUI? Have a Raspberry Pi with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK? Look no further, you've found your GUI package. - - import PySimpleGUI as sg - - sg.MsgBox('Hello From PySimpleGUI!', 'This is the shortest GUI program ever!') - - -![snap0136](https://user-images.githubusercontent.com/13696193/43162494-33095ece-8f59-11e8-86de-b6d8bcc5a52f.jpg) - - Build beautiful customized forms that fit your specific problem. Let PySimpleGUI solve your GUI problem while you solve the real problems. Do you really want to plod through the mountains of code required to program tkinter? - -![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) - -Perhaps you're looking for a way to interact with your Raspberry Pi in a more friendly way. The is the same form as above, except shown on a Pi. - -![raspberry pi](https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg) - - -In addition to a primary GUI, you can add a Progress Meter to your code with ONE LINE of code. Slide this into any of your `for` loops and get a nice meter like this: - - EasyProgressMeter('My meter title', current_value, max value) - - ![snap0177](https://user-images.githubusercontent.com/13696193/43658025-947973d2-9725-11e8-902f-e2d5effb6e3e.jpg) - -You can build an async media player GUI with custom buttons in 30 lines of code. - -![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) - -I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? - -There are a number of 'easy to use' Python GUIs, but they're **very** limiting. PySimpleGUI takes the best of packages like `EasyGUI`and `WxSimpleGUI` , both really handy but limited. The primary difference between these and PySimpleGUI is that in addition to getting the simple Message Boxes you also get the ability to make your own forms that are highly customizeable. Don't like the standard Message Box? Then make your own! - -Every call has optional parameters so that you can change the look and feel. Don't like the button color? It's easy to change by adding a button_color parameter to your widget. - -GUI Packages with more functionality, like QT and WxPython, require configuring and can take a ***week*** to get *reasonably familiar* with the interfaces. Clearly there needs to be a middle ground between forms with 1 or two input fields and a full-blown GUI. You'll be making your own custom forms with PySimpleGUI within minutes, even Async forms. - -With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. - -The `PySimpleGUI` package is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? - - Features of PySimpleGUI include: - Text - Single Line Input - Buttons including these types: - File Browse - Folder Browse - Non-closing return - Close form - Realtime - Checkboxes - Radio Buttons - Listbox - Slider - Icons - Multi-line Text Input - Scroll-able Output - Images - Progress Bar - Async/Non-Blocking Windows - Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling window - 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) - Single-Line-Of-Coide Proress Bar & Debug Print - Complete control of colors, look and feel - Button images - - -An example of many widgets used on a single form. A little further down you'll find the TWENTY lines of code required to create this complex form. Try it if you don't believe it. Start Python, copy and paste the code below into the >>> prompt and hit enter. This will pop up... - -![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) - -Here is the code that produced the above screenshot. - - import PySimpleGUI as sg - - with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: - layout = [ - [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [sg.Text('Here is some text.... and a place to enter text')], - [sg.InputText()], - [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], - [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], - [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', - scale=(2, 10))], - [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [sg.Text('_' * 100, size=(70, 1))], - [sg.Text('Choose Source and Destination Folders', size=(35, 1))], - [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], - [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), - sg.FolderBrowse()], - [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] - ] - - button, values = form.LayoutAndRead(layout) - - **A note on screen shots** -You will see a number of different styles of buttons, data entry fields, etc, in this readme. They were all made with the same SDK, the only difference is in the settings that are specified on a per-element, row, form, or global basis. One setting in particular, border_width, can make a big difference on the look of the form. Some of the screenshots had a border_width of 6, others a value of 1. - - ---- -### Design Goals -> Copy, Paste, Run. - -`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the code to visually match what's on the screen. - - > Be Pythonic - - Be Pythonic... Attempted to use language constructs in a natural way and to exploit some of Python's interesting features. Python's lists and optional parameters make PySimpleGUI work. - - Forms are represented as Python lists. - - A form is a list of rows - - A row is a list of elements -- Return values are a list of button presses and input values. - -It's stunning that after so many years Python still hasn't put forth a GUI framework that truly fits the language's basic data structures, especially lists. It's hard to argue with the success to be had in quickly building GUI applications using this package's syntax. - - ----- -## Getting Started with PySimpleGUI - -### Installing - - pip install PySimpleGUI - or -Simply download the file - PySimpleGUI.py and import it into your code - - -### Prerequisites - -Python 3 -tkinter - -Runs on all Python platforms that have tkinter running on them. Thoroughly tested on Windows. Runs on Windows, Mac, Linux, Raspberry Pi. Even runs on `pypy3`. - -### Using - -To use in your code, simply import.... - `import PySimpleGUI as sg` - -Then use either "high level" API calls or build your own forms. - - sg.MsgBox('This is my first message box') - -![snap0178](https://user-images.githubusercontent.com/13696193/43658024-945c83f8-9725-11e8-8ddd-0bbe67a9fc5d.jpg) - - -Yes, it's just that easy to have a window appear on the screen using Python. With PySimpleGUI, making a custom form appear isn't much more difficult. The goal is to get you running on your GUI within ***minutes***, not hours nor days. - ---- -## APIs - -PySimpleGUI can be broken down into 2 types of API's: - * High Level single call functions - * Custom form functions - - -### Python Language Features - - There are a couple of Python language features that PySimpleGUI utilizes heavily that should be understood first... - * Variable number of arguments to a function call - * Optional parameters to a function call - -#### Variable Number of Arguments - - The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. - - sg.MsgBox('Variable number of parameters example', var1, var2, "etc") - -Each new item begins on a new line in the Message Box - - ![snap0179](https://user-images.githubusercontent.com/13696193/43658129-f6ca49c6-9725-11e8-9317-1f77443eb04a.jpg) - - - -#### Optional Parameters to a Function Call - -This feature of the Python language is utilized ***heavily*** as a method of customizing forms and form Elements. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. - -Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't *have* to be specified on each and every call. - - def MsgBox(*args, - button_color=None, - button_type=MSG_BOX_OK, - auto_close=False, - auto_close_duration=None, - icon=DEFAULT_WINDOW_ICON, - line_width=MESSAGE_BOX_LINE_WIDTH, - font=None): - -If the caller wanted to change the button color to be black on yellow, the call would look something like this: - - sg.MsgBox('This box has a custom button color', button_color=('black', 'yellow')) - - -![snap0180](https://user-images.githubusercontent.com/13696193/43658171-13a72bfe-9726-11e8-8c7a-0a46e46fb202.jpg) - - ---- - -### High Level API Calls - -The classic "input a value, print result" example. -Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. -This code prompts user to input a line of text and then displays that text in a messages box: - - - import PySimpleGUI as sg - - rc = sg.GetTextBox('Title', 'Please input something') - sg.MsgBox('Results', 'The value returned from GetTextBox', rc) - - - ![snap0181](https://user-images.githubusercontent.com/13696193/43658233-48cc7794-9726-11e8-8582-8844280c344e.jpg) - -![snap0182](https://user-images.githubusercontent.com/13696193/43658232-48aaad4e-9726-11e8-95f5-aa9b9213bb77.jpg) - - -#### Message Boxes -In addition to MsgBox, you'll find a several API calls that are shortcuts to common messages boxes. You can achieve similar results by calling MsgBox with the correct parameters. - -The differences tend to be the number and types of buttons. Here are the calls and the windows that are created. - - import PySimpleGUI as sg - - `sg.MsgBoxOK('This is an OK MsgBox')` - - ![ok](https://user-images.githubusercontent.com/13696193/43667331-723ac666-9745-11e8-8666-230c35a6afd6.jpg) - - - sg.MsgBoxOKCancel('This is an OK Cancel MsgBox') - -![ok cancel 2](https://user-images.githubusercontent.com/13696193/43667330-71d5bea6-9745-11e8-8944-b3900853aa62.jpg) - - sg.MsgBoxCancel('This is a Cancel MsgBox') - -![cancel](https://user-images.githubusercontent.com/13696193/43667329-71a007de-9745-11e8-974b-d028f68798e7.jpg) - - sg.MsgBoxYesNo('This is a Yes No MsgBox') - -![yesno](https://user-images.githubusercontent.com/13696193/43667327-717ff7dc-9745-11e8-9dce-52c305a85101.jpg) - - - sg.MsgBoxError('This is an error MsgBox') - -![error msgbox](https://user-images.githubusercontent.com/13696193/43667326-71621712-9745-11e8-87c4-56e2ab500f8e.jpg) - - sg.MsgBoxAutoClose('This is an autoclose MsgBox') - -![autoclose](https://user-images.githubusercontent.com/13696193/43667325-714997dc-9745-11e8-836a-7185dc80329f.jpg) - - sg.ScrolledTextBox(my_text, height=10) - -![scrolledtextbox 2](https://user-images.githubusercontent.com/13696193/43667324-712aa0d4-9745-11e8-83a9-a0d0570d0865.jpg) - - -Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing your printed text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. Your code could contain a line like: - - sprint(f'My variables values include x={x}', f'y={y}') - -This becomes a debug print of sorts that will route to a scrolled window. - -See also the `EasyPrint` and `Print` functions. - -#### High Level User Input - -There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. If you need only 1 value, then perhaps one of these high level functions will work. - - GetTextBox - - GetFileBox - - GetFolderBox - - `submit_clicked, value = sg.GetTextBox('Title', 'Please enter anything')` - -![gettextbox 2](https://user-images.githubusercontent.com/13696193/43667510-355b23a2-9746-11e8-9f1e-91c0dd0f4ed8.jpg) - - submit_clicked, value = sg.GetFileBox('Title', 'Choose a file') - -![getfilebox 2](https://user-images.githubusercontent.com/13696193/43667535-5821fc94-9746-11e8-95c3-82395099e994.jpg) - - submit_clicked, value = sg.GetPathBox('Title', 'Choose a folder') - -![getpathbox](https://user-images.githubusercontent.com/13696193/43667556-79874c22-9746-11e8-80f2-8262d32802c2.jpg) - - -#### Progress Meter! -We all have loops in our code. 'Isn't it joyful waiting, watching a counter scrolling past in a text window? How about one line of code to get a progress meter, that contains statistics about your code? - - - EasyProgressMeter(title, - current_value, - max_value, - *args, - orientation=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, - button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), - border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): - -Here's the one-line Progress Meter in action! - - for i in range(1,10000): - sg.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') - -That line of code resulted in this window popping up and updating. - -![preogress meter](https://user-images.githubusercontent.com/13696193/43667625-d47da702-9746-11e8-91e6-e5177883abae.jpg) - -A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. -With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. - -***Be sure and add one to your loop counter*** so that your counter goes from 1 to the max value. If you do not add one, your counter will never hit the max value. Instead it will go from 0 to max-1. - -#### Debug Output -Another call in the 'Easy' families of APIs is `EasyPrint`. It will output to a debug window. If the debug window isn't open, then the first call will open it. No need to do anything but stick a 'print' call in your code. You can even replace your 'print' calls with calls to EasyPrint by simply sticking the statement - - print = sg.EasyPrint - -at the top of your code. -There are a number of names for the same EasyPrint function. `Print` is one of the better ones to use as it's easy to remember. It is simply `print` with a capital P. - - import PySimpleGUI as sg - - for i in range(100): - sg.Print(i) - -![snap0125](https://user-images.githubusercontent.com/13696193/43114979-a696189e-8ecf-11e8-83c7-473fcf0ccc66.jpg) -Or if you didn't want to change your code: - - import PySimpleGUI as sg - - print=sg.Print - for i in range(100): - print(i) - -Just like the standard print call, `EasyPrint` supports the `sep` and `end` keyword arguments. Other names that can be used to call `EasyPrint` include Print, `eprint`, If you want to close the window, call the function `EasyPrintClose`. - -A word of caution. There are known problems when multiple PySimpleGUI windows are opened, particularly if the user closes them in an unusual way. Not a reason to stay away from using it. Just something to keep in mind if you encounter a problem. - -You can change the size of the debug window using the `SetOptions` call with the `debug_win_size` parameter. - ---- -# Custom Form API Calls (Your First Form) - -This is the FUN part of the programming of this GUI. In order to really get the most out of the API, you should be using an IDE that supports auto complete or will show you the definition of the function. This will make customizing go smoother. - -This first section on custom forms is for your typical, blocking, non-persistant form. By this I mean, when you "show" the form, the function will not return until the user has clicked a button or closed the window. When this happens, the form's window will be automatically closed. - -Two other types of forms exist. -1. Persistent form - rather than closing on button clicks, the show form function returns and the form continues to be visible. This is good for applications like a chat window. -2. Asynchronous form - the trickiest of the lot. Great care must be exercised. Examples are an MP3 player or status dashboard. Async forms are updated (refreshed) on a periodic basis. - -It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. Let's start with a basic Browse for a file and do something with it. -# Copy these design patterns! -## Pattern 1 - With Context Manager - - - with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: - form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], - [sg.InputText(), sg.FileBrowse()], - [sg.Submit(), sg.Cancel()]] - button, (source_filename,) = form.LayoutAndRead(form_rows) - -## Pattern 2 - No Context Manager - - - form = sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) - form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], - [sg.InputText(), sg.FileBrowse()], - [sg.Submit(), sg.Cancel()]] - button, (source_filename,) = form.LayoutAndRead(form_rows) - - - -These 2 design patters both produce this custom form: - -![snap0134](https://user-images.githubusercontent.com/13696193/43162410-e7775466-8f58-11e8-8d6a-da4772c00dd8.jpg) - -It's important to use the "with" context manager so that resources are freed as quickly as possible, using the currently executing thread. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. - -The second design pattern is not context manager based. If you are struggling with an unknown error, try modifying the code to run without a context manager. To do so, you simple remove the with, stick the form on the front of that statement, and un-indent the with-block code. - -You will use these design patterns or code templates for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. This is the most basic / normal of the design patterns. - -### How GUI Programming in Python Should Look - -GUI programming in Python is a mess. tkinter kinda sucks. Why is Python such a great teaching language and yet no GUI framework exists that lends itself to the basic building blocks of Python, the list? - -The key to custom forms in PySimpleGUI is to view forms as ROWS of Widgets (Elements). Each row is specified as a list of these widgets. Put the rows together and you've got a form. - -Let's look at this one. - - -![snap0131](https://user-images.githubusercontent.com/13696193/43417007-df6d8408-9407-11e8-9986-30f0415f08a5.jpg) - -Let's agree the form has 4 rows. - -The first row only has **text** that reads `Rename files or folders` - -The second row has 3 elements in it. First the **text** `Source for Folders`, then an **input** field, then a **browse** button. - -Now let's look at how those 2 rows and the other two row from Python code: - - layout = [[sg.Text('Rename files or folders')], - [sg.Text('Source for Folders', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], - [sg.Text('Source for Files ', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], - [sg.Submit(), sg.Cancel()]] - -See how the source code mirrors the layout? You simply make lists for each row, then submit that table to PySimpleGUI to show and get values from. - -And what about those return values? Most people simply want to show a form, get the input values and do something with them. So why break up the code into button callbacks, etc, when I simply want my form's input values to be given to me. - -The same "row" concept applies to return values. The form is scanned from top to bottom, left to right. Each field that's an input field will occupy a spot in the return values. - -In our example form, there are 2 fields, so the return values from this form will be a list with 2 values in it. - - button, (folder_path, file_path) = form.LayoutAndRead(layout) - -In the statement that shows and reads the form, the two input fields are directly assigned to the caller's variables `folder_path` and `file_path`, ready to use. No parsing no callbacks. - -Isn't this what almost every Python programmer looking for a GUI wants?? Something easy to work with to get the values and move on to the rest of the program, where the real action is taking place. Why write pages of tkinter code when the same layout can be achieved with PySimpleGUI in 3 or 4 lines of code. 4 lines or 40? I chose 4. - - -### Laying out your form -Your form is a 2 dimensional list in Python. The first dimension are rows, the second is a list of Elements for each row. The first thing you want to do is layout your form on paper. - - layout = [ [row 1], - [row 2], - [row 3] ] - -Simple enough... a list of lists. -A row is a list of Elements. For example this could be a row with a couple of elements on it. - - [ Input, Button] - -Turning back to our example. This GUI roughly looks like this: - - layout = [ [Text], - [InputText, FileBrowse] - [Submit, Cancel] ] - - Now let's put it all together into an entire program. - - -### Line by line explanation - -Going through each line of code in the above form will help explain how to use this design patter. Copy, modify and run it! - - with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: -This creates a new form, storing it in the variable `form`. - - form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], -The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. - - [sg.InputText(), sg.FileBrowse()], -Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. - - [sg.Submit(), sg.Cancel()]] - -The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its value to the caller. - - button, (source_filename, ) = form.LayoutAndRead(form_rows) -This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field. The result of the form is stored directly into the variable we wish to work with. - - -## Return values - - Return information from FlexForm, SG's primary form builder interface, is in this format: - - button, (value1, value2, ...) - -Each of the Elements that are Input Elements will have a value in the list of return values. You can unpack your GUI directly into the variables you want to use. - - button, (filename, folder1, folder2, should_overwrite) = form.LayoutAndRead(form_rows) - - Or, you can unpack the return results separately. - - button, values = form.LayoutAndRead(form_rows) - filename, folder1, folder2, should_overwrite = values - -If you have a SINGLE value being returned, it is written this way: - - button, (value1,) = form.LayoutAndRead(form_rows) - - - Another way of parsing the return values is to store the list of values into a variable representing the list of values. - - button, value_list = form.LayoutAndRead(form_rows) - value1 = value_list[0] - value2 = value_list[1] - ... - ---- -## All Widgets / Elements -This code utilizes as many of the elements in one form as possible. - - with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: - layout = [ - [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [sg.Text('Here is some text.... and a place to enter text')], - [sg.InputText()], - [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], - [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], - [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', - scale=(2, 10))], - [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [sg.Text('_' * 100, size=(70, 1))], - [sg.Text('Choose Source and Destination Folders', size=(35, 1))], - [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], - [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), - sg.FolderBrowse()], - [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] - ] - - button, values = form.LayoutAndRead(layout) - -This is a somewhat complex form with quite a bit of custom sizing to make things line up well. This is code you only have to write once. When looking at the code, remember that what you're seeing is a list of lists. Each row contains a list of Graphical Elements that are used to create the form. - -![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) - -Clicking the Submit button caused the form call to return. The call to MsgBox resulted in this dialog box. -![results 2](https://user-images.githubusercontent.com/13696193/43097502-44e3ed32-8e8a-11e8-9a51-2b8af0b1a682.jpg) - - -**`Note, button value can be None`**. The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. - -You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. - ---- -# Building Custom Forms -You will find it much easier to write code using PySimpleGUI if you use an IDE such as PyCharm. The features that show you documentation about the API call you are making will help you determine which settings you want to change, if any. In PyCharm, two commands are particularly helpful. - - Control-Q (when cursor is on function name) brings up a box with the function definition - Control-P (when cursor inside function call "()") shows a list of parameters and their default values - -## Synchronous Forms -The most common use of PySimpleGUI is to display and collect information from the user. The most straightforward way to do this is using a "blocking" GUI call. Execution is "blocked" while waiting for the user to close the GUI form/dialog box. -You've already seen a number of examples above that use blocking forms. Anytime you see a context manager used (see the `with` statement) it's most likely a blocking form. You can examine the show calls to be sure. If the form is a non-blocking form, it must indicate that in the call to `form.show`. - -NON-BLOCKING form call: - - form.Show(non_blocking=True) - -### Beginning a Form -The first step is to create the form object using the desired form customization. - - with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: - -This is the definition of the FlexForm object: - - def FlexForm(title, - default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), - auto_size_text=None, - auto_size_buttons=None, - scale=(None, None), - location=(None, None), - button_color=None,Font=None, - progress_bar_color=(None,None), - is_tabbed_form=False, - border_depth=None, - auto_close=False, - auto_close_duration=DEFAULT_AUTOCLOSE_TIME, - icon=DEFAULT_WINDOW_ICON): - -Parameter Descriptions. You will find these same parameters specified for each `Element` and some of them in `Row` specifications. The `Element` specified value will take precedence over the `Row` and `Form` values. - - default_element_size - Size of elements in form in characters (width, height) - auto_size_text - Bool. True if elements should size themselves according to contents - auto_size_buttons - Bool. True if button elements should size themselves according to their text label - scale - Set size of element to be a multiple of the Element size - location - Location to place window in pixels - button_color - Default color for buttons (foreground, background). Can be text or hex - progress_bar_color - Foreground and background colors for progress bars - is_tabbed_form - Bool. If True then form is a tabbed form - border_depth - Amount of 'bezel' to put on input boxes, buttons, etc. - auto_close - Bool. If True form will autoclose - auto_close_duration - Duration in seconds before form closes - icon - .ICO file that will appear on the Task Bar and end of Title Bar - - -#### Sizes -Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. - -The default Element size for PySimpleGUI is `(45,1)`. - -Sizes can be set at the element level, or in this case, the size variables apply to all elements in the form. Setting `size=(20,1)` in the form creation call will set all elements in the form to that size. - -In addition to `size` there is a `scale` option. `scale` will take the Element's size and scale it up or down depending on the scale value. `scale=(1,1)` doesn't change the Element's size. `scale=(2,1)` will set the Element's size to be twice as wide as the size setting. - -There are a couple of widgets where one of the size values is in pixels rather than characters. This is true for Progress Meters and Sliders. The second parameter is the 'height' in pixels. - -#### FlexForm - form-level variables overview -A summary of the variables that can be changed when a FlexForm is created - - default_element_size - set default size for all elements in the form - auto_size_text- true/false autosizing turned on / off - scale - set scale value for all elements - button_color- default button color (foreground, background) - font - font name and size for all text items - progress_bar_color - progress bar colors - is_tabbed_form - true/false indicates form is a tabbed or normal form - border_depth - style setting for buttons, input fields - auto_close - true/false indicates if form will automatically close - auto_close_duration - how long in seconds before closing form - icon - filename for icon that's displayed on the window on taskbar - - -## Elements -"Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. - - Text - Single Line Input - Buttons including these types: - File Browse - Folder Browse - Non-closing return - Close form - Realtime - Checkboxes - Radio Buttons - Listbox - Slider - Multi-line Text Input - Scroll-able Output - Progress Bar - Async/Non-Blocking Windows - Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling Window - "Higher level" APIs (e.g. MessageBox, YesNobox, ...) - - -### Output Elements -Building a form is simply making lists of Elements. Each list is a row in the overall GUI dialog box. The definition looks something like this: - - layout = [ [row 1 element, row 1 element], - [row 2 element, row 2 element, row 2 element] ] -The code is a crude representation of the GUI, laid out in text. -#### Text Element - - layout = [[sg.Text('This is what a Text Element looks like')]] - - - ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) - - -The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. - - Text(Text, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None, - text_color=None, - justification=None) -. - - Text - The text that's displayed - size - Element's size - auto_size_text - Bool. Change width to match size of text - font - Font name and size to use - text_color - text color - justification - Justification for the text. String - 'left', 'right', 'center' - -Some commonly used elements have 'shorthand' versions of the functions to make the code more compact. The functions `T` and `Txt` are the same as calling `Text`. - -**Fonts** in PySimpleGUI are always in this format: - - (font_name, point_size) - -The default font setting is - - ("Helvetica", 10) - -**Color** in PySimpleGUI are always in this format: - - (foreground, background) - -The values foreground and background can be the color names or the hex value formatted as a string: - - "#RRGGBB" - -**auto_size_text** -A `True` value for `auto_size_text`, when placed on any Element, indicates that the width of the Element should be shrunk do the width of the text. This is particularly useful with `Buttons` as fixed-width buttons are somewhat crude looking. The default value is `False`. You will often see this setting on FlexForm definitions. - -**Shorthand functions** -The shorthand functions for `Text` are `Txt` and `T` - - -#### Multiline Text Element - - layout = [[sg.Multiline('This is what a Multi-line Text Element looks like', size=(45,5))]] -![multiline text](https://user-images.githubusercontent.com/13696193/42670464-0824c754-8629-11e8-9741-6ed08f924618.jpg) -This Element doubles as both an input and output Element. The `DefaultText` optional parameter is used to indicate what to output to the window. - - Multiline(default_text='', - enter_submits = False, - scale=(None, None), - size=(None, None), - auto_size_text=None) -. - - default_text - Text to display in the text box - enter_submits - Bool. If True, pressing Enter key submits form - scale - Element's scale - size - Element's size - auto_size_text - Bool. Change width to match size of text - -#### Output Element -Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. More on this later. - - form.AddRow(gg.Output(size=(100,20))) - -![output element](https://user-images.githubusercontent.com/13696193/42704820-5446959c-869f-11e8-849e-047ea280387a.jpg) - - Output(scale=(None, None), - size=(None, None)) -. - - scale - How much to scale size of element - size - Size of element (width, height) in characters - -### Input Elements - These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. - -#### Text Input Element - - layout = [[sg.InputText('Default text')]] -![inputtext](https://user-images.githubusercontent.com/13696193/42693515-610a716c-867d-11e8-9a00-7e7fcf771230.jpg) - - def InputText(default_text = '', - scale=(None, None), - size=(None, None), - auto_size_text=None, - password_char='') -. - - default_text - Text initially shown in the input box - scale - Amount size is scaled by - size - (width, height) of element in characters - auto_size_text- Bool. True is element should be sized to fit text - password_char - Character that will be used to replace each entered character. Setting to a value indicates this field is a password entry field - -Shorthand functions that are equivalent to `InputText` are `Input` and `In` - - -#### Combo Element -Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. - - layout = [[sg.InputCombo(['choice 1', 'choice 2'])]] - -![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) - - InputCombo(values, - scale=(None, None), - size=(None, None), - auto_size_text=None) -. - - values - Choices to be displayed. List of strings - scale - Amount to scale size by - size - (width, height) of element in characters - auto_size_text - Bool. True if size should fit the text length - -#### Listbox Element -The standard listbox like you'll find in most GUIs. Note that the return values from this element will be a ***list of results, not a single result***. This is because the user can select more than 1 item from the list (if you set the right mode). - - layout = [[sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6))]] - -![snap0130](https://user-images.githubusercontent.com/13696193/43115859-2fbf0646-8ed3-11e8-9979-bbee8eaebfab.jpg) - - - Listbox(values, - select_mode=None, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None) -. - - values - Choices to be displayed. List of strings - select_mode - Defines how to list is to operate. - Choices include constants or strings: - Constants version: - LISTBOX_SELECT_MODE_BROWSE - LISTBOX_SELECT_MODE_EXTENDED - LISTBOX_SELECT_MODE_MULTIPLE - LISTBOX_SELECT_MODE_SINGLE - the default - Strings version: - 'browse' - 'extended' - 'multiple' - 'single' - scale - Amount to scale size by - size - (width, height) of element in characters - auto_size_text - Bool. True if size should fit the text length - -The `select_mode` option can be a string or a constant value defined as a variable. Generally speaking strings are used for these kinds of options. - -#### Slider Element -Sliders have a couple of slider-specific settings as well as appearance settings. Examples include the `orientation` and `range` settings. - - layout = [[sg.Slider(range=(1,500), default_value=222, size=(20,15), orientation='horizontal', font=('Helvetica', 12))]] - -![snap0129](https://user-images.githubusercontent.com/13696193/43115741-e1cb52c8-8ed2-11e8-80bb-0e99ae846ec1.jpg) - - Slider(range=(None,None), - default_value=None, - orientation=None, - border_width=None, - relief=None, - scale=(None, None), - size=(None, None), - font=None): -. - - range - (min, max) slider's range - default_value - default setting (within range) - orientation - 'horizontal' or 'vertical' ('h' or 'v' work) - border_width - how deep the widget looks - relief - relief style. Values are same as progress meter relief values. Can be a constant or a string: - RELIEF_RAISED= 'raised' - RELIEF_SUNKEN= 'sunken' - RELIEF_FLAT= 'flat' - RELIEF_RIDGE= 'ridge' - RELIEF_GROOVE= 'groove' - RELIEF_SOLID = 'solid' - scale - Amount to scale size by - size - (width, height) of element in characters - auto_size_text - Bool. True if size should fit the text - -#### Radio Button Element -Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. - - layout = [[sg.Radio('My first Radio!', "RADIO1", default=True), sg.Radio('My second radio!', "RADIO1")]] - -![radio element](https://user-images.githubusercontent.com/13696193/42705705-327b4b6c-86a2-11e8-81a7-740e57646ba8.jpg) - - Radio(text, - group_id, - default=False, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None) - -. - - text - Text to display next to button - group_id - Groups together multiple Radio Buttons. Can be any value - default - Bool. Initial state - scale - Amount to scale size of element - size- (width, height) size of element in characters - auto_size_text - Bool. True if should size width to fit text - font - Font type and size for text display - - -#### Checkbox Element -Checkbox elements are like Radio Button elements. They return a bool indicating whether or not they are checked. - - layout = [[sg.Checkbox('My first Checkbox!', default=True), sg.Checkbox('My second Checkbox!')]] - -![checkbox element](https://user-images.githubusercontent.com/13696193/42717015-655d73d2-86cc-11e8-9c69-3c810f48e578.jpg) - - - Checkbox(text, - default=False, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None): -. - - text - Text to display next to checkbox - default- Bool. Initial state - scale - Amount to scale size of element - size - (width, height) size of element in characters - auto_size_text- Bool. True if should size width to fit text - font- Font type and size for text display - - -#### Spin Element -An up/down spinner control. The valid values are passed in as a list. - - layout = [[sg.Spin([i for i in range(1,11)], initial_value=1), sg.Text('Volume level')]] - -![spin element](https://user-images.githubusercontent.com/13696193/42717231-8ddb51d4-86cd-11e8-827a-75f2237477fa.jpg) - - Spin(values, - intiial_value=None, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None) -. - - values - List of valid values - initial_value - String with initial value - scale - Amount to scale size of element - size - (width, height) size of element in characters - auto_size_text - Bool. True if should size width to fit text - font - Font type and size for text display - -#### Button Element -Buttons are the most important element of all! They cause the majority of the action to happen. After all, it's a button press that will get you out of a form, whether it but Submit or Cancel, one way or another a button is involved in all forms. The only exception is to this is when the user closes the window using the "X" in the upper corner which means no button was involved. - -The Types of buttons include: -* Folder Browse -* File Browse -* Close Form -* Read Form -* Realtime - - - Close Form - Normal buttons like Submit, Cancel, Yes, No, etc, are "Close Form" buttons. They cause the input values to be read and then the form is closed, returning the values to the caller. - -Folder Browse - When clicked a folder browse dialog box is opened. The results of the Folder Browse dialog box are written into one of the input fields of the form. - -File Browse - Same as the Folder Browse except rather than choosing a folder, a single file is chosen. - -Read Form - This is an async form button that will read a snapshot of all of the input fields, but does not close the form after it's clicked. - -Realtime - This is another async form button. Normal button clicks occur after a button's click is released. Realtime buttons report a click the entire time the button is held down. - -While it's possible to build forms using the Button Element directly, you should never need to do that. There are pre-made buttons and shortcuts that will make life much easier. The most basic Button element call to use is `SimpleButton` - - SimpleButton(text, - scale=(None, None), - size=(None, None), - auto_size_button=None, - button_color=None, - font=None) - -Pre-made buttons include: - - OK - Ok - Submit - Cancel - Yes - No - FileBrowse - FolderBrowse -. - layout = [[sg.OK(), sg.Cancel()]] - -![ok cancel](https://user-images.githubusercontent.com/13696193/42717733-1803f584-86d1-11e8-9223-36b782971b9f.jpg) - -The FileBrowse and FolderBrowse buttons both fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. - -The default value for `Target` is `(ThisRow, -1)`. ThisRow is a special value that tells the GUI to use the same row as the button. The Y-value of -1 means the field one value to the left of the button. For a File or Folder Browse button, the field that it fills are generally to the left of the button is most cases. - -Let's examine this form as an example: - -![button target example](https://user-images.githubusercontent.com/13696193/42718075-b4dcb61e-86d3-11e8-904c-d709dd364108.jpg) - -The `InputText` element is located at (1,0)... row 1, column 0. The `Browse` button is located at position (2,0). The Target for the button could be any of these values: - - Target = (1,0) - Target = (-1,0) -The code for the entire form could be: - - layout = [[sg.T('Source Folder')], - [sg.In()], - [sg.FolderBrowse(Target=(-1,0)), sg.OK()]] - -**Custom Buttons** -Not all buttons are created equal. A button that closes a form is different that a button that returns from the form without closing it. If you want to define your own button, you will generally do this with the Button Element `SimpleButton`, which closes the form when clicked. - -layout = [[sg.SimpleButton('My Button')]] - -![singlebutton](https://user-images.githubusercontent.com/13696193/42718281-9453deca-86d5-11e8-83c7-4b6d33720858.jpg) - -All buttons can have their text changed by changing the `button_text` variable in the button call. It is this text that is returned when a form is read. This text will be what tells you which button is called so make it unique. Most of the convenience buttons (Submit, Cancel, Yes, etc) are all SimpleButtons. The two that are not are `FileBrowse` and `FolderBrowse`. They clearly do not close the form. Instead they bring up a file or folder browser dialog box. - -**Button Images** -Now this is an exciting feature not found in many simplified packages.... images on buttons! You can make a pretty spiffy user interface with the help of a few button images. - -Your button images need to be in PNG or GIF format. When you make a button with an image, set the button background to the same color as the background. There's a button color TRANSPARENT_BUTTON that you can set your button color to in order for it to blend into the background. Note that this value is currently the same as the color as the default system background on Windows. - -This example comes from the `Demo Media Player.py` example program. Because it's a non-blocking button, it's defined as `ReadFormButton`. You also put images on blocking buttons by using `SimpleButton`. - - - sg.ReadFormButton('Restart Song', button_color=sg.TRANSPARENT_BUTTON, - image_filename=image_restart, image_size=(50, 50), image_subsample=2, border_width=0) - -Three parameters are used for button images. - - image_filename - Filename. Can be a relative path - image_size - Size of image file in pixels - image_subsample - Amount to divide the size by. 2 means your image will be 1/2 the size. 3 means 1/3 - -Here's an example form made with button images. - -![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) - -You'll find the source code in the file Demo Media Player. Here is what the button calls look like to create media player form - - sg.ReadFormButton('Pause', button_color=sg.TRANSPARENT_BUTTON, - image_filename=image_pause, image_size=(50, 50), image_subsample=2, border_width=0) - -This is one you'll have to experiment with at this point. Not up for an exhaustive explanation. - - **Realtime Buttons** - - Normally buttons are considered "clicked" when the mouse button is let UP after a downward click on the button. What about times when you need to read the raw up/down button values. A classic example for this is a robotic remote control. Building a remote control using a GUI is easy enough. One button for each of the directions is a start. Perhaps something like this: - -![snap0135](https://user-images.githubusercontent.com/13696193/43440841-bcf8d184-9466-11e8-9f7b-30a1d5ce32d3.jpg) - -This form has 2 button types. There's the normal "Simple Button" (Quit) and 4 "Realtime Buttons". - -Here is the code to make, show and get results from this form: - - form = sg.FlexForm('Robotics Remote Control', auto_size_text=True) - - form_rows = [[sg.Text('Robotics Remote Control')], - [sg.T(' '*10), sg.RealtimeButton('Forward')], - [ sg.RealtimeButton('Left'), sg.T(' '*15), sg.RealtimeButton('Right')], - [sg.T(' '*10), sg.RealtimeButton('Reverse')], - [sg.T('')], - [sg.Quit(button_color=('black', 'orange'))] - ] - - form.LayoutAndRead(form_rows, non_blocking=True) - -Somewhere later in your code will be your main event loop. This is where you do your polling of devices, do input/output, etc. It's here that you will read your form's buttons. - - while (True): - # This is the code that reads and updates your window - button, values = form.ReadNonBlocking() - if button is not None: - sg.Print(button) - if button == 'Quit' or values is None: - break - time.sleep(.01) - -This loop will read button values and print them. When one of the Realtime buttons is clicked, the call to `form.ReadNonBlocking` will return a button name matching the name on the button that was depressed. It will continue to return values as long as the button remains depressed. Once released, the ReadNonBlocking will return None for buttons ules anutton was clicked. - -**File Types** -The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is - - FileTypes=(("ALL Files", "*.*"),) - -This code produces a form where the Browse button only shows files of type .TXT - - layout = [[sg.In() ,sg.FileBrowse(file_types=(("Text Files", "*.txt"),))]] - - ***The ENTER key*** - The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. - - --- -#### ProgressBar -The `ProgressBar` element is used to build custom Progress Bar forms. It is HIGHLY recommended that you use the functions that provide a complete progress meter solution for you. Progress Meters are not easy to work with because the forms have to be non-blocking and they are tricky to debug. - -The **easiest** way to get progress meters into your code is to use the `EasyProgessMeter` API. This consists of a pair of functions, `EasyProgessMeter` and `EasyProgressMeterCancel`. You can easily cancel any progress meter by calling it with the current value = max value. This will mark the meter as expired and close the window. -You've already seen EasyProgressMeter calls presented earlier in this readme. - - sg.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') - -The return value for `EasyProgressMeter` is: -`True` if meter updated correctly -`False` if user clicked the Cancel button, closed the form, or vale reached the max value. -**Customized Progress Bar** -If you want a bit more customization of your meter, then you can go up 1 level and use the calls to `ProgressMeter` and `ProgressMeterUpdate`. These APIs behave like an object we're all used to. First you create the `ProgressMeter` object, then you call the `Update` method to update it. - -You setup the progress meter by calling - - my_meter = ProgressMeter(title, - max_value, - *args, - orientantion=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, - button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), - border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) -Then to update the bar within your loop - - return_code = ProgressMeterUpdate(my_meter, - value, - *args): -Putting it all together you get this design pattern - - my_meter = sg.ProgressMeter('Meter Title', 100000, orentation='Vert') - - for i in range(0, 100000): - sg.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') - - -The final way of using a Progress Meter with PySimpleGUI is to build a custom form with a `ProgressBar` Element in the form. You will need to run your form as a non-blocking form. When you are ready to update your progress bar, you call the `UpdateBar` method for the `ProgressBar` element itself. - - -#### Output -The Output Element is a re-direction of Stdout. Anything "printed" will be displayed in this element. - - Output(scale=(None, None), - size=(None, None)) - -Here's a complete solution for a chat-window using an Async form with an Output Element - - import PySimpleGUI as sg - # Blocking form that doesn't close - def ChatBot(): - with sg.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: - layout = [[(sg.Text('This is where standard out is being routed', size=[40, 1]))], - [sg.Output(size=(80, 20))], - [sg.Multiline(size=(70, 5), enter_submits=True), sg.ReadFormButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0])), sg.SimpleButton('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]] - # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form - # if you call LayoutAndRead from here, then you will miss the first button click - form.Layout(layout) - # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # - while True: - button, value = form.Read() - if button == 'SEND': - print(value) - else: - break - - -## Tabbed Forms -Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format - - results = ShowTabbedForm('Title for the form', - (form,layout,'Tab 1 label'), - (form2,layout2, 'Tab 2 label'), ...) - -Each of the tabs of the form is in fact a form. The same steps are taken to create the form as before. A `FlexForm` is created, then rows are filled with Elements, and finally the form is shown. When calling `ShowTabbedForm`, each form is passed in as a tuple. The tuple has the format: `(the form, the rows, a string shown on the tab)` - -Results are returned as a list of lists. For each form you'll get a list that's in the same format as a normal form. A single tab's values would be: - - (button, (values)) - -Recall that values is a list as well. Multiple tabs in the form would return like this: - - ((button1, (values1)), (button2, (values2)) - - ## Colors ## -Starting in version 2.5 you can change the background colors for the window and the Elements. - -Your forms can go from this: -![snap0155](https://user-images.githubusercontent.com/13696193/43273879-a9fdc10a-90cb-11e8-8c20-4f6a244ebe2f.jpg) - - -to this... with one function call... - -![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) - - - -While you can do it on an element by element or form level basis, the easiest way, by far, is a call to `SetOptions`. - -Be aware that once you change these options they are changed for the rest of your program's execution. All of your forms will have that look and feel, until you change it to something else (which could be the system default colors. - -This call sets all of the different color options. - - SetOptions(background_color='#9FB8AD', - text_element_background_color='#9FB8AD', - element_background_color='#9FB8AD', - scrollbar_color=None, - input_elements_background_color='#F7F3EC', - progress_meter_color = ('green', 'blue') - button_color=('white','#475841')) - - - -## Global Settings -**Global Settings** -Let's have some fun customizing! Make PySimpleGUI look the way you want it to look. You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. - - SetOptions(icon=None - button_color=(None,None) - element_size=(None,None), - margins=(None,None), - element_padding=(None,None) - auto_size_text=None - auto_size_buttons=None - font=None - border_width=None - slider_border_width=None - slider_relief=None - slider_orientation=None - autoclose_time=None - message_box_line_width=None - progress_meter_border_depth=None - progress_meter_style=None - progress_meter_relief=None - progress_meter_color=None - progress_meter_size=None - text_justification=None - background_color=None - element_background_color=None - text_element_background_color=None - input_elements_background_color=None - scrollbar_color=None, text_color=None - debug_win_size=(None,None) - window_location=(None,None) - -Explanation of parameters - - icon - filename of icon used for taskbar and title bar - button_color - button color (foreground, background) - element_size - element size (width, height) in characters - margins - tkinter margins around outsize - element_padding - tkinter padding around each element - auto_size_text - autosize the elements to fit their text - auto_size_buttons - autosize the buttons to fit their text - font - font used for elements - border_width - amount of bezel or border around sunken or raised elements - slider_border_width - changes the way sliders look - slider_relief - changes the way sliders look - slider_orientation - changes orientation of slider - autoclose_time - time in seconds for autoclose boxes - message_box_line_width - number of characers in a line of text in message boxes - progress_meter_border_depth - amount of border around raised or lowered progress meters - progress_meter_style - style of progress meter as defined by tkinter - progress_meter_relief - relief style - progress_meter_color - color of the bar and background of progress meters - progress_meter_size - size in (characters, pixels) - background_color - Color of the main window's background - element_background_color - Background color of the elements - text_element_background_color - Text element background color - input_elements_background_color - Input fields background color - scrollbar_color - Color for scrollbars (may not always work) - text_color - Text element default text color - text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' - debug_win_size - size of the Print output window - window_location - location on the screen (x,y) of window's top left cornder - - -These settings apply to all forms `SetOptions`. The Row options and Element options will take precedence over these settings. Settings can be thought of as levels of settings with the Form-level being the highest and the Element-level the lowest. Thus the levels are: - - - Form level - - Row level - - Element level - -Each lower level overrides the settings of the higher level. Once settings have been changed, they remain changed for the duration of the program (unless changed again). - -## Asynchronous (Non-Blocking) Forms -So you want to be a wizard do ya? Well go boldly! While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. With asynchronous forms the form is shown, user input is read, but your code keeps right on chugging. YOUR responsibility is to call `PySimpleGUI.ReadNonBlocking` on a periodic basis. Once a second or more will produce a reasonably snappy GUI. - -When do you use a non-blocking form? A couple of examples are -* A media file player like an MP3 player -* A status dashboard that's periodically updated -* Progress Meters - when you want to make your own progress meters -* Output using print to a scrolled text element. Good for debugging. - -Word of warning... version 2.2, the currently released, and upcoming version 2.3 differ in the return code for the `ReadNonBlocking` call. Previously the function returned 2 values, except when the form is closed using the "X" which returned a single value of `None`. The *new* way is that `ReadNonBlocking` always returns 2 values. If the user closed the form with the "X" then the return values will be None, None. You will want to key off the second value to catch this case. -The proper code to check if the user has exited the form will be a polling-loop that looks something like this: - - while True: - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': - break - -We're going to build an app that does the latter. It's going to update our form with a running clock. - -The basic flow and functions you will be calling are: -Setup - - - form = FlexForm() - form_rows = ..... - form.LayoutAndRead(form_rows, non_blocking=True) - - -Periodic refresh - - form.ReadNonBlocking() -If you need to close the form - - form.CloseNonBlockingForm() - -Rather than the usual `form.LayoutAndRead()` call, we're manually adding the rows (doing the layout) and then showing the form. After the form is shown, you simply call `form.ReadNonBlocking()` every now and then. - -When you are ready to close the form (assuming the form wasn't closed by the user or a button click) you simply call `form.CloseNonBlockingForm()` - -**Example - Running timer that updates** -See the sample code on the GitHub named Demo Media Player for another example of Async Forms. We're going to make a form and update one of the elements of that form every .01 seconds. Here's the entire code to do that. - - - import PySimpleGUI as sg - import time - - # form that doesn't block - # Make a form, but don't use context manager - form = sg.FlexForm('Running Timer', auto_size_text=True) - # Create a text element that will be updated with status information on the GUI itself - output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) - # Create the rows - form_rows = [[sg.Text('Non-blocking GUI with updates')], - [output_element], - [sg.SimpleButton('Quit')]] - # Layout the rows of the form and perform a read. Indicate the form is non-blocking! - form.LayoutAndRead(form_rows, non_blocking=True) - - # - # Some place later in your code... - # You need to perform a ReadNonBlocking on your form every now and then or - # else it won't refresh - # - - for i in range(1, 1000): - output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': - break - time.sleep(.01) - else: - form.CloseNonBlockingForm() - - - -What we have here is the same sequence of function calls as in the description. Get a form, add rows to it, show the form, and then refresh it every now and then. - -The new thing in this example is the call use of the Update method for the Text Element. The first thing we do inside the loop is "update" the text element that we made earlier. This changes the value of the text field on the form. The new value will be displayed when `form.ReadNonBlocking()` is called. - -Note the `else` statement on the for loop. This is needed because we're about to exit the loop while the form is still open. The user has not closed the form using the X nor a button so it's up to the caller to close the form using `CloseNonBlockingForm`. - -That's it... this example follows the async design pattern well. - - - -## Sample Applications -Use the example programs as a starting basis for your GUI. Copy, paste, modify and run! The demo files are: - -`Demo Recipes.py` - Sample forms for all major form types and situations. This is the place to get your code template from. Includes asynchronous forms, etc. - -`Demo DisplayHash1and256.py` - Demonstrates using High Level API calls to get a filename - -`Demo DupliucateFileFinder.py` - Demonstrates High Level API to get a folder & Easy Progress Meter to show progress of the file scanning - -`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. If anyone wants to help me package this application up, I could use a hand. - -## Fun Stuff -Here are some things to try if you're bored or want to further customize - -**Debug Output** -Be sure and check out the EasyPrint (Print) function described in the high-level API section. Leave your code the way it is, route your stdout and stderror to a scrolling window. - -For a fun time, add these lines to the top of your script - - import PySimpleGUI as sg - print = sg.Print - -This will turn all of your print statements into prints that display in a window on your screen rather than to the terminal. - -**Look and Feel** -Dial in the look and feel that you like with the `SetOptions` function. You can change all of the defaults in one function call. One line of code to customize the entire GUI. - -**ObjToString** -Ever wanted to easily display an objects contents easily? Use ObjToString to get a nicely formatted recursive walk of your objects. -This statement: - - print(sg.ObjToSting(x)) - -And this was the output - - - abc = abc - attr12 = 12 - c = - b = - a = - attr1 = 1 - attr2 = 2 - attr3 = three - attr10 = 10 - attrx = x - -You'll quickly wonder how you ever coded without it. - ---- -# Known Issues -While not an "issue" this is a ***stern warning*** - -## **Do not attempt** to call `PySimpleGUI` from multiple threads! It's `tkinter` based and `tkinter` has issues with multiple threads - -**Progress Meters** - the visual graphic portion of the meter may be off. May return to the native tkinter progress meter solution in the future. Right now a "custom" progress meter is used. On the bright side, the statistics shown are extremely accurate and can tell you something about the performance of your code. - -**Async Forms** - these include the 'easy' forms (EasyProgressMeter and EasyPrint/Print). If you start overlapping having Async forms open with normal forms then things get a littler squirrelly. Still tracking down the issues and am making it more solid every day possible. You'll know there's an issue when you see blank form. - -**EasyPrint** - EasyPrint is a new feature that's pretty awesome. You print and the output goes to a window, with a scroll bar, that you can copy and paste from. Being a new feature, it's got some potential problems. There are known interaction problems with other GUI windows. For example, closing a Print window can also close other windows you have open. For now, don't close your debug print window until other windows are closed too. - -## Contributing - -A MikeTheWatchGuy production... entirely responsible for this code.... unless it causes you trouble in which case I'm not at all responsible. - -## Versions -|Version | Description | -|--|--| -| 1.0.9 | July 10, 2018 - Initial Release | -| 1.0.21 | July 13, 2018 - Readme updates | -| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case -| 2.1.1 | July 18, 2018 - Global settings exposed, fixes -| 2.2.0| July 20, 2018 - Image Elements, Print output -| 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. -| 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi -| 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. -| 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ -| 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting - - -### Release Notes -2.3 - Sliders, Listbox's and Image elements (oh my!) - -If using Progress Meters, avoid cancelling them when you have another window open. It could lead to future windows being blank. It's being worked on. - -New debug printing capability. `sg.Print` - -2.5 Discovered issue with scroll bar on `Output` elements. The bar will match size of ROW not the size of the element. Normally you never notice this due to where on a form the `Output` element goes. - -Listboxes are still without scrollwheels. The mouse can drag to see more items. The mouse scrollwheel will also scroll the list and will `page up` and `page down` keys. - -2.7 Is the "feature complete" release. Pretty much all features are done and in the code - - -### Upcoming -Make suggestions people! Future release features - -Columns. How multiple columns would be specified in the SDK interface are still being designed. - -Port to other graphic engines. Hook up the front-end interface to a backend other than tkinter. Qt, WxPython, etc. - - - -## Code Condition - - Make it run - Make it right - Make it fast - -It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor for PEP 8 compliance. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. - -While the internals to PySimpleGUI are a tad sketchy, the public interfaces into the SDK are more strictly defined and comply with PEP 8 for the most part. - -Please log bugs and suggestions in the GitHub! It will only make the code stronger and better in the end, a good thing for us all, right? - -## Design - -A moment about the design-spirit of `PySimpleGUI`. From the beginning, this package was meant to take advantage of Python's capabilities with the goal of programming ease. - -**Single File** -While not the best programming practice, the implementation resulted in a single file solution. Only one file is needed, PySimpleGUI.py. You can post this file, email it, and easily import it using one statement. - -**Functions as objects** -In Python, functions behave just like object. When you're placing a Text Element into your form, you may be sometimes calling a function and other times declaring an object. If you use the word Text, then you're getting an object. If you're using `Txt`, then you're calling a function that returns a `Text` object. - -**Lists** -It seemed quite natural to use Python's powerful list constructs when possible. The form is specified as a series of lists. Each "row" of the GUI is represented as a list of Elements. When the form read returns the results to the user, all of the results are presented as a single list. This makes reading a form's values super-simple to do in a single line of Python code. - - -## Authors -MikeTheWatchGuy - -## License - -GNU Lesser General Public License (LGPL 3) + - -## Acknowledgments - -* Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence -* [Fredrik Lundh](https://wiki.python.org/moin/FredrikLundh) for his work on `tkinter` - - -## How Do I -Finally, I must thank the fine folks at How Do I. -https://github.com/gleitz/howdoi -Their utility has forever changed the way and pace in which I can program. I urge you to try the HowDoI.py application here on GitHub. Trust me, **it's going to be worth the effort!** -Here are the steps to run that application - - Install howdoi: - pip install howdoi - Test your install: - python -m howdoi howdoi.py - To run it: - Python HowDoI.py - -The pip command is all there is to the setup. - -The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. -For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. -![snap0109](https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg) - -In the hands of a competent programmer, this tool is **amazing**. It's a must-try kind of program that has completely changed my programming process. I'm not afraid of asking for help! You just have to be smart about using what you find. - -The PySimpleGUI window that the results are shown in is an 'input' field which means you can copy and paste the results right into your code. \ No newline at end of file From 7d17007418c67b29534eedef50362208a55d70dd Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 3 Aug 2018 19:03:11 -0400 Subject: [PATCH 102/209] Readme --- docs/readme.md | 1506 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1506 insertions(+) create mode 100644 docs/readme.md diff --git a/docs/readme.md b/docs/readme.md new file mode 100644 index 000000000..f03d65375 --- /dev/null +++ b/docs/readme.md @@ -0,0 +1,1506 @@ + + +![pysimplegui_logo](https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png) + +[![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 +# PySimpleGUI + (Ver 2.7) + +Super-simple GUI to grasp... Powerfully customizable. + +Note - *Python3* is required to run PySimpleGUI. It takes advantage of some Python3 features that do not translate well into Python2. + +Looking to take your Python code from the world of command lines and into the convenience of a GUI? Have a Raspberry Pi with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK? Look no further, you've found your GUI package. + + import PySimpleGUI as sg + + sg.MsgBox('Hello From PySimpleGUI!', 'This is the shortest GUI program ever!') + + +![snap0136](https://user-images.githubusercontent.com/13696193/43162494-33095ece-8f59-11e8-86de-b6d8bcc5a52f.jpg) + + Build beautiful customized forms that fit your specific problem. Let PySimpleGUI solve your GUI problem while you solve the real problems. Do you really want to plod through the mountains of code required to program tkinter? + +![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) + +Perhaps you're looking for a way to interact with your Raspberry Pi in a more friendly way. The is the same form as above, except shown on a Pi. + +![raspberry pi](https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg) + + +In addition to a primary GUI, you can add a Progress Meter to your code with ONE LINE of code. Slide this into any of your `for` loops and get a nice meter like this: + + EasyProgressMeter('My meter title', current_value, max value) + + ![snap0177](https://user-images.githubusercontent.com/13696193/43658025-947973d2-9725-11e8-902f-e2d5effb6e3e.jpg) + +You can build an async media player GUI with custom buttons in 30 lines of code. + +![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) + +I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? + +There are a number of 'easy to use' Python GUIs, but they're **very** limiting. PySimpleGUI takes the best of packages like `EasyGUI`and `WxSimpleGUI` , both really handy but limited. The primary difference between these and PySimpleGUI is that in addition to getting the simple Message Boxes you also get the ability to make your own forms that are highly customizeable. Don't like the standard Message Box? Then make your own! + +Every call has optional parameters so that you can change the look and feel. Don't like the button color? It's easy to change by adding a button_color parameter to your widget. + +GUI Packages with more functionality, like QT and WxPython, require configuring and can take a ***week*** to get *reasonably familiar* with the interfaces. Clearly there needs to be a middle ground between forms with 1 or two input fields and a full-blown GUI. You'll be making your own custom forms with PySimpleGUI within minutes, even Async forms. + +With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. + +The `PySimpleGUI` package is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? + + Features of PySimpleGUI include: + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Realtime + Checkboxes + Radio Buttons + Listbox + Slider + Icons + Multi-line Text Input + Scroll-able Output + Images + Progress Bar + Async/Non-Blocking Windows + Tabbed forms + Persistent Windows + Redirect Python Output/Errors to scrolling window + 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + Single-Line-Of-Coide Proress Bar & Debug Print + Complete control of colors, look and feel + Button images + + +An example of many widgets used on a single form. A little further down you'll find the TWENTY lines of code required to create this complex form. Try it if you don't believe it. Start Python, copy and paste the code below into the >>> prompt and hit enter. This will pop up... + +![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) + +Here is the code that produced the above screenshot. + + import PySimpleGUI as sg + + with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText()], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [sg.Text('_' * 100, size=(70, 1))], + [sg.Text('Choose Source and Destination Folders', size=(35, 1))], + [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], + [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), + sg.FolderBrowse()], + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + + **A note on screen shots** +You will see a number of different styles of buttons, data entry fields, etc, in this readme. They were all made with the same SDK, the only difference is in the settings that are specified on a per-element, row, form, or global basis. One setting in particular, border_width, can make a big difference on the look of the form. Some of the screenshots had a border_width of 6, others a value of 1. + + +--- +### Design Goals +> Copy, Paste, Run. + +`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the code to visually match what's on the screen. + + > Be Pythonic + + Be Pythonic... Attempted to use language constructs in a natural way and to exploit some of Python's interesting features. Python's lists and optional parameters make PySimpleGUI work. + - Forms are represented as Python lists. + - A form is a list of rows + - A row is a list of elements +- Return values are a list of button presses and input values. + +It's stunning that after so many years Python still hasn't put forth a GUI framework that truly fits the language's basic data structures, especially lists. It's hard to argue with the success to be had in quickly building GUI applications using this package's syntax. + + ----- +## Getting Started with PySimpleGUI + +### Installing + + pip install PySimpleGUI + or +Simply download the file - PySimpleGUI.py and import it into your code + + +### Prerequisites + +Python 3 +tkinter + +Runs on all Python platforms that have tkinter running on them. Thoroughly tested on Windows. Runs on Windows, Mac, Linux, Raspberry Pi. Even runs on `pypy3`. + +### Using + +To use in your code, simply import.... + `import PySimpleGUI as sg` + +Then use either "high level" API calls or build your own forms. + + sg.MsgBox('This is my first message box') + +![snap0178](https://user-images.githubusercontent.com/13696193/43658024-945c83f8-9725-11e8-8ddd-0bbe67a9fc5d.jpg) + + +Yes, it's just that easy to have a window appear on the screen using Python. With PySimpleGUI, making a custom form appear isn't much more difficult. The goal is to get you running on your GUI within ***minutes***, not hours nor days. + +--- +## APIs + +PySimpleGUI can be broken down into 2 types of API's: + * High Level single call functions + * Custom form functions + + +### Python Language Features + + There are a couple of Python language features that PySimpleGUI utilizes heavily that should be understood first... + * Variable number of arguments to a function call + * Optional parameters to a function call + +#### Variable Number of Arguments + + The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. + + sg.MsgBox('Variable number of parameters example', var1, var2, "etc") + +Each new item begins on a new line in the Message Box + + ![snap0179](https://user-images.githubusercontent.com/13696193/43658129-f6ca49c6-9725-11e8-9317-1f77443eb04a.jpg) + + + +#### Optional Parameters to a Function Call + +This feature of the Python language is utilized ***heavily*** as a method of customizing forms and form Elements. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. + +Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't *have* to be specified on each and every call. + + def MsgBox(*args, + button_color=None, + button_type=MSG_BOX_OK, + auto_close=False, + auto_close_duration=None, + icon=DEFAULT_WINDOW_ICON, + line_width=MESSAGE_BOX_LINE_WIDTH, + font=None): + +If the caller wanted to change the button color to be black on yellow, the call would look something like this: + + sg.MsgBox('This box has a custom button color', button_color=('black', 'yellow')) + + +![snap0180](https://user-images.githubusercontent.com/13696193/43658171-13a72bfe-9726-11e8-8c7a-0a46e46fb202.jpg) + + +--- + +### High Level API Calls + +The classic "input a value, print result" example. +Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. +This code prompts user to input a line of text and then displays that text in a messages box: + + + import PySimpleGUI as sg + + rc = sg.GetTextBox('Title', 'Please input something') + sg.MsgBox('Results', 'The value returned from GetTextBox', rc) + + + ![snap0181](https://user-images.githubusercontent.com/13696193/43658233-48cc7794-9726-11e8-8582-8844280c344e.jpg) + +![snap0182](https://user-images.githubusercontent.com/13696193/43658232-48aaad4e-9726-11e8-95f5-aa9b9213bb77.jpg) + + +#### Message Boxes +In addition to MsgBox, you'll find a several API calls that are shortcuts to common messages boxes. You can achieve similar results by calling MsgBox with the correct parameters. + +The differences tend to be the number and types of buttons. Here are the calls and the windows that are created. + + import PySimpleGUI as sg + + `sg.MsgBoxOK('This is an OK MsgBox')` + + ![ok](https://user-images.githubusercontent.com/13696193/43667331-723ac666-9745-11e8-8666-230c35a6afd6.jpg) + + + sg.MsgBoxOKCancel('This is an OK Cancel MsgBox') + +![ok cancel 2](https://user-images.githubusercontent.com/13696193/43667330-71d5bea6-9745-11e8-8944-b3900853aa62.jpg) + + sg.MsgBoxCancel('This is a Cancel MsgBox') + +![cancel](https://user-images.githubusercontent.com/13696193/43667329-71a007de-9745-11e8-974b-d028f68798e7.jpg) + + sg.MsgBoxYesNo('This is a Yes No MsgBox') + +![yesno](https://user-images.githubusercontent.com/13696193/43667327-717ff7dc-9745-11e8-9dce-52c305a85101.jpg) + + + sg.MsgBoxError('This is an error MsgBox') + +![error msgbox](https://user-images.githubusercontent.com/13696193/43667326-71621712-9745-11e8-87c4-56e2ab500f8e.jpg) + + sg.MsgBoxAutoClose('This is an autoclose MsgBox') + +![autoclose](https://user-images.githubusercontent.com/13696193/43667325-714997dc-9745-11e8-836a-7185dc80329f.jpg) + + sg.ScrolledTextBox(my_text, height=10) + +![scrolledtextbox 2](https://user-images.githubusercontent.com/13696193/43667324-712aa0d4-9745-11e8-83a9-a0d0570d0865.jpg) + + +Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing your printed text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. Your code could contain a line like: + + sprint(f'My variables values include x={x}', f'y={y}') + +This becomes a debug print of sorts that will route to a scrolled window. + +See also the `EasyPrint` and `Print` functions. + +#### High Level User Input + +There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. If you need only 1 value, then perhaps one of these high level functions will work. + - GetTextBox + - GetFileBox + - GetFolderBox + + `submit_clicked, value = sg.GetTextBox('Title', 'Please enter anything')` + +![gettextbox 2](https://user-images.githubusercontent.com/13696193/43667510-355b23a2-9746-11e8-9f1e-91c0dd0f4ed8.jpg) + + submit_clicked, value = sg.GetFileBox('Title', 'Choose a file') + +![getfilebox 2](https://user-images.githubusercontent.com/13696193/43667535-5821fc94-9746-11e8-95c3-82395099e994.jpg) + + submit_clicked, value = sg.GetPathBox('Title', 'Choose a folder') + +![getpathbox](https://user-images.githubusercontent.com/13696193/43667556-79874c22-9746-11e8-80f2-8262d32802c2.jpg) + + +#### Progress Meter! +We all have loops in our code. 'Isn't it joyful waiting, watching a counter scrolling past in a text window? How about one line of code to get a progress meter, that contains statistics about your code? + + + EasyProgressMeter(title, + current_value, + max_value, + *args, + orientation=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): + +Here's the one-line Progress Meter in action! + + for i in range(1,10000): + sg.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') + +That line of code resulted in this window popping up and updating. + +![preogress meter](https://user-images.githubusercontent.com/13696193/43667625-d47da702-9746-11e8-91e6-e5177883abae.jpg) + +A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. +With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. + +***Be sure and add one to your loop counter*** so that your counter goes from 1 to the max value. If you do not add one, your counter will never hit the max value. Instead it will go from 0 to max-1. + +#### Debug Output +Another call in the 'Easy' families of APIs is `EasyPrint`. It will output to a debug window. If the debug window isn't open, then the first call will open it. No need to do anything but stick a 'print' call in your code. You can even replace your 'print' calls with calls to EasyPrint by simply sticking the statement + + print = sg.EasyPrint + +at the top of your code. +There are a number of names for the same EasyPrint function. `Print` is one of the better ones to use as it's easy to remember. It is simply `print` with a capital P. + + import PySimpleGUI as sg + + for i in range(100): + sg.Print(i) + +![snap0125](https://user-images.githubusercontent.com/13696193/43114979-a696189e-8ecf-11e8-83c7-473fcf0ccc66.jpg) +Or if you didn't want to change your code: + + import PySimpleGUI as sg + + print=sg.Print + for i in range(100): + print(i) + +Just like the standard print call, `EasyPrint` supports the `sep` and `end` keyword arguments. Other names that can be used to call `EasyPrint` include Print, `eprint`, If you want to close the window, call the function `EasyPrintClose`. + +A word of caution. There are known problems when multiple PySimpleGUI windows are opened, particularly if the user closes them in an unusual way. Not a reason to stay away from using it. Just something to keep in mind if you encounter a problem. + +You can change the size of the debug window using the `SetOptions` call with the `debug_win_size` parameter. + +--- +# Custom Form API Calls (Your First Form) + +This is the FUN part of the programming of this GUI. In order to really get the most out of the API, you should be using an IDE that supports auto complete or will show you the definition of the function. This will make customizing go smoother. + +This first section on custom forms is for your typical, blocking, non-persistant form. By this I mean, when you "show" the form, the function will not return until the user has clicked a button or closed the window. When this happens, the form's window will be automatically closed. + +Two other types of forms exist. +1. Persistent form - rather than closing on button clicks, the show form function returns and the form continues to be visible. This is good for applications like a chat window. +2. Asynchronous form - the trickiest of the lot. Great care must be exercised. Examples are an MP3 player or status dashboard. Async forms are updated (refreshed) on a periodic basis. + +It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. Let's start with a basic Browse for a file and do something with it. +# Copy these design patterns! +## Pattern 1 - With Context Manager + + + with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: + form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], + [sg.InputText(), sg.FileBrowse()], + [sg.Submit(), sg.Cancel()]] + button, (source_filename,) = form.LayoutAndRead(form_rows) + +## Pattern 2 - No Context Manager + + + form = sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) + form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], + [sg.InputText(), sg.FileBrowse()], + [sg.Submit(), sg.Cancel()]] + button, (source_filename,) = form.LayoutAndRead(form_rows) + + + +These 2 design patters both produce this custom form: + +![snap0134](https://user-images.githubusercontent.com/13696193/43162410-e7775466-8f58-11e8-8d6a-da4772c00dd8.jpg) + +It's important to use the "with" context manager so that resources are freed as quickly as possible, using the currently executing thread. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. + +The second design pattern is not context manager based. If you are struggling with an unknown error, try modifying the code to run without a context manager. To do so, you simple remove the with, stick the form on the front of that statement, and un-indent the with-block code. + +You will use these design patterns or code templates for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. This is the most basic / normal of the design patterns. + +### How GUI Programming in Python Should Look + +GUI programming in Python is a mess. tkinter kinda sucks. Why is Python such a great teaching language and yet no GUI framework exists that lends itself to the basic building blocks of Python, the list? + +The key to custom forms in PySimpleGUI is to view forms as ROWS of Widgets (Elements). Each row is specified as a list of these widgets. Put the rows together and you've got a form. + +Let's look at this one. + + +![snap0131](https://user-images.githubusercontent.com/13696193/43417007-df6d8408-9407-11e8-9986-30f0415f08a5.jpg) + +Let's agree the form has 4 rows. + +The first row only has **text** that reads `Rename files or folders` + +The second row has 3 elements in it. First the **text** `Source for Folders`, then an **input** field, then a **browse** button. + +Now let's look at how those 2 rows and the other two row from Python code: + + layout = [[sg.Text('Rename files or folders')], + [sg.Text('Source for Folders', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], + [sg.Text('Source for Files ', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], + [sg.Submit(), sg.Cancel()]] + +See how the source code mirrors the layout? You simply make lists for each row, then submit that table to PySimpleGUI to show and get values from. + +And what about those return values? Most people simply want to show a form, get the input values and do something with them. So why break up the code into button callbacks, etc, when I simply want my form's input values to be given to me. + +The same "row" concept applies to return values. The form is scanned from top to bottom, left to right. Each field that's an input field will occupy a spot in the return values. + +In our example form, there are 2 fields, so the return values from this form will be a list with 2 values in it. + + button, (folder_path, file_path) = form.LayoutAndRead(layout) + +In the statement that shows and reads the form, the two input fields are directly assigned to the caller's variables `folder_path` and `file_path`, ready to use. No parsing no callbacks. + +Isn't this what almost every Python programmer looking for a GUI wants?? Something easy to work with to get the values and move on to the rest of the program, where the real action is taking place. Why write pages of tkinter code when the same layout can be achieved with PySimpleGUI in 3 or 4 lines of code. 4 lines or 40? I chose 4. + + +### Laying out your form +Your form is a 2 dimensional list in Python. The first dimension are rows, the second is a list of Elements for each row. The first thing you want to do is layout your form on paper. + + layout = [ [row 1], + [row 2], + [row 3] ] + +Simple enough... a list of lists. +A row is a list of Elements. For example this could be a row with a couple of elements on it. + + [ Input, Button] + +Turning back to our example. This GUI roughly looks like this: + + layout = [ [Text], + [InputText, FileBrowse] + [Submit, Cancel] ] + + Now let's put it all together into an entire program. + + +### Line by line explanation + +Going through each line of code in the above form will help explain how to use this design patter. Copy, modify and run it! + + with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: +This creates a new form, storing it in the variable `form`. + + form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], +The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. + + [sg.InputText(), sg.FileBrowse()], +Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. + + [sg.Submit(), sg.Cancel()]] + +The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its value to the caller. + + button, (source_filename, ) = form.LayoutAndRead(form_rows) +This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field. The result of the form is stored directly into the variable we wish to work with. + + +## Return values + + Return information from FlexForm, SG's primary form builder interface, is in this format: + + button, (value1, value2, ...) + +Each of the Elements that are Input Elements will have a value in the list of return values. You can unpack your GUI directly into the variables you want to use. + + button, (filename, folder1, folder2, should_overwrite) = form.LayoutAndRead(form_rows) + + Or, you can unpack the return results separately. + + button, values = form.LayoutAndRead(form_rows) + filename, folder1, folder2, should_overwrite = values + +If you have a SINGLE value being returned, it is written this way: + + button, (value1,) = form.LayoutAndRead(form_rows) + + + Another way of parsing the return values is to store the list of values into a variable representing the list of values. + + button, value_list = form.LayoutAndRead(form_rows) + value1 = value_list[0] + value2 = value_list[1] + ... + +--- +## All Widgets / Elements +This code utilizes as many of the elements in one form as possible. + + with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText()], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [sg.Text('_' * 100, size=(70, 1))], + [sg.Text('Choose Source and Destination Folders', size=(35, 1))], + [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], + [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), + sg.FolderBrowse()], + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + +This is a somewhat complex form with quite a bit of custom sizing to make things line up well. This is code you only have to write once. When looking at the code, remember that what you're seeing is a list of lists. Each row contains a list of Graphical Elements that are used to create the form. + +![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) + +Clicking the Submit button caused the form call to return. The call to MsgBox resulted in this dialog box. +![results 2](https://user-images.githubusercontent.com/13696193/43097502-44e3ed32-8e8a-11e8-9a51-2b8af0b1a682.jpg) + + +**`Note, button value can be None`**. The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. + +You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. + +--- +# Building Custom Forms +You will find it much easier to write code using PySimpleGUI if you use an IDE such as PyCharm. The features that show you documentation about the API call you are making will help you determine which settings you want to change, if any. In PyCharm, two commands are particularly helpful. + + Control-Q (when cursor is on function name) brings up a box with the function definition + Control-P (when cursor inside function call "()") shows a list of parameters and their default values + +## Synchronous Forms +The most common use of PySimpleGUI is to display and collect information from the user. The most straightforward way to do this is using a "blocking" GUI call. Execution is "blocked" while waiting for the user to close the GUI form/dialog box. +You've already seen a number of examples above that use blocking forms. Anytime you see a context manager used (see the `with` statement) it's most likely a blocking form. You can examine the show calls to be sure. If the form is a non-blocking form, it must indicate that in the call to `form.show`. + +NON-BLOCKING form call: + + form.Show(non_blocking=True) + +### Beginning a Form +The first step is to create the form object using the desired form customization. + + with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: + +This is the definition of the FlexForm object: + + def FlexForm(title, + default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), + auto_size_text=None, + auto_size_buttons=None, + scale=(None, None), + location=(None, None), + button_color=None,Font=None, + progress_bar_color=(None,None), + is_tabbed_form=False, + border_depth=None, + auto_close=False, + auto_close_duration=DEFAULT_AUTOCLOSE_TIME, + icon=DEFAULT_WINDOW_ICON): + +Parameter Descriptions. You will find these same parameters specified for each `Element` and some of them in `Row` specifications. The `Element` specified value will take precedence over the `Row` and `Form` values. + + default_element_size - Size of elements in form in characters (width, height) + auto_size_text - Bool. True if elements should size themselves according to contents + auto_size_buttons - Bool. True if button elements should size themselves according to their text label + scale - Set size of element to be a multiple of the Element size + location - Location to place window in pixels + button_color - Default color for buttons (foreground, background). Can be text or hex + progress_bar_color - Foreground and background colors for progress bars + is_tabbed_form - Bool. If True then form is a tabbed form + border_depth - Amount of 'bezel' to put on input boxes, buttons, etc. + auto_close - Bool. If True form will autoclose + auto_close_duration - Duration in seconds before form closes + icon - .ICO file that will appear on the Task Bar and end of Title Bar + + +#### Sizes +Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. + +The default Element size for PySimpleGUI is `(45,1)`. + +Sizes can be set at the element level, or in this case, the size variables apply to all elements in the form. Setting `size=(20,1)` in the form creation call will set all elements in the form to that size. + +In addition to `size` there is a `scale` option. `scale` will take the Element's size and scale it up or down depending on the scale value. `scale=(1,1)` doesn't change the Element's size. `scale=(2,1)` will set the Element's size to be twice as wide as the size setting. + +There are a couple of widgets where one of the size values is in pixels rather than characters. This is true for Progress Meters and Sliders. The second parameter is the 'height' in pixels. + +#### FlexForm - form-level variables overview +A summary of the variables that can be changed when a FlexForm is created + + default_element_size - set default size for all elements in the form + auto_size_text- true/false autosizing turned on / off + scale - set scale value for all elements + button_color- default button color (foreground, background) + font - font name and size for all text items + progress_bar_color - progress bar colors + is_tabbed_form - true/false indicates form is a tabbed or normal form + border_depth - style setting for buttons, input fields + auto_close - true/false indicates if form will automatically close + auto_close_duration - how long in seconds before closing form + icon - filename for icon that's displayed on the window on taskbar + + +## Elements +"Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. + + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Realtime + Checkboxes + Radio Buttons + Listbox + Slider + Multi-line Text Input + Scroll-able Output + Progress Bar + Async/Non-Blocking Windows + Tabbed forms + Persistent Windows + Redirect Python Output/Errors to scrolling Window + "Higher level" APIs (e.g. MessageBox, YesNobox, ...) + + +### Output Elements +Building a form is simply making lists of Elements. Each list is a row in the overall GUI dialog box. The definition looks something like this: + + layout = [ [row 1 element, row 1 element], + [row 2 element, row 2 element, row 2 element] ] +The code is a crude representation of the GUI, laid out in text. +#### Text Element + + layout = [[sg.Text('This is what a Text Element looks like')]] + + + ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) + + +The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. + + Text(Text, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None, + text_color=None, + justification=None) +. + + Text - The text that's displayed + size - Element's size + auto_size_text - Bool. Change width to match size of text + font - Font name and size to use + text_color - text color + justification - Justification for the text. String - 'left', 'right', 'center' + +Some commonly used elements have 'shorthand' versions of the functions to make the code more compact. The functions `T` and `Txt` are the same as calling `Text`. + +**Fonts** in PySimpleGUI are always in this format: + + (font_name, point_size) + +The default font setting is + + ("Helvetica", 10) + +**Color** in PySimpleGUI are always in this format: + + (foreground, background) + +The values foreground and background can be the color names or the hex value formatted as a string: + + "#RRGGBB" + +**auto_size_text** +A `True` value for `auto_size_text`, when placed on any Element, indicates that the width of the Element should be shrunk do the width of the text. This is particularly useful with `Buttons` as fixed-width buttons are somewhat crude looking. The default value is `False`. You will often see this setting on FlexForm definitions. + +**Shorthand functions** +The shorthand functions for `Text` are `Txt` and `T` + + +#### Multiline Text Element + + layout = [[sg.Multiline('This is what a Multi-line Text Element looks like', size=(45,5))]] +![multiline text](https://user-images.githubusercontent.com/13696193/42670464-0824c754-8629-11e8-9741-6ed08f924618.jpg) +This Element doubles as both an input and output Element. The `DefaultText` optional parameter is used to indicate what to output to the window. + + Multiline(default_text='', + enter_submits = False, + scale=(None, None), + size=(None, None), + auto_size_text=None) +. + + default_text - Text to display in the text box + enter_submits - Bool. If True, pressing Enter key submits form + scale - Element's scale + size - Element's size + auto_size_text - Bool. Change width to match size of text + +#### Output Element +Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. More on this later. + + form.AddRow(gg.Output(size=(100,20))) + +![output element](https://user-images.githubusercontent.com/13696193/42704820-5446959c-869f-11e8-849e-047ea280387a.jpg) + + Output(scale=(None, None), + size=(None, None)) +. + + scale - How much to scale size of element + size - Size of element (width, height) in characters + +### Input Elements + These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. + +#### Text Input Element + + layout = [[sg.InputText('Default text')]] +![inputtext](https://user-images.githubusercontent.com/13696193/42693515-610a716c-867d-11e8-9a00-7e7fcf771230.jpg) + + def InputText(default_text = '', + scale=(None, None), + size=(None, None), + auto_size_text=None, + password_char='') +. + + default_text - Text initially shown in the input box + scale - Amount size is scaled by + size - (width, height) of element in characters + auto_size_text- Bool. True is element should be sized to fit text + password_char - Character that will be used to replace each entered character. Setting to a value indicates this field is a password entry field + +Shorthand functions that are equivalent to `InputText` are `Input` and `In` + + +#### Combo Element +Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. + + layout = [[sg.InputCombo(['choice 1', 'choice 2'])]] + +![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) + + InputCombo(values, + scale=(None, None), + size=(None, None), + auto_size_text=None) +. + + values - Choices to be displayed. List of strings + scale - Amount to scale size by + size - (width, height) of element in characters + auto_size_text - Bool. True if size should fit the text length + +#### Listbox Element +The standard listbox like you'll find in most GUIs. Note that the return values from this element will be a ***list of results, not a single result***. This is because the user can select more than 1 item from the list (if you set the right mode). + + layout = [[sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6))]] + +![snap0130](https://user-images.githubusercontent.com/13696193/43115859-2fbf0646-8ed3-11e8-9979-bbee8eaebfab.jpg) + + + Listbox(values, + select_mode=None, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None) +. + + values - Choices to be displayed. List of strings + select_mode - Defines how to list is to operate. + Choices include constants or strings: + Constants version: + LISTBOX_SELECT_MODE_BROWSE + LISTBOX_SELECT_MODE_EXTENDED + LISTBOX_SELECT_MODE_MULTIPLE + LISTBOX_SELECT_MODE_SINGLE - the default + Strings version: + 'browse' + 'extended' + 'multiple' + 'single' + scale - Amount to scale size by + size - (width, height) of element in characters + auto_size_text - Bool. True if size should fit the text length + +The `select_mode` option can be a string or a constant value defined as a variable. Generally speaking strings are used for these kinds of options. + +#### Slider Element +Sliders have a couple of slider-specific settings as well as appearance settings. Examples include the `orientation` and `range` settings. + + layout = [[sg.Slider(range=(1,500), default_value=222, size=(20,15), orientation='horizontal', font=('Helvetica', 12))]] + +![snap0129](https://user-images.githubusercontent.com/13696193/43115741-e1cb52c8-8ed2-11e8-80bb-0e99ae846ec1.jpg) + + Slider(range=(None,None), + default_value=None, + orientation=None, + border_width=None, + relief=None, + scale=(None, None), + size=(None, None), + font=None): +. + + range - (min, max) slider's range + default_value - default setting (within range) + orientation - 'horizontal' or 'vertical' ('h' or 'v' work) + border_width - how deep the widget looks + relief - relief style. Values are same as progress meter relief values. Can be a constant or a string: + RELIEF_RAISED= 'raised' + RELIEF_SUNKEN= 'sunken' + RELIEF_FLAT= 'flat' + RELIEF_RIDGE= 'ridge' + RELIEF_GROOVE= 'groove' + RELIEF_SOLID = 'solid' + scale - Amount to scale size by + size - (width, height) of element in characters + auto_size_text - Bool. True if size should fit the text + +#### Radio Button Element +Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. + + layout = [[sg.Radio('My first Radio!', "RADIO1", default=True), sg.Radio('My second radio!', "RADIO1")]] + +![radio element](https://user-images.githubusercontent.com/13696193/42705705-327b4b6c-86a2-11e8-81a7-740e57646ba8.jpg) + + Radio(text, + group_id, + default=False, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None) + +. + + text - Text to display next to button + group_id - Groups together multiple Radio Buttons. Can be any value + default - Bool. Initial state + scale - Amount to scale size of element + size- (width, height) size of element in characters + auto_size_text - Bool. True if should size width to fit text + font - Font type and size for text display + + +#### Checkbox Element +Checkbox elements are like Radio Button elements. They return a bool indicating whether or not they are checked. + + layout = [[sg.Checkbox('My first Checkbox!', default=True), sg.Checkbox('My second Checkbox!')]] + +![checkbox element](https://user-images.githubusercontent.com/13696193/42717015-655d73d2-86cc-11e8-9c69-3c810f48e578.jpg) + + + Checkbox(text, + default=False, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None): +. + + text - Text to display next to checkbox + default- Bool. Initial state + scale - Amount to scale size of element + size - (width, height) size of element in characters + auto_size_text- Bool. True if should size width to fit text + font- Font type and size for text display + + +#### Spin Element +An up/down spinner control. The valid values are passed in as a list. + + layout = [[sg.Spin([i for i in range(1,11)], initial_value=1), sg.Text('Volume level')]] + +![spin element](https://user-images.githubusercontent.com/13696193/42717231-8ddb51d4-86cd-11e8-827a-75f2237477fa.jpg) + + Spin(values, + intiial_value=None, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None) +. + + values - List of valid values + initial_value - String with initial value + scale - Amount to scale size of element + size - (width, height) size of element in characters + auto_size_text - Bool. True if should size width to fit text + font - Font type and size for text display + +#### Button Element +Buttons are the most important element of all! They cause the majority of the action to happen. After all, it's a button press that will get you out of a form, whether it but Submit or Cancel, one way or another a button is involved in all forms. The only exception is to this is when the user closes the window using the "X" in the upper corner which means no button was involved. + +The Types of buttons include: +* Folder Browse +* File Browse +* Close Form +* Read Form +* Realtime + + + Close Form - Normal buttons like Submit, Cancel, Yes, No, etc, are "Close Form" buttons. They cause the input values to be read and then the form is closed, returning the values to the caller. + +Folder Browse - When clicked a folder browse dialog box is opened. The results of the Folder Browse dialog box are written into one of the input fields of the form. + +File Browse - Same as the Folder Browse except rather than choosing a folder, a single file is chosen. + +Read Form - This is an async form button that will read a snapshot of all of the input fields, but does not close the form after it's clicked. + +Realtime - This is another async form button. Normal button clicks occur after a button's click is released. Realtime buttons report a click the entire time the button is held down. + +While it's possible to build forms using the Button Element directly, you should never need to do that. There are pre-made buttons and shortcuts that will make life much easier. The most basic Button element call to use is `SimpleButton` + + SimpleButton(text, + scale=(None, None), + size=(None, None), + auto_size_button=None, + button_color=None, + font=None) + +Pre-made buttons include: + + OK + Ok + Submit + Cancel + Yes + No + FileBrowse + FolderBrowse +. + layout = [[sg.OK(), sg.Cancel()]] + +![ok cancel](https://user-images.githubusercontent.com/13696193/42717733-1803f584-86d1-11e8-9223-36b782971b9f.jpg) + +The FileBrowse and FolderBrowse buttons both fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. + +The default value for `Target` is `(ThisRow, -1)`. ThisRow is a special value that tells the GUI to use the same row as the button. The Y-value of -1 means the field one value to the left of the button. For a File or Folder Browse button, the field that it fills are generally to the left of the button is most cases. + +Let's examine this form as an example: + +![button target example](https://user-images.githubusercontent.com/13696193/42718075-b4dcb61e-86d3-11e8-904c-d709dd364108.jpg) + +The `InputText` element is located at (1,0)... row 1, column 0. The `Browse` button is located at position (2,0). The Target for the button could be any of these values: + + Target = (1,0) + Target = (-1,0) +The code for the entire form could be: + + layout = [[sg.T('Source Folder')], + [sg.In()], + [sg.FolderBrowse(Target=(-1,0)), sg.OK()]] + +**Custom Buttons** +Not all buttons are created equal. A button that closes a form is different that a button that returns from the form without closing it. If you want to define your own button, you will generally do this with the Button Element `SimpleButton`, which closes the form when clicked. + +layout = [[sg.SimpleButton('My Button')]] + +![singlebutton](https://user-images.githubusercontent.com/13696193/42718281-9453deca-86d5-11e8-83c7-4b6d33720858.jpg) + +All buttons can have their text changed by changing the `button_text` variable in the button call. It is this text that is returned when a form is read. This text will be what tells you which button is called so make it unique. Most of the convenience buttons (Submit, Cancel, Yes, etc) are all SimpleButtons. The two that are not are `FileBrowse` and `FolderBrowse`. They clearly do not close the form. Instead they bring up a file or folder browser dialog box. + +**Button Images** +Now this is an exciting feature not found in many simplified packages.... images on buttons! You can make a pretty spiffy user interface with the help of a few button images. + +Your button images need to be in PNG or GIF format. When you make a button with an image, set the button background to the same color as the background. There's a button color TRANSPARENT_BUTTON that you can set your button color to in order for it to blend into the background. Note that this value is currently the same as the color as the default system background on Windows. + +This example comes from the `Demo Media Player.py` example program. Because it's a non-blocking button, it's defined as `ReadFormButton`. You also put images on blocking buttons by using `SimpleButton`. + + + sg.ReadFormButton('Restart Song', button_color=sg.TRANSPARENT_BUTTON, + image_filename=image_restart, image_size=(50, 50), image_subsample=2, border_width=0) + +Three parameters are used for button images. + + image_filename - Filename. Can be a relative path + image_size - Size of image file in pixels + image_subsample - Amount to divide the size by. 2 means your image will be 1/2 the size. 3 means 1/3 + +Here's an example form made with button images. + +![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) + +You'll find the source code in the file Demo Media Player. Here is what the button calls look like to create media player form + + sg.ReadFormButton('Pause', button_color=sg.TRANSPARENT_BUTTON, + image_filename=image_pause, image_size=(50, 50), image_subsample=2, border_width=0) + +This is one you'll have to experiment with at this point. Not up for an exhaustive explanation. + + **Realtime Buttons** + + Normally buttons are considered "clicked" when the mouse button is let UP after a downward click on the button. What about times when you need to read the raw up/down button values. A classic example for this is a robotic remote control. Building a remote control using a GUI is easy enough. One button for each of the directions is a start. Perhaps something like this: + +![snap0135](https://user-images.githubusercontent.com/13696193/43440841-bcf8d184-9466-11e8-9f7b-30a1d5ce32d3.jpg) + +This form has 2 button types. There's the normal "Simple Button" (Quit) and 4 "Realtime Buttons". + +Here is the code to make, show and get results from this form: + + form = sg.FlexForm('Robotics Remote Control', auto_size_text=True) + + form_rows = [[sg.Text('Robotics Remote Control')], + [sg.T(' '*10), sg.RealtimeButton('Forward')], + [ sg.RealtimeButton('Left'), sg.T(' '*15), sg.RealtimeButton('Right')], + [sg.T(' '*10), sg.RealtimeButton('Reverse')], + [sg.T('')], + [sg.Quit(button_color=('black', 'orange'))] + ] + + form.LayoutAndRead(form_rows, non_blocking=True) + +Somewhere later in your code will be your main event loop. This is where you do your polling of devices, do input/output, etc. It's here that you will read your form's buttons. + + while (True): + # This is the code that reads and updates your window + button, values = form.ReadNonBlocking() + if button is not None: + sg.Print(button) + if button == 'Quit' or values is None: + break + time.sleep(.01) + +This loop will read button values and print them. When one of the Realtime buttons is clicked, the call to `form.ReadNonBlocking` will return a button name matching the name on the button that was depressed. It will continue to return values as long as the button remains depressed. Once released, the ReadNonBlocking will return None for buttons ules anutton was clicked. + +**File Types** +The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is + + FileTypes=(("ALL Files", "*.*"),) + +This code produces a form where the Browse button only shows files of type .TXT + + layout = [[sg.In() ,sg.FileBrowse(file_types=(("Text Files", "*.txt"),))]] + + ***The ENTER key*** + The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. + + --- +#### ProgressBar +The `ProgressBar` element is used to build custom Progress Bar forms. It is HIGHLY recommended that you use the functions that provide a complete progress meter solution for you. Progress Meters are not easy to work with because the forms have to be non-blocking and they are tricky to debug. + +The **easiest** way to get progress meters into your code is to use the `EasyProgessMeter` API. This consists of a pair of functions, `EasyProgessMeter` and `EasyProgressMeterCancel`. You can easily cancel any progress meter by calling it with the current value = max value. This will mark the meter as expired and close the window. +You've already seen EasyProgressMeter calls presented earlier in this readme. + + sg.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') + +The return value for `EasyProgressMeter` is: +`True` if meter updated correctly +`False` if user clicked the Cancel button, closed the form, or vale reached the max value. +**Customized Progress Bar** +If you want a bit more customization of your meter, then you can go up 1 level and use the calls to `ProgressMeter` and `ProgressMeterUpdate`. These APIs behave like an object we're all used to. First you create the `ProgressMeter` object, then you call the `Update` method to update it. + +You setup the progress meter by calling + + my_meter = ProgressMeter(title, + max_value, + *args, + orientantion=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) +Then to update the bar within your loop + + return_code = ProgressMeterUpdate(my_meter, + value, + *args): +Putting it all together you get this design pattern + + my_meter = sg.ProgressMeter('Meter Title', 100000, orentation='Vert') + + for i in range(0, 100000): + sg.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') + + +The final way of using a Progress Meter with PySimpleGUI is to build a custom form with a `ProgressBar` Element in the form. You will need to run your form as a non-blocking form. When you are ready to update your progress bar, you call the `UpdateBar` method for the `ProgressBar` element itself. + + +#### Output +The Output Element is a re-direction of Stdout. Anything "printed" will be displayed in this element. + + Output(scale=(None, None), + size=(None, None)) + +Here's a complete solution for a chat-window using an Async form with an Output Element + + import PySimpleGUI as sg + # Blocking form that doesn't close + def ChatBot(): + with sg.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + layout = [[(sg.Text('This is where standard out is being routed', size=[40, 1]))], + [sg.Output(size=(80, 20))], + [sg.Multiline(size=(70, 5), enter_submits=True), sg.ReadFormButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0])), sg.SimpleButton('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]] + # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form + # if you call LayoutAndRead from here, then you will miss the first button click + form.Layout(layout) + # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # + while True: + button, value = form.Read() + if button == 'SEND': + print(value) + else: + break + + +## Tabbed Forms +Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format + + results = ShowTabbedForm('Title for the form', + (form,layout,'Tab 1 label'), + (form2,layout2, 'Tab 2 label'), ...) + +Each of the tabs of the form is in fact a form. The same steps are taken to create the form as before. A `FlexForm` is created, then rows are filled with Elements, and finally the form is shown. When calling `ShowTabbedForm`, each form is passed in as a tuple. The tuple has the format: `(the form, the rows, a string shown on the tab)` + +Results are returned as a list of lists. For each form you'll get a list that's in the same format as a normal form. A single tab's values would be: + + (button, (values)) + +Recall that values is a list as well. Multiple tabs in the form would return like this: + + ((button1, (values1)), (button2, (values2)) + + ## Colors ## +Starting in version 2.5 you can change the background colors for the window and the Elements. + +Your forms can go from this: +![snap0155](https://user-images.githubusercontent.com/13696193/43273879-a9fdc10a-90cb-11e8-8c20-4f6a244ebe2f.jpg) + + +to this... with one function call... + +![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) + + + +While you can do it on an element by element or form level basis, the easiest way, by far, is a call to `SetOptions`. + +Be aware that once you change these options they are changed for the rest of your program's execution. All of your forms will have that look and feel, until you change it to something else (which could be the system default colors. + +This call sets all of the different color options. + + SetOptions(background_color='#9FB8AD', + text_element_background_color='#9FB8AD', + element_background_color='#9FB8AD', + scrollbar_color=None, + input_elements_background_color='#F7F3EC', + progress_meter_color = ('green', 'blue') + button_color=('white','#475841')) + + + +## Global Settings +**Global Settings** +Let's have some fun customizing! Make PySimpleGUI look the way you want it to look. You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. + + SetOptions(icon=None + button_color=(None,None) + element_size=(None,None), + margins=(None,None), + element_padding=(None,None) + auto_size_text=None + auto_size_buttons=None + font=None + border_width=None + slider_border_width=None + slider_relief=None + slider_orientation=None + autoclose_time=None + message_box_line_width=None + progress_meter_border_depth=None + progress_meter_style=None + progress_meter_relief=None + progress_meter_color=None + progress_meter_size=None + text_justification=None + background_color=None + element_background_color=None + text_element_background_color=None + input_elements_background_color=None + scrollbar_color=None, text_color=None + debug_win_size=(None,None) + window_location=(None,None) + +Explanation of parameters + + icon - filename of icon used for taskbar and title bar + button_color - button color (foreground, background) + element_size - element size (width, height) in characters + margins - tkinter margins around outsize + element_padding - tkinter padding around each element + auto_size_text - autosize the elements to fit their text + auto_size_buttons - autosize the buttons to fit their text + font - font used for elements + border_width - amount of bezel or border around sunken or raised elements + slider_border_width - changes the way sliders look + slider_relief - changes the way sliders look + slider_orientation - changes orientation of slider + autoclose_time - time in seconds for autoclose boxes + message_box_line_width - number of characers in a line of text in message boxes + progress_meter_border_depth - amount of border around raised or lowered progress meters + progress_meter_style - style of progress meter as defined by tkinter + progress_meter_relief - relief style + progress_meter_color - color of the bar and background of progress meters + progress_meter_size - size in (characters, pixels) + background_color - Color of the main window's background + element_background_color - Background color of the elements + text_element_background_color - Text element background color + input_elements_background_color - Input fields background color + scrollbar_color - Color for scrollbars (may not always work) + text_color - Text element default text color + text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' + debug_win_size - size of the Print output window + window_location - location on the screen (x,y) of window's top left cornder + + +These settings apply to all forms `SetOptions`. The Row options and Element options will take precedence over these settings. Settings can be thought of as levels of settings with the Form-level being the highest and the Element-level the lowest. Thus the levels are: + + - Form level + - Row level + - Element level + +Each lower level overrides the settings of the higher level. Once settings have been changed, they remain changed for the duration of the program (unless changed again). + +## Asynchronous (Non-Blocking) Forms +So you want to be a wizard do ya? Well go boldly! While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. With asynchronous forms the form is shown, user input is read, but your code keeps right on chugging. YOUR responsibility is to call `PySimpleGUI.ReadNonBlocking` on a periodic basis. Once a second or more will produce a reasonably snappy GUI. + +When do you use a non-blocking form? A couple of examples are +* A media file player like an MP3 player +* A status dashboard that's periodically updated +* Progress Meters - when you want to make your own progress meters +* Output using print to a scrolled text element. Good for debugging. + +Word of warning... version 2.2, the currently released, and upcoming version 2.3 differ in the return code for the `ReadNonBlocking` call. Previously the function returned 2 values, except when the form is closed using the "X" which returned a single value of `None`. The *new* way is that `ReadNonBlocking` always returns 2 values. If the user closed the form with the "X" then the return values will be None, None. You will want to key off the second value to catch this case. +The proper code to check if the user has exited the form will be a polling-loop that looks something like this: + + while True: + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + +We're going to build an app that does the latter. It's going to update our form with a running clock. + +The basic flow and functions you will be calling are: +Setup + + + form = FlexForm() + form_rows = ..... + form.LayoutAndRead(form_rows, non_blocking=True) + + +Periodic refresh + + form.ReadNonBlocking() +If you need to close the form + + form.CloseNonBlockingForm() + +Rather than the usual `form.LayoutAndRead()` call, we're manually adding the rows (doing the layout) and then showing the form. After the form is shown, you simply call `form.ReadNonBlocking()` every now and then. + +When you are ready to close the form (assuming the form wasn't closed by the user or a button click) you simply call `form.CloseNonBlockingForm()` + +**Example - Running timer that updates** +See the sample code on the GitHub named Demo Media Player for another example of Async Forms. We're going to make a form and update one of the elements of that form every .01 seconds. Here's the entire code to do that. + + + import PySimpleGUI as sg + import time + + # form that doesn't block + # Make a form, but don't use context manager + form = sg.FlexForm('Running Timer', auto_size_text=True) + # Create a text element that will be updated with status information on the GUI itself + output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) + # Create the rows + form_rows = [[sg.Text('Non-blocking GUI with updates')], + [output_element], + [sg.SimpleButton('Quit')]] + # Layout the rows of the form and perform a read. Indicate the form is non-blocking! + form.LayoutAndRead(form_rows, non_blocking=True) + + # + # Some place later in your code... + # You need to perform a ReadNonBlocking on your form every now and then or + # else it won't refresh + # + + for i in range(1, 1000): + output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + time.sleep(.01) + else: + form.CloseNonBlockingForm() + + + +What we have here is the same sequence of function calls as in the description. Get a form, add rows to it, show the form, and then refresh it every now and then. + +The new thing in this example is the call use of the Update method for the Text Element. The first thing we do inside the loop is "update" the text element that we made earlier. This changes the value of the text field on the form. The new value will be displayed when `form.ReadNonBlocking()` is called. + +Note the `else` statement on the for loop. This is needed because we're about to exit the loop while the form is still open. The user has not closed the form using the X nor a button so it's up to the caller to close the form using `CloseNonBlockingForm`. + +That's it... this example follows the async design pattern well. + + + +## Sample Applications +Use the example programs as a starting basis for your GUI. Copy, paste, modify and run! The demo files are: + +`Demo Recipes.py` - Sample forms for all major form types and situations. This is the place to get your code template from. Includes asynchronous forms, etc. + +`Demo DisplayHash1and256.py` - Demonstrates using High Level API calls to get a filename + +`Demo DupliucateFileFinder.py` - Demonstrates High Level API to get a folder & Easy Progress Meter to show progress of the file scanning + +`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. If anyone wants to help me package this application up, I could use a hand. + +## Fun Stuff +Here are some things to try if you're bored or want to further customize + +**Debug Output** +Be sure and check out the EasyPrint (Print) function described in the high-level API section. Leave your code the way it is, route your stdout and stderror to a scrolling window. + +For a fun time, add these lines to the top of your script + + import PySimpleGUI as sg + print = sg.Print + +This will turn all of your print statements into prints that display in a window on your screen rather than to the terminal. + +**Look and Feel** +Dial in the look and feel that you like with the `SetOptions` function. You can change all of the defaults in one function call. One line of code to customize the entire GUI. + +**ObjToString** +Ever wanted to easily display an objects contents easily? Use ObjToString to get a nicely formatted recursive walk of your objects. +This statement: + + print(sg.ObjToSting(x)) + +And this was the output + + + abc = abc + attr12 = 12 + c = + b = + a = + attr1 = 1 + attr2 = 2 + attr3 = three + attr10 = 10 + attrx = x + +You'll quickly wonder how you ever coded without it. + +--- +# Known Issues +While not an "issue" this is a ***stern warning*** + +## **Do not attempt** to call `PySimpleGUI` from multiple threads! It's `tkinter` based and `tkinter` has issues with multiple threads + +**Progress Meters** - the visual graphic portion of the meter may be off. May return to the native tkinter progress meter solution in the future. Right now a "custom" progress meter is used. On the bright side, the statistics shown are extremely accurate and can tell you something about the performance of your code. + +**Async Forms** - these include the 'easy' forms (EasyProgressMeter and EasyPrint/Print). If you start overlapping having Async forms open with normal forms then things get a littler squirrelly. Still tracking down the issues and am making it more solid every day possible. You'll know there's an issue when you see blank form. + +**EasyPrint** - EasyPrint is a new feature that's pretty awesome. You print and the output goes to a window, with a scroll bar, that you can copy and paste from. Being a new feature, it's got some potential problems. There are known interaction problems with other GUI windows. For example, closing a Print window can also close other windows you have open. For now, don't close your debug print window until other windows are closed too. + +## Contributing + +A MikeTheWatchGuy production... entirely responsible for this code.... unless it causes you trouble in which case I'm not at all responsible. + +## Versions +|Version | Description | +|--|--| +| 1.0.9 | July 10, 2018 - Initial Release | +| 1.0.21 | July 13, 2018 - Readme updates | +| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case +| 2.1.1 | July 18, 2018 - Global settings exposed, fixes +| 2.2.0| July 20, 2018 - Image Elements, Print output +| 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. +| 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi +| 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. +| 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ +| 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting + + +### Release Notes +2.3 - Sliders, Listbox's and Image elements (oh my!) + +If using Progress Meters, avoid cancelling them when you have another window open. It could lead to future windows being blank. It's being worked on. + +New debug printing capability. `sg.Print` + +2.5 Discovered issue with scroll bar on `Output` elements. The bar will match size of ROW not the size of the element. Normally you never notice this due to where on a form the `Output` element goes. + +Listboxes are still without scrollwheels. The mouse can drag to see more items. The mouse scrollwheel will also scroll the list and will `page up` and `page down` keys. + +2.7 Is the "feature complete" release. Pretty much all features are done and in the code + + +### Upcoming +Make suggestions people! Future release features + +Columns. How multiple columns would be specified in the SDK interface are still being designed. + +Port to other graphic engines. Hook up the front-end interface to a backend other than tkinter. Qt, WxPython, etc. + + + +## Code Condition + + Make it run + Make it right + Make it fast + +It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor for PEP 8 compliance. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. + +While the internals to PySimpleGUI are a tad sketchy, the public interfaces into the SDK are more strictly defined and comply with PEP 8 for the most part. + +Please log bugs and suggestions in the GitHub! It will only make the code stronger and better in the end, a good thing for us all, right? + +## Design + +A moment about the design-spirit of `PySimpleGUI`. From the beginning, this package was meant to take advantage of Python's capabilities with the goal of programming ease. + +**Single File** +While not the best programming practice, the implementation resulted in a single file solution. Only one file is needed, PySimpleGUI.py. You can post this file, email it, and easily import it using one statement. + +**Functions as objects** +In Python, functions behave just like object. When you're placing a Text Element into your form, you may be sometimes calling a function and other times declaring an object. If you use the word Text, then you're getting an object. If you're using `Txt`, then you're calling a function that returns a `Text` object. + +**Lists** +It seemed quite natural to use Python's powerful list constructs when possible. The form is specified as a series of lists. Each "row" of the GUI is represented as a list of Elements. When the form read returns the results to the user, all of the results are presented as a single list. This makes reading a form's values super-simple to do in a single line of Python code. + + +## Authors +MikeTheWatchGuy + +## License + +GNU Lesser General Public License (LGPL 3) + + +## Acknowledgments + +* Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence +* [Fredrik Lundh](https://wiki.python.org/moin/FredrikLundh) for his work on `tkinter` + + +## How Do I +Finally, I must thank the fine folks at How Do I. +https://github.com/gleitz/howdoi +Their utility has forever changed the way and pace in which I can program. I urge you to try the HowDoI.py application here on GitHub. Trust me, **it's going to be worth the effort!** +Here are the steps to run that application + + Install howdoi: + pip install howdoi + Test your install: + python -m howdoi howdoi.py + To run it: + Python HowDoI.py + +The pip command is all there is to the setup. + +The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. +For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. +![snap0109](https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg) + +In the hands of a competent programmer, this tool is **amazing**. It's a must-try kind of program that has completely changed my programming process. I'm not afraid of asking for help! You just have to be smart about using what you find. + +The PySimpleGUI window that the results are shown in is an 'input' field which means you can copy and paste the results right into your code. \ No newline at end of file From eafc4f7822309ca6874be600ff74650d03bc6c52 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 3 Aug 2018 19:15:28 -0400 Subject: [PATCH 103/209] Manually building an index.rst --- docs/index.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 docs/index.rst diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 000000000..910d80470 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,20 @@ +.. PySimpleGUI documentation master file, created by + sphinx-quickstart on Fri Aug 3 19:09:46 2018. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to PySimpleGUI's documentation! +======================================= + +.. toctree:: + :maxdepth: 2 + :caption: Contents: +README.md + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` From b714ea56d5df79a47b63068a8beec0f68fbe4beb Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 3 Aug 2018 19:16:43 -0400 Subject: [PATCH 104/209] Added copy of readme as index --- docs/index.md | 1506 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1506 insertions(+) create mode 100644 docs/index.md diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 000000000..f03d65375 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,1506 @@ + + +![pysimplegui_logo](https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png) + +[![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 +# PySimpleGUI + (Ver 2.7) + +Super-simple GUI to grasp... Powerfully customizable. + +Note - *Python3* is required to run PySimpleGUI. It takes advantage of some Python3 features that do not translate well into Python2. + +Looking to take your Python code from the world of command lines and into the convenience of a GUI? Have a Raspberry Pi with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK? Look no further, you've found your GUI package. + + import PySimpleGUI as sg + + sg.MsgBox('Hello From PySimpleGUI!', 'This is the shortest GUI program ever!') + + +![snap0136](https://user-images.githubusercontent.com/13696193/43162494-33095ece-8f59-11e8-86de-b6d8bcc5a52f.jpg) + + Build beautiful customized forms that fit your specific problem. Let PySimpleGUI solve your GUI problem while you solve the real problems. Do you really want to plod through the mountains of code required to program tkinter? + +![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) + +Perhaps you're looking for a way to interact with your Raspberry Pi in a more friendly way. The is the same form as above, except shown on a Pi. + +![raspberry pi](https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg) + + +In addition to a primary GUI, you can add a Progress Meter to your code with ONE LINE of code. Slide this into any of your `for` loops and get a nice meter like this: + + EasyProgressMeter('My meter title', current_value, max value) + + ![snap0177](https://user-images.githubusercontent.com/13696193/43658025-947973d2-9725-11e8-902f-e2d5effb6e3e.jpg) + +You can build an async media player GUI with custom buttons in 30 lines of code. + +![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) + +I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? + +There are a number of 'easy to use' Python GUIs, but they're **very** limiting. PySimpleGUI takes the best of packages like `EasyGUI`and `WxSimpleGUI` , both really handy but limited. The primary difference between these and PySimpleGUI is that in addition to getting the simple Message Boxes you also get the ability to make your own forms that are highly customizeable. Don't like the standard Message Box? Then make your own! + +Every call has optional parameters so that you can change the look and feel. Don't like the button color? It's easy to change by adding a button_color parameter to your widget. + +GUI Packages with more functionality, like QT and WxPython, require configuring and can take a ***week*** to get *reasonably familiar* with the interfaces. Clearly there needs to be a middle ground between forms with 1 or two input fields and a full-blown GUI. You'll be making your own custom forms with PySimpleGUI within minutes, even Async forms. + +With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. + +The `PySimpleGUI` package is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? + + Features of PySimpleGUI include: + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Realtime + Checkboxes + Radio Buttons + Listbox + Slider + Icons + Multi-line Text Input + Scroll-able Output + Images + Progress Bar + Async/Non-Blocking Windows + Tabbed forms + Persistent Windows + Redirect Python Output/Errors to scrolling window + 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + Single-Line-Of-Coide Proress Bar & Debug Print + Complete control of colors, look and feel + Button images + + +An example of many widgets used on a single form. A little further down you'll find the TWENTY lines of code required to create this complex form. Try it if you don't believe it. Start Python, copy and paste the code below into the >>> prompt and hit enter. This will pop up... + +![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) + +Here is the code that produced the above screenshot. + + import PySimpleGUI as sg + + with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText()], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [sg.Text('_' * 100, size=(70, 1))], + [sg.Text('Choose Source and Destination Folders', size=(35, 1))], + [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], + [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), + sg.FolderBrowse()], + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + + **A note on screen shots** +You will see a number of different styles of buttons, data entry fields, etc, in this readme. They were all made with the same SDK, the only difference is in the settings that are specified on a per-element, row, form, or global basis. One setting in particular, border_width, can make a big difference on the look of the form. Some of the screenshots had a border_width of 6, others a value of 1. + + +--- +### Design Goals +> Copy, Paste, Run. + +`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the code to visually match what's on the screen. + + > Be Pythonic + + Be Pythonic... Attempted to use language constructs in a natural way and to exploit some of Python's interesting features. Python's lists and optional parameters make PySimpleGUI work. + - Forms are represented as Python lists. + - A form is a list of rows + - A row is a list of elements +- Return values are a list of button presses and input values. + +It's stunning that after so many years Python still hasn't put forth a GUI framework that truly fits the language's basic data structures, especially lists. It's hard to argue with the success to be had in quickly building GUI applications using this package's syntax. + + ----- +## Getting Started with PySimpleGUI + +### Installing + + pip install PySimpleGUI + or +Simply download the file - PySimpleGUI.py and import it into your code + + +### Prerequisites + +Python 3 +tkinter + +Runs on all Python platforms that have tkinter running on them. Thoroughly tested on Windows. Runs on Windows, Mac, Linux, Raspberry Pi. Even runs on `pypy3`. + +### Using + +To use in your code, simply import.... + `import PySimpleGUI as sg` + +Then use either "high level" API calls or build your own forms. + + sg.MsgBox('This is my first message box') + +![snap0178](https://user-images.githubusercontent.com/13696193/43658024-945c83f8-9725-11e8-8ddd-0bbe67a9fc5d.jpg) + + +Yes, it's just that easy to have a window appear on the screen using Python. With PySimpleGUI, making a custom form appear isn't much more difficult. The goal is to get you running on your GUI within ***minutes***, not hours nor days. + +--- +## APIs + +PySimpleGUI can be broken down into 2 types of API's: + * High Level single call functions + * Custom form functions + + +### Python Language Features + + There are a couple of Python language features that PySimpleGUI utilizes heavily that should be understood first... + * Variable number of arguments to a function call + * Optional parameters to a function call + +#### Variable Number of Arguments + + The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. + + sg.MsgBox('Variable number of parameters example', var1, var2, "etc") + +Each new item begins on a new line in the Message Box + + ![snap0179](https://user-images.githubusercontent.com/13696193/43658129-f6ca49c6-9725-11e8-9317-1f77443eb04a.jpg) + + + +#### Optional Parameters to a Function Call + +This feature of the Python language is utilized ***heavily*** as a method of customizing forms and form Elements. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. + +Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't *have* to be specified on each and every call. + + def MsgBox(*args, + button_color=None, + button_type=MSG_BOX_OK, + auto_close=False, + auto_close_duration=None, + icon=DEFAULT_WINDOW_ICON, + line_width=MESSAGE_BOX_LINE_WIDTH, + font=None): + +If the caller wanted to change the button color to be black on yellow, the call would look something like this: + + sg.MsgBox('This box has a custom button color', button_color=('black', 'yellow')) + + +![snap0180](https://user-images.githubusercontent.com/13696193/43658171-13a72bfe-9726-11e8-8c7a-0a46e46fb202.jpg) + + +--- + +### High Level API Calls + +The classic "input a value, print result" example. +Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. +This code prompts user to input a line of text and then displays that text in a messages box: + + + import PySimpleGUI as sg + + rc = sg.GetTextBox('Title', 'Please input something') + sg.MsgBox('Results', 'The value returned from GetTextBox', rc) + + + ![snap0181](https://user-images.githubusercontent.com/13696193/43658233-48cc7794-9726-11e8-8582-8844280c344e.jpg) + +![snap0182](https://user-images.githubusercontent.com/13696193/43658232-48aaad4e-9726-11e8-95f5-aa9b9213bb77.jpg) + + +#### Message Boxes +In addition to MsgBox, you'll find a several API calls that are shortcuts to common messages boxes. You can achieve similar results by calling MsgBox with the correct parameters. + +The differences tend to be the number and types of buttons. Here are the calls and the windows that are created. + + import PySimpleGUI as sg + + `sg.MsgBoxOK('This is an OK MsgBox')` + + ![ok](https://user-images.githubusercontent.com/13696193/43667331-723ac666-9745-11e8-8666-230c35a6afd6.jpg) + + + sg.MsgBoxOKCancel('This is an OK Cancel MsgBox') + +![ok cancel 2](https://user-images.githubusercontent.com/13696193/43667330-71d5bea6-9745-11e8-8944-b3900853aa62.jpg) + + sg.MsgBoxCancel('This is a Cancel MsgBox') + +![cancel](https://user-images.githubusercontent.com/13696193/43667329-71a007de-9745-11e8-974b-d028f68798e7.jpg) + + sg.MsgBoxYesNo('This is a Yes No MsgBox') + +![yesno](https://user-images.githubusercontent.com/13696193/43667327-717ff7dc-9745-11e8-9dce-52c305a85101.jpg) + + + sg.MsgBoxError('This is an error MsgBox') + +![error msgbox](https://user-images.githubusercontent.com/13696193/43667326-71621712-9745-11e8-87c4-56e2ab500f8e.jpg) + + sg.MsgBoxAutoClose('This is an autoclose MsgBox') + +![autoclose](https://user-images.githubusercontent.com/13696193/43667325-714997dc-9745-11e8-836a-7185dc80329f.jpg) + + sg.ScrolledTextBox(my_text, height=10) + +![scrolledtextbox 2](https://user-images.githubusercontent.com/13696193/43667324-712aa0d4-9745-11e8-83a9-a0d0570d0865.jpg) + + +Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing your printed text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. Your code could contain a line like: + + sprint(f'My variables values include x={x}', f'y={y}') + +This becomes a debug print of sorts that will route to a scrolled window. + +See also the `EasyPrint` and `Print` functions. + +#### High Level User Input + +There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. If you need only 1 value, then perhaps one of these high level functions will work. + - GetTextBox + - GetFileBox + - GetFolderBox + + `submit_clicked, value = sg.GetTextBox('Title', 'Please enter anything')` + +![gettextbox 2](https://user-images.githubusercontent.com/13696193/43667510-355b23a2-9746-11e8-9f1e-91c0dd0f4ed8.jpg) + + submit_clicked, value = sg.GetFileBox('Title', 'Choose a file') + +![getfilebox 2](https://user-images.githubusercontent.com/13696193/43667535-5821fc94-9746-11e8-95c3-82395099e994.jpg) + + submit_clicked, value = sg.GetPathBox('Title', 'Choose a folder') + +![getpathbox](https://user-images.githubusercontent.com/13696193/43667556-79874c22-9746-11e8-80f2-8262d32802c2.jpg) + + +#### Progress Meter! +We all have loops in our code. 'Isn't it joyful waiting, watching a counter scrolling past in a text window? How about one line of code to get a progress meter, that contains statistics about your code? + + + EasyProgressMeter(title, + current_value, + max_value, + *args, + orientation=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): + +Here's the one-line Progress Meter in action! + + for i in range(1,10000): + sg.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') + +That line of code resulted in this window popping up and updating. + +![preogress meter](https://user-images.githubusercontent.com/13696193/43667625-d47da702-9746-11e8-91e6-e5177883abae.jpg) + +A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. +With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. + +***Be sure and add one to your loop counter*** so that your counter goes from 1 to the max value. If you do not add one, your counter will never hit the max value. Instead it will go from 0 to max-1. + +#### Debug Output +Another call in the 'Easy' families of APIs is `EasyPrint`. It will output to a debug window. If the debug window isn't open, then the first call will open it. No need to do anything but stick a 'print' call in your code. You can even replace your 'print' calls with calls to EasyPrint by simply sticking the statement + + print = sg.EasyPrint + +at the top of your code. +There are a number of names for the same EasyPrint function. `Print` is one of the better ones to use as it's easy to remember. It is simply `print` with a capital P. + + import PySimpleGUI as sg + + for i in range(100): + sg.Print(i) + +![snap0125](https://user-images.githubusercontent.com/13696193/43114979-a696189e-8ecf-11e8-83c7-473fcf0ccc66.jpg) +Or if you didn't want to change your code: + + import PySimpleGUI as sg + + print=sg.Print + for i in range(100): + print(i) + +Just like the standard print call, `EasyPrint` supports the `sep` and `end` keyword arguments. Other names that can be used to call `EasyPrint` include Print, `eprint`, If you want to close the window, call the function `EasyPrintClose`. + +A word of caution. There are known problems when multiple PySimpleGUI windows are opened, particularly if the user closes them in an unusual way. Not a reason to stay away from using it. Just something to keep in mind if you encounter a problem. + +You can change the size of the debug window using the `SetOptions` call with the `debug_win_size` parameter. + +--- +# Custom Form API Calls (Your First Form) + +This is the FUN part of the programming of this GUI. In order to really get the most out of the API, you should be using an IDE that supports auto complete or will show you the definition of the function. This will make customizing go smoother. + +This first section on custom forms is for your typical, blocking, non-persistant form. By this I mean, when you "show" the form, the function will not return until the user has clicked a button or closed the window. When this happens, the form's window will be automatically closed. + +Two other types of forms exist. +1. Persistent form - rather than closing on button clicks, the show form function returns and the form continues to be visible. This is good for applications like a chat window. +2. Asynchronous form - the trickiest of the lot. Great care must be exercised. Examples are an MP3 player or status dashboard. Async forms are updated (refreshed) on a periodic basis. + +It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. Let's start with a basic Browse for a file and do something with it. +# Copy these design patterns! +## Pattern 1 - With Context Manager + + + with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: + form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], + [sg.InputText(), sg.FileBrowse()], + [sg.Submit(), sg.Cancel()]] + button, (source_filename,) = form.LayoutAndRead(form_rows) + +## Pattern 2 - No Context Manager + + + form = sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) + form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], + [sg.InputText(), sg.FileBrowse()], + [sg.Submit(), sg.Cancel()]] + button, (source_filename,) = form.LayoutAndRead(form_rows) + + + +These 2 design patters both produce this custom form: + +![snap0134](https://user-images.githubusercontent.com/13696193/43162410-e7775466-8f58-11e8-8d6a-da4772c00dd8.jpg) + +It's important to use the "with" context manager so that resources are freed as quickly as possible, using the currently executing thread. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. + +The second design pattern is not context manager based. If you are struggling with an unknown error, try modifying the code to run without a context manager. To do so, you simple remove the with, stick the form on the front of that statement, and un-indent the with-block code. + +You will use these design patterns or code templates for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. This is the most basic / normal of the design patterns. + +### How GUI Programming in Python Should Look + +GUI programming in Python is a mess. tkinter kinda sucks. Why is Python such a great teaching language and yet no GUI framework exists that lends itself to the basic building blocks of Python, the list? + +The key to custom forms in PySimpleGUI is to view forms as ROWS of Widgets (Elements). Each row is specified as a list of these widgets. Put the rows together and you've got a form. + +Let's look at this one. + + +![snap0131](https://user-images.githubusercontent.com/13696193/43417007-df6d8408-9407-11e8-9986-30f0415f08a5.jpg) + +Let's agree the form has 4 rows. + +The first row only has **text** that reads `Rename files or folders` + +The second row has 3 elements in it. First the **text** `Source for Folders`, then an **input** field, then a **browse** button. + +Now let's look at how those 2 rows and the other two row from Python code: + + layout = [[sg.Text('Rename files or folders')], + [sg.Text('Source for Folders', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], + [sg.Text('Source for Files ', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], + [sg.Submit(), sg.Cancel()]] + +See how the source code mirrors the layout? You simply make lists for each row, then submit that table to PySimpleGUI to show and get values from. + +And what about those return values? Most people simply want to show a form, get the input values and do something with them. So why break up the code into button callbacks, etc, when I simply want my form's input values to be given to me. + +The same "row" concept applies to return values. The form is scanned from top to bottom, left to right. Each field that's an input field will occupy a spot in the return values. + +In our example form, there are 2 fields, so the return values from this form will be a list with 2 values in it. + + button, (folder_path, file_path) = form.LayoutAndRead(layout) + +In the statement that shows and reads the form, the two input fields are directly assigned to the caller's variables `folder_path` and `file_path`, ready to use. No parsing no callbacks. + +Isn't this what almost every Python programmer looking for a GUI wants?? Something easy to work with to get the values and move on to the rest of the program, where the real action is taking place. Why write pages of tkinter code when the same layout can be achieved with PySimpleGUI in 3 or 4 lines of code. 4 lines or 40? I chose 4. + + +### Laying out your form +Your form is a 2 dimensional list in Python. The first dimension are rows, the second is a list of Elements for each row. The first thing you want to do is layout your form on paper. + + layout = [ [row 1], + [row 2], + [row 3] ] + +Simple enough... a list of lists. +A row is a list of Elements. For example this could be a row with a couple of elements on it. + + [ Input, Button] + +Turning back to our example. This GUI roughly looks like this: + + layout = [ [Text], + [InputText, FileBrowse] + [Submit, Cancel] ] + + Now let's put it all together into an entire program. + + +### Line by line explanation + +Going through each line of code in the above form will help explain how to use this design patter. Copy, modify and run it! + + with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: +This creates a new form, storing it in the variable `form`. + + form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], +The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. + + [sg.InputText(), sg.FileBrowse()], +Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. + + [sg.Submit(), sg.Cancel()]] + +The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its value to the caller. + + button, (source_filename, ) = form.LayoutAndRead(form_rows) +This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field. The result of the form is stored directly into the variable we wish to work with. + + +## Return values + + Return information from FlexForm, SG's primary form builder interface, is in this format: + + button, (value1, value2, ...) + +Each of the Elements that are Input Elements will have a value in the list of return values. You can unpack your GUI directly into the variables you want to use. + + button, (filename, folder1, folder2, should_overwrite) = form.LayoutAndRead(form_rows) + + Or, you can unpack the return results separately. + + button, values = form.LayoutAndRead(form_rows) + filename, folder1, folder2, should_overwrite = values + +If you have a SINGLE value being returned, it is written this way: + + button, (value1,) = form.LayoutAndRead(form_rows) + + + Another way of parsing the return values is to store the list of values into a variable representing the list of values. + + button, value_list = form.LayoutAndRead(form_rows) + value1 = value_list[0] + value2 = value_list[1] + ... + +--- +## All Widgets / Elements +This code utilizes as many of the elements in one form as possible. + + with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText()], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [sg.Text('_' * 100, size=(70, 1))], + [sg.Text('Choose Source and Destination Folders', size=(35, 1))], + [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], + [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), + sg.FolderBrowse()], + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + +This is a somewhat complex form with quite a bit of custom sizing to make things line up well. This is code you only have to write once. When looking at the code, remember that what you're seeing is a list of lists. Each row contains a list of Graphical Elements that are used to create the form. + +![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) + +Clicking the Submit button caused the form call to return. The call to MsgBox resulted in this dialog box. +![results 2](https://user-images.githubusercontent.com/13696193/43097502-44e3ed32-8e8a-11e8-9a51-2b8af0b1a682.jpg) + + +**`Note, button value can be None`**. The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. + +You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. + +--- +# Building Custom Forms +You will find it much easier to write code using PySimpleGUI if you use an IDE such as PyCharm. The features that show you documentation about the API call you are making will help you determine which settings you want to change, if any. In PyCharm, two commands are particularly helpful. + + Control-Q (when cursor is on function name) brings up a box with the function definition + Control-P (when cursor inside function call "()") shows a list of parameters and their default values + +## Synchronous Forms +The most common use of PySimpleGUI is to display and collect information from the user. The most straightforward way to do this is using a "blocking" GUI call. Execution is "blocked" while waiting for the user to close the GUI form/dialog box. +You've already seen a number of examples above that use blocking forms. Anytime you see a context manager used (see the `with` statement) it's most likely a blocking form. You can examine the show calls to be sure. If the form is a non-blocking form, it must indicate that in the call to `form.show`. + +NON-BLOCKING form call: + + form.Show(non_blocking=True) + +### Beginning a Form +The first step is to create the form object using the desired form customization. + + with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: + +This is the definition of the FlexForm object: + + def FlexForm(title, + default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), + auto_size_text=None, + auto_size_buttons=None, + scale=(None, None), + location=(None, None), + button_color=None,Font=None, + progress_bar_color=(None,None), + is_tabbed_form=False, + border_depth=None, + auto_close=False, + auto_close_duration=DEFAULT_AUTOCLOSE_TIME, + icon=DEFAULT_WINDOW_ICON): + +Parameter Descriptions. You will find these same parameters specified for each `Element` and some of them in `Row` specifications. The `Element` specified value will take precedence over the `Row` and `Form` values. + + default_element_size - Size of elements in form in characters (width, height) + auto_size_text - Bool. True if elements should size themselves according to contents + auto_size_buttons - Bool. True if button elements should size themselves according to their text label + scale - Set size of element to be a multiple of the Element size + location - Location to place window in pixels + button_color - Default color for buttons (foreground, background). Can be text or hex + progress_bar_color - Foreground and background colors for progress bars + is_tabbed_form - Bool. If True then form is a tabbed form + border_depth - Amount of 'bezel' to put on input boxes, buttons, etc. + auto_close - Bool. If True form will autoclose + auto_close_duration - Duration in seconds before form closes + icon - .ICO file that will appear on the Task Bar and end of Title Bar + + +#### Sizes +Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. + +The default Element size for PySimpleGUI is `(45,1)`. + +Sizes can be set at the element level, or in this case, the size variables apply to all elements in the form. Setting `size=(20,1)` in the form creation call will set all elements in the form to that size. + +In addition to `size` there is a `scale` option. `scale` will take the Element's size and scale it up or down depending on the scale value. `scale=(1,1)` doesn't change the Element's size. `scale=(2,1)` will set the Element's size to be twice as wide as the size setting. + +There are a couple of widgets where one of the size values is in pixels rather than characters. This is true for Progress Meters and Sliders. The second parameter is the 'height' in pixels. + +#### FlexForm - form-level variables overview +A summary of the variables that can be changed when a FlexForm is created + + default_element_size - set default size for all elements in the form + auto_size_text- true/false autosizing turned on / off + scale - set scale value for all elements + button_color- default button color (foreground, background) + font - font name and size for all text items + progress_bar_color - progress bar colors + is_tabbed_form - true/false indicates form is a tabbed or normal form + border_depth - style setting for buttons, input fields + auto_close - true/false indicates if form will automatically close + auto_close_duration - how long in seconds before closing form + icon - filename for icon that's displayed on the window on taskbar + + +## Elements +"Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. + + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Realtime + Checkboxes + Radio Buttons + Listbox + Slider + Multi-line Text Input + Scroll-able Output + Progress Bar + Async/Non-Blocking Windows + Tabbed forms + Persistent Windows + Redirect Python Output/Errors to scrolling Window + "Higher level" APIs (e.g. MessageBox, YesNobox, ...) + + +### Output Elements +Building a form is simply making lists of Elements. Each list is a row in the overall GUI dialog box. The definition looks something like this: + + layout = [ [row 1 element, row 1 element], + [row 2 element, row 2 element, row 2 element] ] +The code is a crude representation of the GUI, laid out in text. +#### Text Element + + layout = [[sg.Text('This is what a Text Element looks like')]] + + + ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) + + +The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. + + Text(Text, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None, + text_color=None, + justification=None) +. + + Text - The text that's displayed + size - Element's size + auto_size_text - Bool. Change width to match size of text + font - Font name and size to use + text_color - text color + justification - Justification for the text. String - 'left', 'right', 'center' + +Some commonly used elements have 'shorthand' versions of the functions to make the code more compact. The functions `T` and `Txt` are the same as calling `Text`. + +**Fonts** in PySimpleGUI are always in this format: + + (font_name, point_size) + +The default font setting is + + ("Helvetica", 10) + +**Color** in PySimpleGUI are always in this format: + + (foreground, background) + +The values foreground and background can be the color names or the hex value formatted as a string: + + "#RRGGBB" + +**auto_size_text** +A `True` value for `auto_size_text`, when placed on any Element, indicates that the width of the Element should be shrunk do the width of the text. This is particularly useful with `Buttons` as fixed-width buttons are somewhat crude looking. The default value is `False`. You will often see this setting on FlexForm definitions. + +**Shorthand functions** +The shorthand functions for `Text` are `Txt` and `T` + + +#### Multiline Text Element + + layout = [[sg.Multiline('This is what a Multi-line Text Element looks like', size=(45,5))]] +![multiline text](https://user-images.githubusercontent.com/13696193/42670464-0824c754-8629-11e8-9741-6ed08f924618.jpg) +This Element doubles as both an input and output Element. The `DefaultText` optional parameter is used to indicate what to output to the window. + + Multiline(default_text='', + enter_submits = False, + scale=(None, None), + size=(None, None), + auto_size_text=None) +. + + default_text - Text to display in the text box + enter_submits - Bool. If True, pressing Enter key submits form + scale - Element's scale + size - Element's size + auto_size_text - Bool. Change width to match size of text + +#### Output Element +Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. More on this later. + + form.AddRow(gg.Output(size=(100,20))) + +![output element](https://user-images.githubusercontent.com/13696193/42704820-5446959c-869f-11e8-849e-047ea280387a.jpg) + + Output(scale=(None, None), + size=(None, None)) +. + + scale - How much to scale size of element + size - Size of element (width, height) in characters + +### Input Elements + These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. + +#### Text Input Element + + layout = [[sg.InputText('Default text')]] +![inputtext](https://user-images.githubusercontent.com/13696193/42693515-610a716c-867d-11e8-9a00-7e7fcf771230.jpg) + + def InputText(default_text = '', + scale=(None, None), + size=(None, None), + auto_size_text=None, + password_char='') +. + + default_text - Text initially shown in the input box + scale - Amount size is scaled by + size - (width, height) of element in characters + auto_size_text- Bool. True is element should be sized to fit text + password_char - Character that will be used to replace each entered character. Setting to a value indicates this field is a password entry field + +Shorthand functions that are equivalent to `InputText` are `Input` and `In` + + +#### Combo Element +Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. + + layout = [[sg.InputCombo(['choice 1', 'choice 2'])]] + +![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) + + InputCombo(values, + scale=(None, None), + size=(None, None), + auto_size_text=None) +. + + values - Choices to be displayed. List of strings + scale - Amount to scale size by + size - (width, height) of element in characters + auto_size_text - Bool. True if size should fit the text length + +#### Listbox Element +The standard listbox like you'll find in most GUIs. Note that the return values from this element will be a ***list of results, not a single result***. This is because the user can select more than 1 item from the list (if you set the right mode). + + layout = [[sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6))]] + +![snap0130](https://user-images.githubusercontent.com/13696193/43115859-2fbf0646-8ed3-11e8-9979-bbee8eaebfab.jpg) + + + Listbox(values, + select_mode=None, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None) +. + + values - Choices to be displayed. List of strings + select_mode - Defines how to list is to operate. + Choices include constants or strings: + Constants version: + LISTBOX_SELECT_MODE_BROWSE + LISTBOX_SELECT_MODE_EXTENDED + LISTBOX_SELECT_MODE_MULTIPLE + LISTBOX_SELECT_MODE_SINGLE - the default + Strings version: + 'browse' + 'extended' + 'multiple' + 'single' + scale - Amount to scale size by + size - (width, height) of element in characters + auto_size_text - Bool. True if size should fit the text length + +The `select_mode` option can be a string or a constant value defined as a variable. Generally speaking strings are used for these kinds of options. + +#### Slider Element +Sliders have a couple of slider-specific settings as well as appearance settings. Examples include the `orientation` and `range` settings. + + layout = [[sg.Slider(range=(1,500), default_value=222, size=(20,15), orientation='horizontal', font=('Helvetica', 12))]] + +![snap0129](https://user-images.githubusercontent.com/13696193/43115741-e1cb52c8-8ed2-11e8-80bb-0e99ae846ec1.jpg) + + Slider(range=(None,None), + default_value=None, + orientation=None, + border_width=None, + relief=None, + scale=(None, None), + size=(None, None), + font=None): +. + + range - (min, max) slider's range + default_value - default setting (within range) + orientation - 'horizontal' or 'vertical' ('h' or 'v' work) + border_width - how deep the widget looks + relief - relief style. Values are same as progress meter relief values. Can be a constant or a string: + RELIEF_RAISED= 'raised' + RELIEF_SUNKEN= 'sunken' + RELIEF_FLAT= 'flat' + RELIEF_RIDGE= 'ridge' + RELIEF_GROOVE= 'groove' + RELIEF_SOLID = 'solid' + scale - Amount to scale size by + size - (width, height) of element in characters + auto_size_text - Bool. True if size should fit the text + +#### Radio Button Element +Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. + + layout = [[sg.Radio('My first Radio!', "RADIO1", default=True), sg.Radio('My second radio!', "RADIO1")]] + +![radio element](https://user-images.githubusercontent.com/13696193/42705705-327b4b6c-86a2-11e8-81a7-740e57646ba8.jpg) + + Radio(text, + group_id, + default=False, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None) + +. + + text - Text to display next to button + group_id - Groups together multiple Radio Buttons. Can be any value + default - Bool. Initial state + scale - Amount to scale size of element + size- (width, height) size of element in characters + auto_size_text - Bool. True if should size width to fit text + font - Font type and size for text display + + +#### Checkbox Element +Checkbox elements are like Radio Button elements. They return a bool indicating whether or not they are checked. + + layout = [[sg.Checkbox('My first Checkbox!', default=True), sg.Checkbox('My second Checkbox!')]] + +![checkbox element](https://user-images.githubusercontent.com/13696193/42717015-655d73d2-86cc-11e8-9c69-3c810f48e578.jpg) + + + Checkbox(text, + default=False, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None): +. + + text - Text to display next to checkbox + default- Bool. Initial state + scale - Amount to scale size of element + size - (width, height) size of element in characters + auto_size_text- Bool. True if should size width to fit text + font- Font type and size for text display + + +#### Spin Element +An up/down spinner control. The valid values are passed in as a list. + + layout = [[sg.Spin([i for i in range(1,11)], initial_value=1), sg.Text('Volume level')]] + +![spin element](https://user-images.githubusercontent.com/13696193/42717231-8ddb51d4-86cd-11e8-827a-75f2237477fa.jpg) + + Spin(values, + intiial_value=None, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None) +. + + values - List of valid values + initial_value - String with initial value + scale - Amount to scale size of element + size - (width, height) size of element in characters + auto_size_text - Bool. True if should size width to fit text + font - Font type and size for text display + +#### Button Element +Buttons are the most important element of all! They cause the majority of the action to happen. After all, it's a button press that will get you out of a form, whether it but Submit or Cancel, one way or another a button is involved in all forms. The only exception is to this is when the user closes the window using the "X" in the upper corner which means no button was involved. + +The Types of buttons include: +* Folder Browse +* File Browse +* Close Form +* Read Form +* Realtime + + + Close Form - Normal buttons like Submit, Cancel, Yes, No, etc, are "Close Form" buttons. They cause the input values to be read and then the form is closed, returning the values to the caller. + +Folder Browse - When clicked a folder browse dialog box is opened. The results of the Folder Browse dialog box are written into one of the input fields of the form. + +File Browse - Same as the Folder Browse except rather than choosing a folder, a single file is chosen. + +Read Form - This is an async form button that will read a snapshot of all of the input fields, but does not close the form after it's clicked. + +Realtime - This is another async form button. Normal button clicks occur after a button's click is released. Realtime buttons report a click the entire time the button is held down. + +While it's possible to build forms using the Button Element directly, you should never need to do that. There are pre-made buttons and shortcuts that will make life much easier. The most basic Button element call to use is `SimpleButton` + + SimpleButton(text, + scale=(None, None), + size=(None, None), + auto_size_button=None, + button_color=None, + font=None) + +Pre-made buttons include: + + OK + Ok + Submit + Cancel + Yes + No + FileBrowse + FolderBrowse +. + layout = [[sg.OK(), sg.Cancel()]] + +![ok cancel](https://user-images.githubusercontent.com/13696193/42717733-1803f584-86d1-11e8-9223-36b782971b9f.jpg) + +The FileBrowse and FolderBrowse buttons both fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. + +The default value for `Target` is `(ThisRow, -1)`. ThisRow is a special value that tells the GUI to use the same row as the button. The Y-value of -1 means the field one value to the left of the button. For a File or Folder Browse button, the field that it fills are generally to the left of the button is most cases. + +Let's examine this form as an example: + +![button target example](https://user-images.githubusercontent.com/13696193/42718075-b4dcb61e-86d3-11e8-904c-d709dd364108.jpg) + +The `InputText` element is located at (1,0)... row 1, column 0. The `Browse` button is located at position (2,0). The Target for the button could be any of these values: + + Target = (1,0) + Target = (-1,0) +The code for the entire form could be: + + layout = [[sg.T('Source Folder')], + [sg.In()], + [sg.FolderBrowse(Target=(-1,0)), sg.OK()]] + +**Custom Buttons** +Not all buttons are created equal. A button that closes a form is different that a button that returns from the form without closing it. If you want to define your own button, you will generally do this with the Button Element `SimpleButton`, which closes the form when clicked. + +layout = [[sg.SimpleButton('My Button')]] + +![singlebutton](https://user-images.githubusercontent.com/13696193/42718281-9453deca-86d5-11e8-83c7-4b6d33720858.jpg) + +All buttons can have their text changed by changing the `button_text` variable in the button call. It is this text that is returned when a form is read. This text will be what tells you which button is called so make it unique. Most of the convenience buttons (Submit, Cancel, Yes, etc) are all SimpleButtons. The two that are not are `FileBrowse` and `FolderBrowse`. They clearly do not close the form. Instead they bring up a file or folder browser dialog box. + +**Button Images** +Now this is an exciting feature not found in many simplified packages.... images on buttons! You can make a pretty spiffy user interface with the help of a few button images. + +Your button images need to be in PNG or GIF format. When you make a button with an image, set the button background to the same color as the background. There's a button color TRANSPARENT_BUTTON that you can set your button color to in order for it to blend into the background. Note that this value is currently the same as the color as the default system background on Windows. + +This example comes from the `Demo Media Player.py` example program. Because it's a non-blocking button, it's defined as `ReadFormButton`. You also put images on blocking buttons by using `SimpleButton`. + + + sg.ReadFormButton('Restart Song', button_color=sg.TRANSPARENT_BUTTON, + image_filename=image_restart, image_size=(50, 50), image_subsample=2, border_width=0) + +Three parameters are used for button images. + + image_filename - Filename. Can be a relative path + image_size - Size of image file in pixels + image_subsample - Amount to divide the size by. 2 means your image will be 1/2 the size. 3 means 1/3 + +Here's an example form made with button images. + +![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) + +You'll find the source code in the file Demo Media Player. Here is what the button calls look like to create media player form + + sg.ReadFormButton('Pause', button_color=sg.TRANSPARENT_BUTTON, + image_filename=image_pause, image_size=(50, 50), image_subsample=2, border_width=0) + +This is one you'll have to experiment with at this point. Not up for an exhaustive explanation. + + **Realtime Buttons** + + Normally buttons are considered "clicked" when the mouse button is let UP after a downward click on the button. What about times when you need to read the raw up/down button values. A classic example for this is a robotic remote control. Building a remote control using a GUI is easy enough. One button for each of the directions is a start. Perhaps something like this: + +![snap0135](https://user-images.githubusercontent.com/13696193/43440841-bcf8d184-9466-11e8-9f7b-30a1d5ce32d3.jpg) + +This form has 2 button types. There's the normal "Simple Button" (Quit) and 4 "Realtime Buttons". + +Here is the code to make, show and get results from this form: + + form = sg.FlexForm('Robotics Remote Control', auto_size_text=True) + + form_rows = [[sg.Text('Robotics Remote Control')], + [sg.T(' '*10), sg.RealtimeButton('Forward')], + [ sg.RealtimeButton('Left'), sg.T(' '*15), sg.RealtimeButton('Right')], + [sg.T(' '*10), sg.RealtimeButton('Reverse')], + [sg.T('')], + [sg.Quit(button_color=('black', 'orange'))] + ] + + form.LayoutAndRead(form_rows, non_blocking=True) + +Somewhere later in your code will be your main event loop. This is where you do your polling of devices, do input/output, etc. It's here that you will read your form's buttons. + + while (True): + # This is the code that reads and updates your window + button, values = form.ReadNonBlocking() + if button is not None: + sg.Print(button) + if button == 'Quit' or values is None: + break + time.sleep(.01) + +This loop will read button values and print them. When one of the Realtime buttons is clicked, the call to `form.ReadNonBlocking` will return a button name matching the name on the button that was depressed. It will continue to return values as long as the button remains depressed. Once released, the ReadNonBlocking will return None for buttons ules anutton was clicked. + +**File Types** +The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is + + FileTypes=(("ALL Files", "*.*"),) + +This code produces a form where the Browse button only shows files of type .TXT + + layout = [[sg.In() ,sg.FileBrowse(file_types=(("Text Files", "*.txt"),))]] + + ***The ENTER key*** + The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. + + --- +#### ProgressBar +The `ProgressBar` element is used to build custom Progress Bar forms. It is HIGHLY recommended that you use the functions that provide a complete progress meter solution for you. Progress Meters are not easy to work with because the forms have to be non-blocking and they are tricky to debug. + +The **easiest** way to get progress meters into your code is to use the `EasyProgessMeter` API. This consists of a pair of functions, `EasyProgessMeter` and `EasyProgressMeterCancel`. You can easily cancel any progress meter by calling it with the current value = max value. This will mark the meter as expired and close the window. +You've already seen EasyProgressMeter calls presented earlier in this readme. + + sg.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') + +The return value for `EasyProgressMeter` is: +`True` if meter updated correctly +`False` if user clicked the Cancel button, closed the form, or vale reached the max value. +**Customized Progress Bar** +If you want a bit more customization of your meter, then you can go up 1 level and use the calls to `ProgressMeter` and `ProgressMeterUpdate`. These APIs behave like an object we're all used to. First you create the `ProgressMeter` object, then you call the `Update` method to update it. + +You setup the progress meter by calling + + my_meter = ProgressMeter(title, + max_value, + *args, + orientantion=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) +Then to update the bar within your loop + + return_code = ProgressMeterUpdate(my_meter, + value, + *args): +Putting it all together you get this design pattern + + my_meter = sg.ProgressMeter('Meter Title', 100000, orentation='Vert') + + for i in range(0, 100000): + sg.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') + + +The final way of using a Progress Meter with PySimpleGUI is to build a custom form with a `ProgressBar` Element in the form. You will need to run your form as a non-blocking form. When you are ready to update your progress bar, you call the `UpdateBar` method for the `ProgressBar` element itself. + + +#### Output +The Output Element is a re-direction of Stdout. Anything "printed" will be displayed in this element. + + Output(scale=(None, None), + size=(None, None)) + +Here's a complete solution for a chat-window using an Async form with an Output Element + + import PySimpleGUI as sg + # Blocking form that doesn't close + def ChatBot(): + with sg.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + layout = [[(sg.Text('This is where standard out is being routed', size=[40, 1]))], + [sg.Output(size=(80, 20))], + [sg.Multiline(size=(70, 5), enter_submits=True), sg.ReadFormButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0])), sg.SimpleButton('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]] + # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form + # if you call LayoutAndRead from here, then you will miss the first button click + form.Layout(layout) + # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # + while True: + button, value = form.Read() + if button == 'SEND': + print(value) + else: + break + + +## Tabbed Forms +Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format + + results = ShowTabbedForm('Title for the form', + (form,layout,'Tab 1 label'), + (form2,layout2, 'Tab 2 label'), ...) + +Each of the tabs of the form is in fact a form. The same steps are taken to create the form as before. A `FlexForm` is created, then rows are filled with Elements, and finally the form is shown. When calling `ShowTabbedForm`, each form is passed in as a tuple. The tuple has the format: `(the form, the rows, a string shown on the tab)` + +Results are returned as a list of lists. For each form you'll get a list that's in the same format as a normal form. A single tab's values would be: + + (button, (values)) + +Recall that values is a list as well. Multiple tabs in the form would return like this: + + ((button1, (values1)), (button2, (values2)) + + ## Colors ## +Starting in version 2.5 you can change the background colors for the window and the Elements. + +Your forms can go from this: +![snap0155](https://user-images.githubusercontent.com/13696193/43273879-a9fdc10a-90cb-11e8-8c20-4f6a244ebe2f.jpg) + + +to this... with one function call... + +![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) + + + +While you can do it on an element by element or form level basis, the easiest way, by far, is a call to `SetOptions`. + +Be aware that once you change these options they are changed for the rest of your program's execution. All of your forms will have that look and feel, until you change it to something else (which could be the system default colors. + +This call sets all of the different color options. + + SetOptions(background_color='#9FB8AD', + text_element_background_color='#9FB8AD', + element_background_color='#9FB8AD', + scrollbar_color=None, + input_elements_background_color='#F7F3EC', + progress_meter_color = ('green', 'blue') + button_color=('white','#475841')) + + + +## Global Settings +**Global Settings** +Let's have some fun customizing! Make PySimpleGUI look the way you want it to look. You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. + + SetOptions(icon=None + button_color=(None,None) + element_size=(None,None), + margins=(None,None), + element_padding=(None,None) + auto_size_text=None + auto_size_buttons=None + font=None + border_width=None + slider_border_width=None + slider_relief=None + slider_orientation=None + autoclose_time=None + message_box_line_width=None + progress_meter_border_depth=None + progress_meter_style=None + progress_meter_relief=None + progress_meter_color=None + progress_meter_size=None + text_justification=None + background_color=None + element_background_color=None + text_element_background_color=None + input_elements_background_color=None + scrollbar_color=None, text_color=None + debug_win_size=(None,None) + window_location=(None,None) + +Explanation of parameters + + icon - filename of icon used for taskbar and title bar + button_color - button color (foreground, background) + element_size - element size (width, height) in characters + margins - tkinter margins around outsize + element_padding - tkinter padding around each element + auto_size_text - autosize the elements to fit their text + auto_size_buttons - autosize the buttons to fit their text + font - font used for elements + border_width - amount of bezel or border around sunken or raised elements + slider_border_width - changes the way sliders look + slider_relief - changes the way sliders look + slider_orientation - changes orientation of slider + autoclose_time - time in seconds for autoclose boxes + message_box_line_width - number of characers in a line of text in message boxes + progress_meter_border_depth - amount of border around raised or lowered progress meters + progress_meter_style - style of progress meter as defined by tkinter + progress_meter_relief - relief style + progress_meter_color - color of the bar and background of progress meters + progress_meter_size - size in (characters, pixels) + background_color - Color of the main window's background + element_background_color - Background color of the elements + text_element_background_color - Text element background color + input_elements_background_color - Input fields background color + scrollbar_color - Color for scrollbars (may not always work) + text_color - Text element default text color + text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' + debug_win_size - size of the Print output window + window_location - location on the screen (x,y) of window's top left cornder + + +These settings apply to all forms `SetOptions`. The Row options and Element options will take precedence over these settings. Settings can be thought of as levels of settings with the Form-level being the highest and the Element-level the lowest. Thus the levels are: + + - Form level + - Row level + - Element level + +Each lower level overrides the settings of the higher level. Once settings have been changed, they remain changed for the duration of the program (unless changed again). + +## Asynchronous (Non-Blocking) Forms +So you want to be a wizard do ya? Well go boldly! While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. With asynchronous forms the form is shown, user input is read, but your code keeps right on chugging. YOUR responsibility is to call `PySimpleGUI.ReadNonBlocking` on a periodic basis. Once a second or more will produce a reasonably snappy GUI. + +When do you use a non-blocking form? A couple of examples are +* A media file player like an MP3 player +* A status dashboard that's periodically updated +* Progress Meters - when you want to make your own progress meters +* Output using print to a scrolled text element. Good for debugging. + +Word of warning... version 2.2, the currently released, and upcoming version 2.3 differ in the return code for the `ReadNonBlocking` call. Previously the function returned 2 values, except when the form is closed using the "X" which returned a single value of `None`. The *new* way is that `ReadNonBlocking` always returns 2 values. If the user closed the form with the "X" then the return values will be None, None. You will want to key off the second value to catch this case. +The proper code to check if the user has exited the form will be a polling-loop that looks something like this: + + while True: + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + +We're going to build an app that does the latter. It's going to update our form with a running clock. + +The basic flow and functions you will be calling are: +Setup + + + form = FlexForm() + form_rows = ..... + form.LayoutAndRead(form_rows, non_blocking=True) + + +Periodic refresh + + form.ReadNonBlocking() +If you need to close the form + + form.CloseNonBlockingForm() + +Rather than the usual `form.LayoutAndRead()` call, we're manually adding the rows (doing the layout) and then showing the form. After the form is shown, you simply call `form.ReadNonBlocking()` every now and then. + +When you are ready to close the form (assuming the form wasn't closed by the user or a button click) you simply call `form.CloseNonBlockingForm()` + +**Example - Running timer that updates** +See the sample code on the GitHub named Demo Media Player for another example of Async Forms. We're going to make a form and update one of the elements of that form every .01 seconds. Here's the entire code to do that. + + + import PySimpleGUI as sg + import time + + # form that doesn't block + # Make a form, but don't use context manager + form = sg.FlexForm('Running Timer', auto_size_text=True) + # Create a text element that will be updated with status information on the GUI itself + output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) + # Create the rows + form_rows = [[sg.Text('Non-blocking GUI with updates')], + [output_element], + [sg.SimpleButton('Quit')]] + # Layout the rows of the form and perform a read. Indicate the form is non-blocking! + form.LayoutAndRead(form_rows, non_blocking=True) + + # + # Some place later in your code... + # You need to perform a ReadNonBlocking on your form every now and then or + # else it won't refresh + # + + for i in range(1, 1000): + output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + time.sleep(.01) + else: + form.CloseNonBlockingForm() + + + +What we have here is the same sequence of function calls as in the description. Get a form, add rows to it, show the form, and then refresh it every now and then. + +The new thing in this example is the call use of the Update method for the Text Element. The first thing we do inside the loop is "update" the text element that we made earlier. This changes the value of the text field on the form. The new value will be displayed when `form.ReadNonBlocking()` is called. + +Note the `else` statement on the for loop. This is needed because we're about to exit the loop while the form is still open. The user has not closed the form using the X nor a button so it's up to the caller to close the form using `CloseNonBlockingForm`. + +That's it... this example follows the async design pattern well. + + + +## Sample Applications +Use the example programs as a starting basis for your GUI. Copy, paste, modify and run! The demo files are: + +`Demo Recipes.py` - Sample forms for all major form types and situations. This is the place to get your code template from. Includes asynchronous forms, etc. + +`Demo DisplayHash1and256.py` - Demonstrates using High Level API calls to get a filename + +`Demo DupliucateFileFinder.py` - Demonstrates High Level API to get a folder & Easy Progress Meter to show progress of the file scanning + +`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. If anyone wants to help me package this application up, I could use a hand. + +## Fun Stuff +Here are some things to try if you're bored or want to further customize + +**Debug Output** +Be sure and check out the EasyPrint (Print) function described in the high-level API section. Leave your code the way it is, route your stdout and stderror to a scrolling window. + +For a fun time, add these lines to the top of your script + + import PySimpleGUI as sg + print = sg.Print + +This will turn all of your print statements into prints that display in a window on your screen rather than to the terminal. + +**Look and Feel** +Dial in the look and feel that you like with the `SetOptions` function. You can change all of the defaults in one function call. One line of code to customize the entire GUI. + +**ObjToString** +Ever wanted to easily display an objects contents easily? Use ObjToString to get a nicely formatted recursive walk of your objects. +This statement: + + print(sg.ObjToSting(x)) + +And this was the output + + + abc = abc + attr12 = 12 + c = + b = + a = + attr1 = 1 + attr2 = 2 + attr3 = three + attr10 = 10 + attrx = x + +You'll quickly wonder how you ever coded without it. + +--- +# Known Issues +While not an "issue" this is a ***stern warning*** + +## **Do not attempt** to call `PySimpleGUI` from multiple threads! It's `tkinter` based and `tkinter` has issues with multiple threads + +**Progress Meters** - the visual graphic portion of the meter may be off. May return to the native tkinter progress meter solution in the future. Right now a "custom" progress meter is used. On the bright side, the statistics shown are extremely accurate and can tell you something about the performance of your code. + +**Async Forms** - these include the 'easy' forms (EasyProgressMeter and EasyPrint/Print). If you start overlapping having Async forms open with normal forms then things get a littler squirrelly. Still tracking down the issues and am making it more solid every day possible. You'll know there's an issue when you see blank form. + +**EasyPrint** - EasyPrint is a new feature that's pretty awesome. You print and the output goes to a window, with a scroll bar, that you can copy and paste from. Being a new feature, it's got some potential problems. There are known interaction problems with other GUI windows. For example, closing a Print window can also close other windows you have open. For now, don't close your debug print window until other windows are closed too. + +## Contributing + +A MikeTheWatchGuy production... entirely responsible for this code.... unless it causes you trouble in which case I'm not at all responsible. + +## Versions +|Version | Description | +|--|--| +| 1.0.9 | July 10, 2018 - Initial Release | +| 1.0.21 | July 13, 2018 - Readme updates | +| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case +| 2.1.1 | July 18, 2018 - Global settings exposed, fixes +| 2.2.0| July 20, 2018 - Image Elements, Print output +| 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. +| 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi +| 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. +| 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ +| 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting + + +### Release Notes +2.3 - Sliders, Listbox's and Image elements (oh my!) + +If using Progress Meters, avoid cancelling them when you have another window open. It could lead to future windows being blank. It's being worked on. + +New debug printing capability. `sg.Print` + +2.5 Discovered issue with scroll bar on `Output` elements. The bar will match size of ROW not the size of the element. Normally you never notice this due to where on a form the `Output` element goes. + +Listboxes are still without scrollwheels. The mouse can drag to see more items. The mouse scrollwheel will also scroll the list and will `page up` and `page down` keys. + +2.7 Is the "feature complete" release. Pretty much all features are done and in the code + + +### Upcoming +Make suggestions people! Future release features + +Columns. How multiple columns would be specified in the SDK interface are still being designed. + +Port to other graphic engines. Hook up the front-end interface to a backend other than tkinter. Qt, WxPython, etc. + + + +## Code Condition + + Make it run + Make it right + Make it fast + +It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor for PEP 8 compliance. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. + +While the internals to PySimpleGUI are a tad sketchy, the public interfaces into the SDK are more strictly defined and comply with PEP 8 for the most part. + +Please log bugs and suggestions in the GitHub! It will only make the code stronger and better in the end, a good thing for us all, right? + +## Design + +A moment about the design-spirit of `PySimpleGUI`. From the beginning, this package was meant to take advantage of Python's capabilities with the goal of programming ease. + +**Single File** +While not the best programming practice, the implementation resulted in a single file solution. Only one file is needed, PySimpleGUI.py. You can post this file, email it, and easily import it using one statement. + +**Functions as objects** +In Python, functions behave just like object. When you're placing a Text Element into your form, you may be sometimes calling a function and other times declaring an object. If you use the word Text, then you're getting an object. If you're using `Txt`, then you're calling a function that returns a `Text` object. + +**Lists** +It seemed quite natural to use Python's powerful list constructs when possible. The form is specified as a series of lists. Each "row" of the GUI is represented as a list of Elements. When the form read returns the results to the user, all of the results are presented as a single list. This makes reading a form's values super-simple to do in a single line of Python code. + + +## Authors +MikeTheWatchGuy + +## License + +GNU Lesser General Public License (LGPL 3) + + +## Acknowledgments + +* Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence +* [Fredrik Lundh](https://wiki.python.org/moin/FredrikLundh) for his work on `tkinter` + + +## How Do I +Finally, I must thank the fine folks at How Do I. +https://github.com/gleitz/howdoi +Their utility has forever changed the way and pace in which I can program. I urge you to try the HowDoI.py application here on GitHub. Trust me, **it's going to be worth the effort!** +Here are the steps to run that application + + Install howdoi: + pip install howdoi + Test your install: + python -m howdoi howdoi.py + To run it: + Python HowDoI.py + +The pip command is all there is to the setup. + +The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. +For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. +![snap0109](https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg) + +In the hands of a competent programmer, this tool is **amazing**. It's a must-try kind of program that has completely changed my programming process. I'm not afraid of asking for help! You just have to be smart about using what you find. + +The PySimpleGUI window that the results are shown in is an 'input' field which means you can copy and paste the results right into your code. \ No newline at end of file From 0b0e589aaf32c8203bc3cfe9e88ec5562d9897c9 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 3 Aug 2018 19:28:33 -0400 Subject: [PATCH 105/209] Trying different readme import --- docs/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index 910d80470..88bb4950f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -9,7 +9,7 @@ Welcome to PySimpleGUI's documentation! .. toctree:: :maxdepth: 2 :caption: Contents: -README.md +../readme.md Indices and tables From e4f369261b223b1303453ed70246557d47507f28 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 3 Aug 2018 19:29:04 -0400 Subject: [PATCH 106/209] Removed from docs folder --- docs/index.md | 1506 ------------------------------------------------ docs/readme.md | 1506 ------------------------------------------------ 2 files changed, 3012 deletions(-) delete mode 100644 docs/index.md delete mode 100644 docs/readme.md diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index f03d65375..000000000 --- a/docs/index.md +++ /dev/null @@ -1,1506 +0,0 @@ - - -![pysimplegui_logo](https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png) - -[![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 -# PySimpleGUI - (Ver 2.7) - -Super-simple GUI to grasp... Powerfully customizable. - -Note - *Python3* is required to run PySimpleGUI. It takes advantage of some Python3 features that do not translate well into Python2. - -Looking to take your Python code from the world of command lines and into the convenience of a GUI? Have a Raspberry Pi with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK? Look no further, you've found your GUI package. - - import PySimpleGUI as sg - - sg.MsgBox('Hello From PySimpleGUI!', 'This is the shortest GUI program ever!') - - -![snap0136](https://user-images.githubusercontent.com/13696193/43162494-33095ece-8f59-11e8-86de-b6d8bcc5a52f.jpg) - - Build beautiful customized forms that fit your specific problem. Let PySimpleGUI solve your GUI problem while you solve the real problems. Do you really want to plod through the mountains of code required to program tkinter? - -![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) - -Perhaps you're looking for a way to interact with your Raspberry Pi in a more friendly way. The is the same form as above, except shown on a Pi. - -![raspberry pi](https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg) - - -In addition to a primary GUI, you can add a Progress Meter to your code with ONE LINE of code. Slide this into any of your `for` loops and get a nice meter like this: - - EasyProgressMeter('My meter title', current_value, max value) - - ![snap0177](https://user-images.githubusercontent.com/13696193/43658025-947973d2-9725-11e8-902f-e2d5effb6e3e.jpg) - -You can build an async media player GUI with custom buttons in 30 lines of code. - -![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) - -I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? - -There are a number of 'easy to use' Python GUIs, but they're **very** limiting. PySimpleGUI takes the best of packages like `EasyGUI`and `WxSimpleGUI` , both really handy but limited. The primary difference between these and PySimpleGUI is that in addition to getting the simple Message Boxes you also get the ability to make your own forms that are highly customizeable. Don't like the standard Message Box? Then make your own! - -Every call has optional parameters so that you can change the look and feel. Don't like the button color? It's easy to change by adding a button_color parameter to your widget. - -GUI Packages with more functionality, like QT and WxPython, require configuring and can take a ***week*** to get *reasonably familiar* with the interfaces. Clearly there needs to be a middle ground between forms with 1 or two input fields and a full-blown GUI. You'll be making your own custom forms with PySimpleGUI within minutes, even Async forms. - -With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. - -The `PySimpleGUI` package is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? - - Features of PySimpleGUI include: - Text - Single Line Input - Buttons including these types: - File Browse - Folder Browse - Non-closing return - Close form - Realtime - Checkboxes - Radio Buttons - Listbox - Slider - Icons - Multi-line Text Input - Scroll-able Output - Images - Progress Bar - Async/Non-Blocking Windows - Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling window - 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) - Single-Line-Of-Coide Proress Bar & Debug Print - Complete control of colors, look and feel - Button images - - -An example of many widgets used on a single form. A little further down you'll find the TWENTY lines of code required to create this complex form. Try it if you don't believe it. Start Python, copy and paste the code below into the >>> prompt and hit enter. This will pop up... - -![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) - -Here is the code that produced the above screenshot. - - import PySimpleGUI as sg - - with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: - layout = [ - [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [sg.Text('Here is some text.... and a place to enter text')], - [sg.InputText()], - [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], - [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], - [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', - scale=(2, 10))], - [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [sg.Text('_' * 100, size=(70, 1))], - [sg.Text('Choose Source and Destination Folders', size=(35, 1))], - [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], - [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), - sg.FolderBrowse()], - [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] - ] - - button, values = form.LayoutAndRead(layout) - - **A note on screen shots** -You will see a number of different styles of buttons, data entry fields, etc, in this readme. They were all made with the same SDK, the only difference is in the settings that are specified on a per-element, row, form, or global basis. One setting in particular, border_width, can make a big difference on the look of the form. Some of the screenshots had a border_width of 6, others a value of 1. - - ---- -### Design Goals -> Copy, Paste, Run. - -`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the code to visually match what's on the screen. - - > Be Pythonic - - Be Pythonic... Attempted to use language constructs in a natural way and to exploit some of Python's interesting features. Python's lists and optional parameters make PySimpleGUI work. - - Forms are represented as Python lists. - - A form is a list of rows - - A row is a list of elements -- Return values are a list of button presses and input values. - -It's stunning that after so many years Python still hasn't put forth a GUI framework that truly fits the language's basic data structures, especially lists. It's hard to argue with the success to be had in quickly building GUI applications using this package's syntax. - - ----- -## Getting Started with PySimpleGUI - -### Installing - - pip install PySimpleGUI - or -Simply download the file - PySimpleGUI.py and import it into your code - - -### Prerequisites - -Python 3 -tkinter - -Runs on all Python platforms that have tkinter running on them. Thoroughly tested on Windows. Runs on Windows, Mac, Linux, Raspberry Pi. Even runs on `pypy3`. - -### Using - -To use in your code, simply import.... - `import PySimpleGUI as sg` - -Then use either "high level" API calls or build your own forms. - - sg.MsgBox('This is my first message box') - -![snap0178](https://user-images.githubusercontent.com/13696193/43658024-945c83f8-9725-11e8-8ddd-0bbe67a9fc5d.jpg) - - -Yes, it's just that easy to have a window appear on the screen using Python. With PySimpleGUI, making a custom form appear isn't much more difficult. The goal is to get you running on your GUI within ***minutes***, not hours nor days. - ---- -## APIs - -PySimpleGUI can be broken down into 2 types of API's: - * High Level single call functions - * Custom form functions - - -### Python Language Features - - There are a couple of Python language features that PySimpleGUI utilizes heavily that should be understood first... - * Variable number of arguments to a function call - * Optional parameters to a function call - -#### Variable Number of Arguments - - The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. - - sg.MsgBox('Variable number of parameters example', var1, var2, "etc") - -Each new item begins on a new line in the Message Box - - ![snap0179](https://user-images.githubusercontent.com/13696193/43658129-f6ca49c6-9725-11e8-9317-1f77443eb04a.jpg) - - - -#### Optional Parameters to a Function Call - -This feature of the Python language is utilized ***heavily*** as a method of customizing forms and form Elements. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. - -Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't *have* to be specified on each and every call. - - def MsgBox(*args, - button_color=None, - button_type=MSG_BOX_OK, - auto_close=False, - auto_close_duration=None, - icon=DEFAULT_WINDOW_ICON, - line_width=MESSAGE_BOX_LINE_WIDTH, - font=None): - -If the caller wanted to change the button color to be black on yellow, the call would look something like this: - - sg.MsgBox('This box has a custom button color', button_color=('black', 'yellow')) - - -![snap0180](https://user-images.githubusercontent.com/13696193/43658171-13a72bfe-9726-11e8-8c7a-0a46e46fb202.jpg) - - ---- - -### High Level API Calls - -The classic "input a value, print result" example. -Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. -This code prompts user to input a line of text and then displays that text in a messages box: - - - import PySimpleGUI as sg - - rc = sg.GetTextBox('Title', 'Please input something') - sg.MsgBox('Results', 'The value returned from GetTextBox', rc) - - - ![snap0181](https://user-images.githubusercontent.com/13696193/43658233-48cc7794-9726-11e8-8582-8844280c344e.jpg) - -![snap0182](https://user-images.githubusercontent.com/13696193/43658232-48aaad4e-9726-11e8-95f5-aa9b9213bb77.jpg) - - -#### Message Boxes -In addition to MsgBox, you'll find a several API calls that are shortcuts to common messages boxes. You can achieve similar results by calling MsgBox with the correct parameters. - -The differences tend to be the number and types of buttons. Here are the calls and the windows that are created. - - import PySimpleGUI as sg - - `sg.MsgBoxOK('This is an OK MsgBox')` - - ![ok](https://user-images.githubusercontent.com/13696193/43667331-723ac666-9745-11e8-8666-230c35a6afd6.jpg) - - - sg.MsgBoxOKCancel('This is an OK Cancel MsgBox') - -![ok cancel 2](https://user-images.githubusercontent.com/13696193/43667330-71d5bea6-9745-11e8-8944-b3900853aa62.jpg) - - sg.MsgBoxCancel('This is a Cancel MsgBox') - -![cancel](https://user-images.githubusercontent.com/13696193/43667329-71a007de-9745-11e8-974b-d028f68798e7.jpg) - - sg.MsgBoxYesNo('This is a Yes No MsgBox') - -![yesno](https://user-images.githubusercontent.com/13696193/43667327-717ff7dc-9745-11e8-9dce-52c305a85101.jpg) - - - sg.MsgBoxError('This is an error MsgBox') - -![error msgbox](https://user-images.githubusercontent.com/13696193/43667326-71621712-9745-11e8-87c4-56e2ab500f8e.jpg) - - sg.MsgBoxAutoClose('This is an autoclose MsgBox') - -![autoclose](https://user-images.githubusercontent.com/13696193/43667325-714997dc-9745-11e8-836a-7185dc80329f.jpg) - - sg.ScrolledTextBox(my_text, height=10) - -![scrolledtextbox 2](https://user-images.githubusercontent.com/13696193/43667324-712aa0d4-9745-11e8-83a9-a0d0570d0865.jpg) - - -Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing your printed text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. Your code could contain a line like: - - sprint(f'My variables values include x={x}', f'y={y}') - -This becomes a debug print of sorts that will route to a scrolled window. - -See also the `EasyPrint` and `Print` functions. - -#### High Level User Input - -There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. If you need only 1 value, then perhaps one of these high level functions will work. - - GetTextBox - - GetFileBox - - GetFolderBox - - `submit_clicked, value = sg.GetTextBox('Title', 'Please enter anything')` - -![gettextbox 2](https://user-images.githubusercontent.com/13696193/43667510-355b23a2-9746-11e8-9f1e-91c0dd0f4ed8.jpg) - - submit_clicked, value = sg.GetFileBox('Title', 'Choose a file') - -![getfilebox 2](https://user-images.githubusercontent.com/13696193/43667535-5821fc94-9746-11e8-95c3-82395099e994.jpg) - - submit_clicked, value = sg.GetPathBox('Title', 'Choose a folder') - -![getpathbox](https://user-images.githubusercontent.com/13696193/43667556-79874c22-9746-11e8-80f2-8262d32802c2.jpg) - - -#### Progress Meter! -We all have loops in our code. 'Isn't it joyful waiting, watching a counter scrolling past in a text window? How about one line of code to get a progress meter, that contains statistics about your code? - - - EasyProgressMeter(title, - current_value, - max_value, - *args, - orientation=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, - button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), - border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): - -Here's the one-line Progress Meter in action! - - for i in range(1,10000): - sg.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') - -That line of code resulted in this window popping up and updating. - -![preogress meter](https://user-images.githubusercontent.com/13696193/43667625-d47da702-9746-11e8-91e6-e5177883abae.jpg) - -A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. -With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. - -***Be sure and add one to your loop counter*** so that your counter goes from 1 to the max value. If you do not add one, your counter will never hit the max value. Instead it will go from 0 to max-1. - -#### Debug Output -Another call in the 'Easy' families of APIs is `EasyPrint`. It will output to a debug window. If the debug window isn't open, then the first call will open it. No need to do anything but stick a 'print' call in your code. You can even replace your 'print' calls with calls to EasyPrint by simply sticking the statement - - print = sg.EasyPrint - -at the top of your code. -There are a number of names for the same EasyPrint function. `Print` is one of the better ones to use as it's easy to remember. It is simply `print` with a capital P. - - import PySimpleGUI as sg - - for i in range(100): - sg.Print(i) - -![snap0125](https://user-images.githubusercontent.com/13696193/43114979-a696189e-8ecf-11e8-83c7-473fcf0ccc66.jpg) -Or if you didn't want to change your code: - - import PySimpleGUI as sg - - print=sg.Print - for i in range(100): - print(i) - -Just like the standard print call, `EasyPrint` supports the `sep` and `end` keyword arguments. Other names that can be used to call `EasyPrint` include Print, `eprint`, If you want to close the window, call the function `EasyPrintClose`. - -A word of caution. There are known problems when multiple PySimpleGUI windows are opened, particularly if the user closes them in an unusual way. Not a reason to stay away from using it. Just something to keep in mind if you encounter a problem. - -You can change the size of the debug window using the `SetOptions` call with the `debug_win_size` parameter. - ---- -# Custom Form API Calls (Your First Form) - -This is the FUN part of the programming of this GUI. In order to really get the most out of the API, you should be using an IDE that supports auto complete or will show you the definition of the function. This will make customizing go smoother. - -This first section on custom forms is for your typical, blocking, non-persistant form. By this I mean, when you "show" the form, the function will not return until the user has clicked a button or closed the window. When this happens, the form's window will be automatically closed. - -Two other types of forms exist. -1. Persistent form - rather than closing on button clicks, the show form function returns and the form continues to be visible. This is good for applications like a chat window. -2. Asynchronous form - the trickiest of the lot. Great care must be exercised. Examples are an MP3 player or status dashboard. Async forms are updated (refreshed) on a periodic basis. - -It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. Let's start with a basic Browse for a file and do something with it. -# Copy these design patterns! -## Pattern 1 - With Context Manager - - - with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: - form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], - [sg.InputText(), sg.FileBrowse()], - [sg.Submit(), sg.Cancel()]] - button, (source_filename,) = form.LayoutAndRead(form_rows) - -## Pattern 2 - No Context Manager - - - form = sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) - form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], - [sg.InputText(), sg.FileBrowse()], - [sg.Submit(), sg.Cancel()]] - button, (source_filename,) = form.LayoutAndRead(form_rows) - - - -These 2 design patters both produce this custom form: - -![snap0134](https://user-images.githubusercontent.com/13696193/43162410-e7775466-8f58-11e8-8d6a-da4772c00dd8.jpg) - -It's important to use the "with" context manager so that resources are freed as quickly as possible, using the currently executing thread. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. - -The second design pattern is not context manager based. If you are struggling with an unknown error, try modifying the code to run without a context manager. To do so, you simple remove the with, stick the form on the front of that statement, and un-indent the with-block code. - -You will use these design patterns or code templates for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. This is the most basic / normal of the design patterns. - -### How GUI Programming in Python Should Look - -GUI programming in Python is a mess. tkinter kinda sucks. Why is Python such a great teaching language and yet no GUI framework exists that lends itself to the basic building blocks of Python, the list? - -The key to custom forms in PySimpleGUI is to view forms as ROWS of Widgets (Elements). Each row is specified as a list of these widgets. Put the rows together and you've got a form. - -Let's look at this one. - - -![snap0131](https://user-images.githubusercontent.com/13696193/43417007-df6d8408-9407-11e8-9986-30f0415f08a5.jpg) - -Let's agree the form has 4 rows. - -The first row only has **text** that reads `Rename files or folders` - -The second row has 3 elements in it. First the **text** `Source for Folders`, then an **input** field, then a **browse** button. - -Now let's look at how those 2 rows and the other two row from Python code: - - layout = [[sg.Text('Rename files or folders')], - [sg.Text('Source for Folders', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], - [sg.Text('Source for Files ', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], - [sg.Submit(), sg.Cancel()]] - -See how the source code mirrors the layout? You simply make lists for each row, then submit that table to PySimpleGUI to show and get values from. - -And what about those return values? Most people simply want to show a form, get the input values and do something with them. So why break up the code into button callbacks, etc, when I simply want my form's input values to be given to me. - -The same "row" concept applies to return values. The form is scanned from top to bottom, left to right. Each field that's an input field will occupy a spot in the return values. - -In our example form, there are 2 fields, so the return values from this form will be a list with 2 values in it. - - button, (folder_path, file_path) = form.LayoutAndRead(layout) - -In the statement that shows and reads the form, the two input fields are directly assigned to the caller's variables `folder_path` and `file_path`, ready to use. No parsing no callbacks. - -Isn't this what almost every Python programmer looking for a GUI wants?? Something easy to work with to get the values and move on to the rest of the program, where the real action is taking place. Why write pages of tkinter code when the same layout can be achieved with PySimpleGUI in 3 or 4 lines of code. 4 lines or 40? I chose 4. - - -### Laying out your form -Your form is a 2 dimensional list in Python. The first dimension are rows, the second is a list of Elements for each row. The first thing you want to do is layout your form on paper. - - layout = [ [row 1], - [row 2], - [row 3] ] - -Simple enough... a list of lists. -A row is a list of Elements. For example this could be a row with a couple of elements on it. - - [ Input, Button] - -Turning back to our example. This GUI roughly looks like this: - - layout = [ [Text], - [InputText, FileBrowse] - [Submit, Cancel] ] - - Now let's put it all together into an entire program. - - -### Line by line explanation - -Going through each line of code in the above form will help explain how to use this design patter. Copy, modify and run it! - - with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: -This creates a new form, storing it in the variable `form`. - - form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], -The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. - - [sg.InputText(), sg.FileBrowse()], -Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. - - [sg.Submit(), sg.Cancel()]] - -The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its value to the caller. - - button, (source_filename, ) = form.LayoutAndRead(form_rows) -This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field. The result of the form is stored directly into the variable we wish to work with. - - -## Return values - - Return information from FlexForm, SG's primary form builder interface, is in this format: - - button, (value1, value2, ...) - -Each of the Elements that are Input Elements will have a value in the list of return values. You can unpack your GUI directly into the variables you want to use. - - button, (filename, folder1, folder2, should_overwrite) = form.LayoutAndRead(form_rows) - - Or, you can unpack the return results separately. - - button, values = form.LayoutAndRead(form_rows) - filename, folder1, folder2, should_overwrite = values - -If you have a SINGLE value being returned, it is written this way: - - button, (value1,) = form.LayoutAndRead(form_rows) - - - Another way of parsing the return values is to store the list of values into a variable representing the list of values. - - button, value_list = form.LayoutAndRead(form_rows) - value1 = value_list[0] - value2 = value_list[1] - ... - ---- -## All Widgets / Elements -This code utilizes as many of the elements in one form as possible. - - with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: - layout = [ - [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [sg.Text('Here is some text.... and a place to enter text')], - [sg.InputText()], - [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], - [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], - [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', - scale=(2, 10))], - [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [sg.Text('_' * 100, size=(70, 1))], - [sg.Text('Choose Source and Destination Folders', size=(35, 1))], - [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], - [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), - sg.FolderBrowse()], - [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] - ] - - button, values = form.LayoutAndRead(layout) - -This is a somewhat complex form with quite a bit of custom sizing to make things line up well. This is code you only have to write once. When looking at the code, remember that what you're seeing is a list of lists. Each row contains a list of Graphical Elements that are used to create the form. - -![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) - -Clicking the Submit button caused the form call to return. The call to MsgBox resulted in this dialog box. -![results 2](https://user-images.githubusercontent.com/13696193/43097502-44e3ed32-8e8a-11e8-9a51-2b8af0b1a682.jpg) - - -**`Note, button value can be None`**. The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. - -You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. - ---- -# Building Custom Forms -You will find it much easier to write code using PySimpleGUI if you use an IDE such as PyCharm. The features that show you documentation about the API call you are making will help you determine which settings you want to change, if any. In PyCharm, two commands are particularly helpful. - - Control-Q (when cursor is on function name) brings up a box with the function definition - Control-P (when cursor inside function call "()") shows a list of parameters and their default values - -## Synchronous Forms -The most common use of PySimpleGUI is to display and collect information from the user. The most straightforward way to do this is using a "blocking" GUI call. Execution is "blocked" while waiting for the user to close the GUI form/dialog box. -You've already seen a number of examples above that use blocking forms. Anytime you see a context manager used (see the `with` statement) it's most likely a blocking form. You can examine the show calls to be sure. If the form is a non-blocking form, it must indicate that in the call to `form.show`. - -NON-BLOCKING form call: - - form.Show(non_blocking=True) - -### Beginning a Form -The first step is to create the form object using the desired form customization. - - with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: - -This is the definition of the FlexForm object: - - def FlexForm(title, - default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), - auto_size_text=None, - auto_size_buttons=None, - scale=(None, None), - location=(None, None), - button_color=None,Font=None, - progress_bar_color=(None,None), - is_tabbed_form=False, - border_depth=None, - auto_close=False, - auto_close_duration=DEFAULT_AUTOCLOSE_TIME, - icon=DEFAULT_WINDOW_ICON): - -Parameter Descriptions. You will find these same parameters specified for each `Element` and some of them in `Row` specifications. The `Element` specified value will take precedence over the `Row` and `Form` values. - - default_element_size - Size of elements in form in characters (width, height) - auto_size_text - Bool. True if elements should size themselves according to contents - auto_size_buttons - Bool. True if button elements should size themselves according to their text label - scale - Set size of element to be a multiple of the Element size - location - Location to place window in pixels - button_color - Default color for buttons (foreground, background). Can be text or hex - progress_bar_color - Foreground and background colors for progress bars - is_tabbed_form - Bool. If True then form is a tabbed form - border_depth - Amount of 'bezel' to put on input boxes, buttons, etc. - auto_close - Bool. If True form will autoclose - auto_close_duration - Duration in seconds before form closes - icon - .ICO file that will appear on the Task Bar and end of Title Bar - - -#### Sizes -Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. - -The default Element size for PySimpleGUI is `(45,1)`. - -Sizes can be set at the element level, or in this case, the size variables apply to all elements in the form. Setting `size=(20,1)` in the form creation call will set all elements in the form to that size. - -In addition to `size` there is a `scale` option. `scale` will take the Element's size and scale it up or down depending on the scale value. `scale=(1,1)` doesn't change the Element's size. `scale=(2,1)` will set the Element's size to be twice as wide as the size setting. - -There are a couple of widgets where one of the size values is in pixels rather than characters. This is true for Progress Meters and Sliders. The second parameter is the 'height' in pixels. - -#### FlexForm - form-level variables overview -A summary of the variables that can be changed when a FlexForm is created - - default_element_size - set default size for all elements in the form - auto_size_text- true/false autosizing turned on / off - scale - set scale value for all elements - button_color- default button color (foreground, background) - font - font name and size for all text items - progress_bar_color - progress bar colors - is_tabbed_form - true/false indicates form is a tabbed or normal form - border_depth - style setting for buttons, input fields - auto_close - true/false indicates if form will automatically close - auto_close_duration - how long in seconds before closing form - icon - filename for icon that's displayed on the window on taskbar - - -## Elements -"Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. - - Text - Single Line Input - Buttons including these types: - File Browse - Folder Browse - Non-closing return - Close form - Realtime - Checkboxes - Radio Buttons - Listbox - Slider - Multi-line Text Input - Scroll-able Output - Progress Bar - Async/Non-Blocking Windows - Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling Window - "Higher level" APIs (e.g. MessageBox, YesNobox, ...) - - -### Output Elements -Building a form is simply making lists of Elements. Each list is a row in the overall GUI dialog box. The definition looks something like this: - - layout = [ [row 1 element, row 1 element], - [row 2 element, row 2 element, row 2 element] ] -The code is a crude representation of the GUI, laid out in text. -#### Text Element - - layout = [[sg.Text('This is what a Text Element looks like')]] - - - ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) - - -The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. - - Text(Text, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None, - text_color=None, - justification=None) -. - - Text - The text that's displayed - size - Element's size - auto_size_text - Bool. Change width to match size of text - font - Font name and size to use - text_color - text color - justification - Justification for the text. String - 'left', 'right', 'center' - -Some commonly used elements have 'shorthand' versions of the functions to make the code more compact. The functions `T` and `Txt` are the same as calling `Text`. - -**Fonts** in PySimpleGUI are always in this format: - - (font_name, point_size) - -The default font setting is - - ("Helvetica", 10) - -**Color** in PySimpleGUI are always in this format: - - (foreground, background) - -The values foreground and background can be the color names or the hex value formatted as a string: - - "#RRGGBB" - -**auto_size_text** -A `True` value for `auto_size_text`, when placed on any Element, indicates that the width of the Element should be shrunk do the width of the text. This is particularly useful with `Buttons` as fixed-width buttons are somewhat crude looking. The default value is `False`. You will often see this setting on FlexForm definitions. - -**Shorthand functions** -The shorthand functions for `Text` are `Txt` and `T` - - -#### Multiline Text Element - - layout = [[sg.Multiline('This is what a Multi-line Text Element looks like', size=(45,5))]] -![multiline text](https://user-images.githubusercontent.com/13696193/42670464-0824c754-8629-11e8-9741-6ed08f924618.jpg) -This Element doubles as both an input and output Element. The `DefaultText` optional parameter is used to indicate what to output to the window. - - Multiline(default_text='', - enter_submits = False, - scale=(None, None), - size=(None, None), - auto_size_text=None) -. - - default_text - Text to display in the text box - enter_submits - Bool. If True, pressing Enter key submits form - scale - Element's scale - size - Element's size - auto_size_text - Bool. Change width to match size of text - -#### Output Element -Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. More on this later. - - form.AddRow(gg.Output(size=(100,20))) - -![output element](https://user-images.githubusercontent.com/13696193/42704820-5446959c-869f-11e8-849e-047ea280387a.jpg) - - Output(scale=(None, None), - size=(None, None)) -. - - scale - How much to scale size of element - size - Size of element (width, height) in characters - -### Input Elements - These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. - -#### Text Input Element - - layout = [[sg.InputText('Default text')]] -![inputtext](https://user-images.githubusercontent.com/13696193/42693515-610a716c-867d-11e8-9a00-7e7fcf771230.jpg) - - def InputText(default_text = '', - scale=(None, None), - size=(None, None), - auto_size_text=None, - password_char='') -. - - default_text - Text initially shown in the input box - scale - Amount size is scaled by - size - (width, height) of element in characters - auto_size_text- Bool. True is element should be sized to fit text - password_char - Character that will be used to replace each entered character. Setting to a value indicates this field is a password entry field - -Shorthand functions that are equivalent to `InputText` are `Input` and `In` - - -#### Combo Element -Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. - - layout = [[sg.InputCombo(['choice 1', 'choice 2'])]] - -![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) - - InputCombo(values, - scale=(None, None), - size=(None, None), - auto_size_text=None) -. - - values - Choices to be displayed. List of strings - scale - Amount to scale size by - size - (width, height) of element in characters - auto_size_text - Bool. True if size should fit the text length - -#### Listbox Element -The standard listbox like you'll find in most GUIs. Note that the return values from this element will be a ***list of results, not a single result***. This is because the user can select more than 1 item from the list (if you set the right mode). - - layout = [[sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6))]] - -![snap0130](https://user-images.githubusercontent.com/13696193/43115859-2fbf0646-8ed3-11e8-9979-bbee8eaebfab.jpg) - - - Listbox(values, - select_mode=None, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None) -. - - values - Choices to be displayed. List of strings - select_mode - Defines how to list is to operate. - Choices include constants or strings: - Constants version: - LISTBOX_SELECT_MODE_BROWSE - LISTBOX_SELECT_MODE_EXTENDED - LISTBOX_SELECT_MODE_MULTIPLE - LISTBOX_SELECT_MODE_SINGLE - the default - Strings version: - 'browse' - 'extended' - 'multiple' - 'single' - scale - Amount to scale size by - size - (width, height) of element in characters - auto_size_text - Bool. True if size should fit the text length - -The `select_mode` option can be a string or a constant value defined as a variable. Generally speaking strings are used for these kinds of options. - -#### Slider Element -Sliders have a couple of slider-specific settings as well as appearance settings. Examples include the `orientation` and `range` settings. - - layout = [[sg.Slider(range=(1,500), default_value=222, size=(20,15), orientation='horizontal', font=('Helvetica', 12))]] - -![snap0129](https://user-images.githubusercontent.com/13696193/43115741-e1cb52c8-8ed2-11e8-80bb-0e99ae846ec1.jpg) - - Slider(range=(None,None), - default_value=None, - orientation=None, - border_width=None, - relief=None, - scale=(None, None), - size=(None, None), - font=None): -. - - range - (min, max) slider's range - default_value - default setting (within range) - orientation - 'horizontal' or 'vertical' ('h' or 'v' work) - border_width - how deep the widget looks - relief - relief style. Values are same as progress meter relief values. Can be a constant or a string: - RELIEF_RAISED= 'raised' - RELIEF_SUNKEN= 'sunken' - RELIEF_FLAT= 'flat' - RELIEF_RIDGE= 'ridge' - RELIEF_GROOVE= 'groove' - RELIEF_SOLID = 'solid' - scale - Amount to scale size by - size - (width, height) of element in characters - auto_size_text - Bool. True if size should fit the text - -#### Radio Button Element -Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. - - layout = [[sg.Radio('My first Radio!', "RADIO1", default=True), sg.Radio('My second radio!', "RADIO1")]] - -![radio element](https://user-images.githubusercontent.com/13696193/42705705-327b4b6c-86a2-11e8-81a7-740e57646ba8.jpg) - - Radio(text, - group_id, - default=False, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None) - -. - - text - Text to display next to button - group_id - Groups together multiple Radio Buttons. Can be any value - default - Bool. Initial state - scale - Amount to scale size of element - size- (width, height) size of element in characters - auto_size_text - Bool. True if should size width to fit text - font - Font type and size for text display - - -#### Checkbox Element -Checkbox elements are like Radio Button elements. They return a bool indicating whether or not they are checked. - - layout = [[sg.Checkbox('My first Checkbox!', default=True), sg.Checkbox('My second Checkbox!')]] - -![checkbox element](https://user-images.githubusercontent.com/13696193/42717015-655d73d2-86cc-11e8-9c69-3c810f48e578.jpg) - - - Checkbox(text, - default=False, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None): -. - - text - Text to display next to checkbox - default- Bool. Initial state - scale - Amount to scale size of element - size - (width, height) size of element in characters - auto_size_text- Bool. True if should size width to fit text - font- Font type and size for text display - - -#### Spin Element -An up/down spinner control. The valid values are passed in as a list. - - layout = [[sg.Spin([i for i in range(1,11)], initial_value=1), sg.Text('Volume level')]] - -![spin element](https://user-images.githubusercontent.com/13696193/42717231-8ddb51d4-86cd-11e8-827a-75f2237477fa.jpg) - - Spin(values, - intiial_value=None, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None) -. - - values - List of valid values - initial_value - String with initial value - scale - Amount to scale size of element - size - (width, height) size of element in characters - auto_size_text - Bool. True if should size width to fit text - font - Font type and size for text display - -#### Button Element -Buttons are the most important element of all! They cause the majority of the action to happen. After all, it's a button press that will get you out of a form, whether it but Submit or Cancel, one way or another a button is involved in all forms. The only exception is to this is when the user closes the window using the "X" in the upper corner which means no button was involved. - -The Types of buttons include: -* Folder Browse -* File Browse -* Close Form -* Read Form -* Realtime - - - Close Form - Normal buttons like Submit, Cancel, Yes, No, etc, are "Close Form" buttons. They cause the input values to be read and then the form is closed, returning the values to the caller. - -Folder Browse - When clicked a folder browse dialog box is opened. The results of the Folder Browse dialog box are written into one of the input fields of the form. - -File Browse - Same as the Folder Browse except rather than choosing a folder, a single file is chosen. - -Read Form - This is an async form button that will read a snapshot of all of the input fields, but does not close the form after it's clicked. - -Realtime - This is another async form button. Normal button clicks occur after a button's click is released. Realtime buttons report a click the entire time the button is held down. - -While it's possible to build forms using the Button Element directly, you should never need to do that. There are pre-made buttons and shortcuts that will make life much easier. The most basic Button element call to use is `SimpleButton` - - SimpleButton(text, - scale=(None, None), - size=(None, None), - auto_size_button=None, - button_color=None, - font=None) - -Pre-made buttons include: - - OK - Ok - Submit - Cancel - Yes - No - FileBrowse - FolderBrowse -. - layout = [[sg.OK(), sg.Cancel()]] - -![ok cancel](https://user-images.githubusercontent.com/13696193/42717733-1803f584-86d1-11e8-9223-36b782971b9f.jpg) - -The FileBrowse and FolderBrowse buttons both fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. - -The default value for `Target` is `(ThisRow, -1)`. ThisRow is a special value that tells the GUI to use the same row as the button. The Y-value of -1 means the field one value to the left of the button. For a File or Folder Browse button, the field that it fills are generally to the left of the button is most cases. - -Let's examine this form as an example: - -![button target example](https://user-images.githubusercontent.com/13696193/42718075-b4dcb61e-86d3-11e8-904c-d709dd364108.jpg) - -The `InputText` element is located at (1,0)... row 1, column 0. The `Browse` button is located at position (2,0). The Target for the button could be any of these values: - - Target = (1,0) - Target = (-1,0) -The code for the entire form could be: - - layout = [[sg.T('Source Folder')], - [sg.In()], - [sg.FolderBrowse(Target=(-1,0)), sg.OK()]] - -**Custom Buttons** -Not all buttons are created equal. A button that closes a form is different that a button that returns from the form without closing it. If you want to define your own button, you will generally do this with the Button Element `SimpleButton`, which closes the form when clicked. - -layout = [[sg.SimpleButton('My Button')]] - -![singlebutton](https://user-images.githubusercontent.com/13696193/42718281-9453deca-86d5-11e8-83c7-4b6d33720858.jpg) - -All buttons can have their text changed by changing the `button_text` variable in the button call. It is this text that is returned when a form is read. This text will be what tells you which button is called so make it unique. Most of the convenience buttons (Submit, Cancel, Yes, etc) are all SimpleButtons. The two that are not are `FileBrowse` and `FolderBrowse`. They clearly do not close the form. Instead they bring up a file or folder browser dialog box. - -**Button Images** -Now this is an exciting feature not found in many simplified packages.... images on buttons! You can make a pretty spiffy user interface with the help of a few button images. - -Your button images need to be in PNG or GIF format. When you make a button with an image, set the button background to the same color as the background. There's a button color TRANSPARENT_BUTTON that you can set your button color to in order for it to blend into the background. Note that this value is currently the same as the color as the default system background on Windows. - -This example comes from the `Demo Media Player.py` example program. Because it's a non-blocking button, it's defined as `ReadFormButton`. You also put images on blocking buttons by using `SimpleButton`. - - - sg.ReadFormButton('Restart Song', button_color=sg.TRANSPARENT_BUTTON, - image_filename=image_restart, image_size=(50, 50), image_subsample=2, border_width=0) - -Three parameters are used for button images. - - image_filename - Filename. Can be a relative path - image_size - Size of image file in pixels - image_subsample - Amount to divide the size by. 2 means your image will be 1/2 the size. 3 means 1/3 - -Here's an example form made with button images. - -![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) - -You'll find the source code in the file Demo Media Player. Here is what the button calls look like to create media player form - - sg.ReadFormButton('Pause', button_color=sg.TRANSPARENT_BUTTON, - image_filename=image_pause, image_size=(50, 50), image_subsample=2, border_width=0) - -This is one you'll have to experiment with at this point. Not up for an exhaustive explanation. - - **Realtime Buttons** - - Normally buttons are considered "clicked" when the mouse button is let UP after a downward click on the button. What about times when you need to read the raw up/down button values. A classic example for this is a robotic remote control. Building a remote control using a GUI is easy enough. One button for each of the directions is a start. Perhaps something like this: - -![snap0135](https://user-images.githubusercontent.com/13696193/43440841-bcf8d184-9466-11e8-9f7b-30a1d5ce32d3.jpg) - -This form has 2 button types. There's the normal "Simple Button" (Quit) and 4 "Realtime Buttons". - -Here is the code to make, show and get results from this form: - - form = sg.FlexForm('Robotics Remote Control', auto_size_text=True) - - form_rows = [[sg.Text('Robotics Remote Control')], - [sg.T(' '*10), sg.RealtimeButton('Forward')], - [ sg.RealtimeButton('Left'), sg.T(' '*15), sg.RealtimeButton('Right')], - [sg.T(' '*10), sg.RealtimeButton('Reverse')], - [sg.T('')], - [sg.Quit(button_color=('black', 'orange'))] - ] - - form.LayoutAndRead(form_rows, non_blocking=True) - -Somewhere later in your code will be your main event loop. This is where you do your polling of devices, do input/output, etc. It's here that you will read your form's buttons. - - while (True): - # This is the code that reads and updates your window - button, values = form.ReadNonBlocking() - if button is not None: - sg.Print(button) - if button == 'Quit' or values is None: - break - time.sleep(.01) - -This loop will read button values and print them. When one of the Realtime buttons is clicked, the call to `form.ReadNonBlocking` will return a button name matching the name on the button that was depressed. It will continue to return values as long as the button remains depressed. Once released, the ReadNonBlocking will return None for buttons ules anutton was clicked. - -**File Types** -The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is - - FileTypes=(("ALL Files", "*.*"),) - -This code produces a form where the Browse button only shows files of type .TXT - - layout = [[sg.In() ,sg.FileBrowse(file_types=(("Text Files", "*.txt"),))]] - - ***The ENTER key*** - The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. - - --- -#### ProgressBar -The `ProgressBar` element is used to build custom Progress Bar forms. It is HIGHLY recommended that you use the functions that provide a complete progress meter solution for you. Progress Meters are not easy to work with because the forms have to be non-blocking and they are tricky to debug. - -The **easiest** way to get progress meters into your code is to use the `EasyProgessMeter` API. This consists of a pair of functions, `EasyProgessMeter` and `EasyProgressMeterCancel`. You can easily cancel any progress meter by calling it with the current value = max value. This will mark the meter as expired and close the window. -You've already seen EasyProgressMeter calls presented earlier in this readme. - - sg.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') - -The return value for `EasyProgressMeter` is: -`True` if meter updated correctly -`False` if user clicked the Cancel button, closed the form, or vale reached the max value. -**Customized Progress Bar** -If you want a bit more customization of your meter, then you can go up 1 level and use the calls to `ProgressMeter` and `ProgressMeterUpdate`. These APIs behave like an object we're all used to. First you create the `ProgressMeter` object, then you call the `Update` method to update it. - -You setup the progress meter by calling - - my_meter = ProgressMeter(title, - max_value, - *args, - orientantion=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, - button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), - border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) -Then to update the bar within your loop - - return_code = ProgressMeterUpdate(my_meter, - value, - *args): -Putting it all together you get this design pattern - - my_meter = sg.ProgressMeter('Meter Title', 100000, orentation='Vert') - - for i in range(0, 100000): - sg.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') - - -The final way of using a Progress Meter with PySimpleGUI is to build a custom form with a `ProgressBar` Element in the form. You will need to run your form as a non-blocking form. When you are ready to update your progress bar, you call the `UpdateBar` method for the `ProgressBar` element itself. - - -#### Output -The Output Element is a re-direction of Stdout. Anything "printed" will be displayed in this element. - - Output(scale=(None, None), - size=(None, None)) - -Here's a complete solution for a chat-window using an Async form with an Output Element - - import PySimpleGUI as sg - # Blocking form that doesn't close - def ChatBot(): - with sg.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: - layout = [[(sg.Text('This is where standard out is being routed', size=[40, 1]))], - [sg.Output(size=(80, 20))], - [sg.Multiline(size=(70, 5), enter_submits=True), sg.ReadFormButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0])), sg.SimpleButton('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]] - # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form - # if you call LayoutAndRead from here, then you will miss the first button click - form.Layout(layout) - # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # - while True: - button, value = form.Read() - if button == 'SEND': - print(value) - else: - break - - -## Tabbed Forms -Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format - - results = ShowTabbedForm('Title for the form', - (form,layout,'Tab 1 label'), - (form2,layout2, 'Tab 2 label'), ...) - -Each of the tabs of the form is in fact a form. The same steps are taken to create the form as before. A `FlexForm` is created, then rows are filled with Elements, and finally the form is shown. When calling `ShowTabbedForm`, each form is passed in as a tuple. The tuple has the format: `(the form, the rows, a string shown on the tab)` - -Results are returned as a list of lists. For each form you'll get a list that's in the same format as a normal form. A single tab's values would be: - - (button, (values)) - -Recall that values is a list as well. Multiple tabs in the form would return like this: - - ((button1, (values1)), (button2, (values2)) - - ## Colors ## -Starting in version 2.5 you can change the background colors for the window and the Elements. - -Your forms can go from this: -![snap0155](https://user-images.githubusercontent.com/13696193/43273879-a9fdc10a-90cb-11e8-8c20-4f6a244ebe2f.jpg) - - -to this... with one function call... - -![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) - - - -While you can do it on an element by element or form level basis, the easiest way, by far, is a call to `SetOptions`. - -Be aware that once you change these options they are changed for the rest of your program's execution. All of your forms will have that look and feel, until you change it to something else (which could be the system default colors. - -This call sets all of the different color options. - - SetOptions(background_color='#9FB8AD', - text_element_background_color='#9FB8AD', - element_background_color='#9FB8AD', - scrollbar_color=None, - input_elements_background_color='#F7F3EC', - progress_meter_color = ('green', 'blue') - button_color=('white','#475841')) - - - -## Global Settings -**Global Settings** -Let's have some fun customizing! Make PySimpleGUI look the way you want it to look. You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. - - SetOptions(icon=None - button_color=(None,None) - element_size=(None,None), - margins=(None,None), - element_padding=(None,None) - auto_size_text=None - auto_size_buttons=None - font=None - border_width=None - slider_border_width=None - slider_relief=None - slider_orientation=None - autoclose_time=None - message_box_line_width=None - progress_meter_border_depth=None - progress_meter_style=None - progress_meter_relief=None - progress_meter_color=None - progress_meter_size=None - text_justification=None - background_color=None - element_background_color=None - text_element_background_color=None - input_elements_background_color=None - scrollbar_color=None, text_color=None - debug_win_size=(None,None) - window_location=(None,None) - -Explanation of parameters - - icon - filename of icon used for taskbar and title bar - button_color - button color (foreground, background) - element_size - element size (width, height) in characters - margins - tkinter margins around outsize - element_padding - tkinter padding around each element - auto_size_text - autosize the elements to fit their text - auto_size_buttons - autosize the buttons to fit their text - font - font used for elements - border_width - amount of bezel or border around sunken or raised elements - slider_border_width - changes the way sliders look - slider_relief - changes the way sliders look - slider_orientation - changes orientation of slider - autoclose_time - time in seconds for autoclose boxes - message_box_line_width - number of characers in a line of text in message boxes - progress_meter_border_depth - amount of border around raised or lowered progress meters - progress_meter_style - style of progress meter as defined by tkinter - progress_meter_relief - relief style - progress_meter_color - color of the bar and background of progress meters - progress_meter_size - size in (characters, pixels) - background_color - Color of the main window's background - element_background_color - Background color of the elements - text_element_background_color - Text element background color - input_elements_background_color - Input fields background color - scrollbar_color - Color for scrollbars (may not always work) - text_color - Text element default text color - text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' - debug_win_size - size of the Print output window - window_location - location on the screen (x,y) of window's top left cornder - - -These settings apply to all forms `SetOptions`. The Row options and Element options will take precedence over these settings. Settings can be thought of as levels of settings with the Form-level being the highest and the Element-level the lowest. Thus the levels are: - - - Form level - - Row level - - Element level - -Each lower level overrides the settings of the higher level. Once settings have been changed, they remain changed for the duration of the program (unless changed again). - -## Asynchronous (Non-Blocking) Forms -So you want to be a wizard do ya? Well go boldly! While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. With asynchronous forms the form is shown, user input is read, but your code keeps right on chugging. YOUR responsibility is to call `PySimpleGUI.ReadNonBlocking` on a periodic basis. Once a second or more will produce a reasonably snappy GUI. - -When do you use a non-blocking form? A couple of examples are -* A media file player like an MP3 player -* A status dashboard that's periodically updated -* Progress Meters - when you want to make your own progress meters -* Output using print to a scrolled text element. Good for debugging. - -Word of warning... version 2.2, the currently released, and upcoming version 2.3 differ in the return code for the `ReadNonBlocking` call. Previously the function returned 2 values, except when the form is closed using the "X" which returned a single value of `None`. The *new* way is that `ReadNonBlocking` always returns 2 values. If the user closed the form with the "X" then the return values will be None, None. You will want to key off the second value to catch this case. -The proper code to check if the user has exited the form will be a polling-loop that looks something like this: - - while True: - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': - break - -We're going to build an app that does the latter. It's going to update our form with a running clock. - -The basic flow and functions you will be calling are: -Setup - - - form = FlexForm() - form_rows = ..... - form.LayoutAndRead(form_rows, non_blocking=True) - - -Periodic refresh - - form.ReadNonBlocking() -If you need to close the form - - form.CloseNonBlockingForm() - -Rather than the usual `form.LayoutAndRead()` call, we're manually adding the rows (doing the layout) and then showing the form. After the form is shown, you simply call `form.ReadNonBlocking()` every now and then. - -When you are ready to close the form (assuming the form wasn't closed by the user or a button click) you simply call `form.CloseNonBlockingForm()` - -**Example - Running timer that updates** -See the sample code on the GitHub named Demo Media Player for another example of Async Forms. We're going to make a form and update one of the elements of that form every .01 seconds. Here's the entire code to do that. - - - import PySimpleGUI as sg - import time - - # form that doesn't block - # Make a form, but don't use context manager - form = sg.FlexForm('Running Timer', auto_size_text=True) - # Create a text element that will be updated with status information on the GUI itself - output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) - # Create the rows - form_rows = [[sg.Text('Non-blocking GUI with updates')], - [output_element], - [sg.SimpleButton('Quit')]] - # Layout the rows of the form and perform a read. Indicate the form is non-blocking! - form.LayoutAndRead(form_rows, non_blocking=True) - - # - # Some place later in your code... - # You need to perform a ReadNonBlocking on your form every now and then or - # else it won't refresh - # - - for i in range(1, 1000): - output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': - break - time.sleep(.01) - else: - form.CloseNonBlockingForm() - - - -What we have here is the same sequence of function calls as in the description. Get a form, add rows to it, show the form, and then refresh it every now and then. - -The new thing in this example is the call use of the Update method for the Text Element. The first thing we do inside the loop is "update" the text element that we made earlier. This changes the value of the text field on the form. The new value will be displayed when `form.ReadNonBlocking()` is called. - -Note the `else` statement on the for loop. This is needed because we're about to exit the loop while the form is still open. The user has not closed the form using the X nor a button so it's up to the caller to close the form using `CloseNonBlockingForm`. - -That's it... this example follows the async design pattern well. - - - -## Sample Applications -Use the example programs as a starting basis for your GUI. Copy, paste, modify and run! The demo files are: - -`Demo Recipes.py` - Sample forms for all major form types and situations. This is the place to get your code template from. Includes asynchronous forms, etc. - -`Demo DisplayHash1and256.py` - Demonstrates using High Level API calls to get a filename - -`Demo DupliucateFileFinder.py` - Demonstrates High Level API to get a folder & Easy Progress Meter to show progress of the file scanning - -`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. If anyone wants to help me package this application up, I could use a hand. - -## Fun Stuff -Here are some things to try if you're bored or want to further customize - -**Debug Output** -Be sure and check out the EasyPrint (Print) function described in the high-level API section. Leave your code the way it is, route your stdout and stderror to a scrolling window. - -For a fun time, add these lines to the top of your script - - import PySimpleGUI as sg - print = sg.Print - -This will turn all of your print statements into prints that display in a window on your screen rather than to the terminal. - -**Look and Feel** -Dial in the look and feel that you like with the `SetOptions` function. You can change all of the defaults in one function call. One line of code to customize the entire GUI. - -**ObjToString** -Ever wanted to easily display an objects contents easily? Use ObjToString to get a nicely formatted recursive walk of your objects. -This statement: - - print(sg.ObjToSting(x)) - -And this was the output - - - abc = abc - attr12 = 12 - c = - b = - a = - attr1 = 1 - attr2 = 2 - attr3 = three - attr10 = 10 - attrx = x - -You'll quickly wonder how you ever coded without it. - ---- -# Known Issues -While not an "issue" this is a ***stern warning*** - -## **Do not attempt** to call `PySimpleGUI` from multiple threads! It's `tkinter` based and `tkinter` has issues with multiple threads - -**Progress Meters** - the visual graphic portion of the meter may be off. May return to the native tkinter progress meter solution in the future. Right now a "custom" progress meter is used. On the bright side, the statistics shown are extremely accurate and can tell you something about the performance of your code. - -**Async Forms** - these include the 'easy' forms (EasyProgressMeter and EasyPrint/Print). If you start overlapping having Async forms open with normal forms then things get a littler squirrelly. Still tracking down the issues and am making it more solid every day possible. You'll know there's an issue when you see blank form. - -**EasyPrint** - EasyPrint is a new feature that's pretty awesome. You print and the output goes to a window, with a scroll bar, that you can copy and paste from. Being a new feature, it's got some potential problems. There are known interaction problems with other GUI windows. For example, closing a Print window can also close other windows you have open. For now, don't close your debug print window until other windows are closed too. - -## Contributing - -A MikeTheWatchGuy production... entirely responsible for this code.... unless it causes you trouble in which case I'm not at all responsible. - -## Versions -|Version | Description | -|--|--| -| 1.0.9 | July 10, 2018 - Initial Release | -| 1.0.21 | July 13, 2018 - Readme updates | -| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case -| 2.1.1 | July 18, 2018 - Global settings exposed, fixes -| 2.2.0| July 20, 2018 - Image Elements, Print output -| 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. -| 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi -| 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. -| 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ -| 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting - - -### Release Notes -2.3 - Sliders, Listbox's and Image elements (oh my!) - -If using Progress Meters, avoid cancelling them when you have another window open. It could lead to future windows being blank. It's being worked on. - -New debug printing capability. `sg.Print` - -2.5 Discovered issue with scroll bar on `Output` elements. The bar will match size of ROW not the size of the element. Normally you never notice this due to where on a form the `Output` element goes. - -Listboxes are still without scrollwheels. The mouse can drag to see more items. The mouse scrollwheel will also scroll the list and will `page up` and `page down` keys. - -2.7 Is the "feature complete" release. Pretty much all features are done and in the code - - -### Upcoming -Make suggestions people! Future release features - -Columns. How multiple columns would be specified in the SDK interface are still being designed. - -Port to other graphic engines. Hook up the front-end interface to a backend other than tkinter. Qt, WxPython, etc. - - - -## Code Condition - - Make it run - Make it right - Make it fast - -It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor for PEP 8 compliance. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. - -While the internals to PySimpleGUI are a tad sketchy, the public interfaces into the SDK are more strictly defined and comply with PEP 8 for the most part. - -Please log bugs and suggestions in the GitHub! It will only make the code stronger and better in the end, a good thing for us all, right? - -## Design - -A moment about the design-spirit of `PySimpleGUI`. From the beginning, this package was meant to take advantage of Python's capabilities with the goal of programming ease. - -**Single File** -While not the best programming practice, the implementation resulted in a single file solution. Only one file is needed, PySimpleGUI.py. You can post this file, email it, and easily import it using one statement. - -**Functions as objects** -In Python, functions behave just like object. When you're placing a Text Element into your form, you may be sometimes calling a function and other times declaring an object. If you use the word Text, then you're getting an object. If you're using `Txt`, then you're calling a function that returns a `Text` object. - -**Lists** -It seemed quite natural to use Python's powerful list constructs when possible. The form is specified as a series of lists. Each "row" of the GUI is represented as a list of Elements. When the form read returns the results to the user, all of the results are presented as a single list. This makes reading a form's values super-simple to do in a single line of Python code. - - -## Authors -MikeTheWatchGuy - -## License - -GNU Lesser General Public License (LGPL 3) + - -## Acknowledgments - -* Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence -* [Fredrik Lundh](https://wiki.python.org/moin/FredrikLundh) for his work on `tkinter` - - -## How Do I -Finally, I must thank the fine folks at How Do I. -https://github.com/gleitz/howdoi -Their utility has forever changed the way and pace in which I can program. I urge you to try the HowDoI.py application here on GitHub. Trust me, **it's going to be worth the effort!** -Here are the steps to run that application - - Install howdoi: - pip install howdoi - Test your install: - python -m howdoi howdoi.py - To run it: - Python HowDoI.py - -The pip command is all there is to the setup. - -The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. -For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. -![snap0109](https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg) - -In the hands of a competent programmer, this tool is **amazing**. It's a must-try kind of program that has completely changed my programming process. I'm not afraid of asking for help! You just have to be smart about using what you find. - -The PySimpleGUI window that the results are shown in is an 'input' field which means you can copy and paste the results right into your code. \ No newline at end of file diff --git a/docs/readme.md b/docs/readme.md deleted file mode 100644 index f03d65375..000000000 --- a/docs/readme.md +++ /dev/null @@ -1,1506 +0,0 @@ - - -![pysimplegui_logo](https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png) - -[![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 -# PySimpleGUI - (Ver 2.7) - -Super-simple GUI to grasp... Powerfully customizable. - -Note - *Python3* is required to run PySimpleGUI. It takes advantage of some Python3 features that do not translate well into Python2. - -Looking to take your Python code from the world of command lines and into the convenience of a GUI? Have a Raspberry Pi with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK? Look no further, you've found your GUI package. - - import PySimpleGUI as sg - - sg.MsgBox('Hello From PySimpleGUI!', 'This is the shortest GUI program ever!') - - -![snap0136](https://user-images.githubusercontent.com/13696193/43162494-33095ece-8f59-11e8-86de-b6d8bcc5a52f.jpg) - - Build beautiful customized forms that fit your specific problem. Let PySimpleGUI solve your GUI problem while you solve the real problems. Do you really want to plod through the mountains of code required to program tkinter? - -![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) - -Perhaps you're looking for a way to interact with your Raspberry Pi in a more friendly way. The is the same form as above, except shown on a Pi. - -![raspberry pi](https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg) - - -In addition to a primary GUI, you can add a Progress Meter to your code with ONE LINE of code. Slide this into any of your `for` loops and get a nice meter like this: - - EasyProgressMeter('My meter title', current_value, max value) - - ![snap0177](https://user-images.githubusercontent.com/13696193/43658025-947973d2-9725-11e8-902f-e2d5effb6e3e.jpg) - -You can build an async media player GUI with custom buttons in 30 lines of code. - -![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) - -I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? - -There are a number of 'easy to use' Python GUIs, but they're **very** limiting. PySimpleGUI takes the best of packages like `EasyGUI`and `WxSimpleGUI` , both really handy but limited. The primary difference between these and PySimpleGUI is that in addition to getting the simple Message Boxes you also get the ability to make your own forms that are highly customizeable. Don't like the standard Message Box? Then make your own! - -Every call has optional parameters so that you can change the look and feel. Don't like the button color? It's easy to change by adding a button_color parameter to your widget. - -GUI Packages with more functionality, like QT and WxPython, require configuring and can take a ***week*** to get *reasonably familiar* with the interfaces. Clearly there needs to be a middle ground between forms with 1 or two input fields and a full-blown GUI. You'll be making your own custom forms with PySimpleGUI within minutes, even Async forms. - -With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. - -The `PySimpleGUI` package is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? - - Features of PySimpleGUI include: - Text - Single Line Input - Buttons including these types: - File Browse - Folder Browse - Non-closing return - Close form - Realtime - Checkboxes - Radio Buttons - Listbox - Slider - Icons - Multi-line Text Input - Scroll-able Output - Images - Progress Bar - Async/Non-Blocking Windows - Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling window - 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) - Single-Line-Of-Coide Proress Bar & Debug Print - Complete control of colors, look and feel - Button images - - -An example of many widgets used on a single form. A little further down you'll find the TWENTY lines of code required to create this complex form. Try it if you don't believe it. Start Python, copy and paste the code below into the >>> prompt and hit enter. This will pop up... - -![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) - -Here is the code that produced the above screenshot. - - import PySimpleGUI as sg - - with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: - layout = [ - [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [sg.Text('Here is some text.... and a place to enter text')], - [sg.InputText()], - [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], - [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], - [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', - scale=(2, 10))], - [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [sg.Text('_' * 100, size=(70, 1))], - [sg.Text('Choose Source and Destination Folders', size=(35, 1))], - [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], - [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), - sg.FolderBrowse()], - [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] - ] - - button, values = form.LayoutAndRead(layout) - - **A note on screen shots** -You will see a number of different styles of buttons, data entry fields, etc, in this readme. They were all made with the same SDK, the only difference is in the settings that are specified on a per-element, row, form, or global basis. One setting in particular, border_width, can make a big difference on the look of the form. Some of the screenshots had a border_width of 6, others a value of 1. - - ---- -### Design Goals -> Copy, Paste, Run. - -`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the code to visually match what's on the screen. - - > Be Pythonic - - Be Pythonic... Attempted to use language constructs in a natural way and to exploit some of Python's interesting features. Python's lists and optional parameters make PySimpleGUI work. - - Forms are represented as Python lists. - - A form is a list of rows - - A row is a list of elements -- Return values are a list of button presses and input values. - -It's stunning that after so many years Python still hasn't put forth a GUI framework that truly fits the language's basic data structures, especially lists. It's hard to argue with the success to be had in quickly building GUI applications using this package's syntax. - - ----- -## Getting Started with PySimpleGUI - -### Installing - - pip install PySimpleGUI - or -Simply download the file - PySimpleGUI.py and import it into your code - - -### Prerequisites - -Python 3 -tkinter - -Runs on all Python platforms that have tkinter running on them. Thoroughly tested on Windows. Runs on Windows, Mac, Linux, Raspberry Pi. Even runs on `pypy3`. - -### Using - -To use in your code, simply import.... - `import PySimpleGUI as sg` - -Then use either "high level" API calls or build your own forms. - - sg.MsgBox('This is my first message box') - -![snap0178](https://user-images.githubusercontent.com/13696193/43658024-945c83f8-9725-11e8-8ddd-0bbe67a9fc5d.jpg) - - -Yes, it's just that easy to have a window appear on the screen using Python. With PySimpleGUI, making a custom form appear isn't much more difficult. The goal is to get you running on your GUI within ***minutes***, not hours nor days. - ---- -## APIs - -PySimpleGUI can be broken down into 2 types of API's: - * High Level single call functions - * Custom form functions - - -### Python Language Features - - There are a couple of Python language features that PySimpleGUI utilizes heavily that should be understood first... - * Variable number of arguments to a function call - * Optional parameters to a function call - -#### Variable Number of Arguments - - The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. - - sg.MsgBox('Variable number of parameters example', var1, var2, "etc") - -Each new item begins on a new line in the Message Box - - ![snap0179](https://user-images.githubusercontent.com/13696193/43658129-f6ca49c6-9725-11e8-9317-1f77443eb04a.jpg) - - - -#### Optional Parameters to a Function Call - -This feature of the Python language is utilized ***heavily*** as a method of customizing forms and form Elements. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. - -Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't *have* to be specified on each and every call. - - def MsgBox(*args, - button_color=None, - button_type=MSG_BOX_OK, - auto_close=False, - auto_close_duration=None, - icon=DEFAULT_WINDOW_ICON, - line_width=MESSAGE_BOX_LINE_WIDTH, - font=None): - -If the caller wanted to change the button color to be black on yellow, the call would look something like this: - - sg.MsgBox('This box has a custom button color', button_color=('black', 'yellow')) - - -![snap0180](https://user-images.githubusercontent.com/13696193/43658171-13a72bfe-9726-11e8-8c7a-0a46e46fb202.jpg) - - ---- - -### High Level API Calls - -The classic "input a value, print result" example. -Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. -This code prompts user to input a line of text and then displays that text in a messages box: - - - import PySimpleGUI as sg - - rc = sg.GetTextBox('Title', 'Please input something') - sg.MsgBox('Results', 'The value returned from GetTextBox', rc) - - - ![snap0181](https://user-images.githubusercontent.com/13696193/43658233-48cc7794-9726-11e8-8582-8844280c344e.jpg) - -![snap0182](https://user-images.githubusercontent.com/13696193/43658232-48aaad4e-9726-11e8-95f5-aa9b9213bb77.jpg) - - -#### Message Boxes -In addition to MsgBox, you'll find a several API calls that are shortcuts to common messages boxes. You can achieve similar results by calling MsgBox with the correct parameters. - -The differences tend to be the number and types of buttons. Here are the calls and the windows that are created. - - import PySimpleGUI as sg - - `sg.MsgBoxOK('This is an OK MsgBox')` - - ![ok](https://user-images.githubusercontent.com/13696193/43667331-723ac666-9745-11e8-8666-230c35a6afd6.jpg) - - - sg.MsgBoxOKCancel('This is an OK Cancel MsgBox') - -![ok cancel 2](https://user-images.githubusercontent.com/13696193/43667330-71d5bea6-9745-11e8-8944-b3900853aa62.jpg) - - sg.MsgBoxCancel('This is a Cancel MsgBox') - -![cancel](https://user-images.githubusercontent.com/13696193/43667329-71a007de-9745-11e8-974b-d028f68798e7.jpg) - - sg.MsgBoxYesNo('This is a Yes No MsgBox') - -![yesno](https://user-images.githubusercontent.com/13696193/43667327-717ff7dc-9745-11e8-9dce-52c305a85101.jpg) - - - sg.MsgBoxError('This is an error MsgBox') - -![error msgbox](https://user-images.githubusercontent.com/13696193/43667326-71621712-9745-11e8-87c4-56e2ab500f8e.jpg) - - sg.MsgBoxAutoClose('This is an autoclose MsgBox') - -![autoclose](https://user-images.githubusercontent.com/13696193/43667325-714997dc-9745-11e8-836a-7185dc80329f.jpg) - - sg.ScrolledTextBox(my_text, height=10) - -![scrolledtextbox 2](https://user-images.githubusercontent.com/13696193/43667324-712aa0d4-9745-11e8-83a9-a0d0570d0865.jpg) - - -Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing your printed text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. Your code could contain a line like: - - sprint(f'My variables values include x={x}', f'y={y}') - -This becomes a debug print of sorts that will route to a scrolled window. - -See also the `EasyPrint` and `Print` functions. - -#### High Level User Input - -There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. If you need only 1 value, then perhaps one of these high level functions will work. - - GetTextBox - - GetFileBox - - GetFolderBox - - `submit_clicked, value = sg.GetTextBox('Title', 'Please enter anything')` - -![gettextbox 2](https://user-images.githubusercontent.com/13696193/43667510-355b23a2-9746-11e8-9f1e-91c0dd0f4ed8.jpg) - - submit_clicked, value = sg.GetFileBox('Title', 'Choose a file') - -![getfilebox 2](https://user-images.githubusercontent.com/13696193/43667535-5821fc94-9746-11e8-95c3-82395099e994.jpg) - - submit_clicked, value = sg.GetPathBox('Title', 'Choose a folder') - -![getpathbox](https://user-images.githubusercontent.com/13696193/43667556-79874c22-9746-11e8-80f2-8262d32802c2.jpg) - - -#### Progress Meter! -We all have loops in our code. 'Isn't it joyful waiting, watching a counter scrolling past in a text window? How about one line of code to get a progress meter, that contains statistics about your code? - - - EasyProgressMeter(title, - current_value, - max_value, - *args, - orientation=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, - button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), - border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): - -Here's the one-line Progress Meter in action! - - for i in range(1,10000): - sg.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') - -That line of code resulted in this window popping up and updating. - -![preogress meter](https://user-images.githubusercontent.com/13696193/43667625-d47da702-9746-11e8-91e6-e5177883abae.jpg) - -A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. -With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. - -***Be sure and add one to your loop counter*** so that your counter goes from 1 to the max value. If you do not add one, your counter will never hit the max value. Instead it will go from 0 to max-1. - -#### Debug Output -Another call in the 'Easy' families of APIs is `EasyPrint`. It will output to a debug window. If the debug window isn't open, then the first call will open it. No need to do anything but stick a 'print' call in your code. You can even replace your 'print' calls with calls to EasyPrint by simply sticking the statement - - print = sg.EasyPrint - -at the top of your code. -There are a number of names for the same EasyPrint function. `Print` is one of the better ones to use as it's easy to remember. It is simply `print` with a capital P. - - import PySimpleGUI as sg - - for i in range(100): - sg.Print(i) - -![snap0125](https://user-images.githubusercontent.com/13696193/43114979-a696189e-8ecf-11e8-83c7-473fcf0ccc66.jpg) -Or if you didn't want to change your code: - - import PySimpleGUI as sg - - print=sg.Print - for i in range(100): - print(i) - -Just like the standard print call, `EasyPrint` supports the `sep` and `end` keyword arguments. Other names that can be used to call `EasyPrint` include Print, `eprint`, If you want to close the window, call the function `EasyPrintClose`. - -A word of caution. There are known problems when multiple PySimpleGUI windows are opened, particularly if the user closes them in an unusual way. Not a reason to stay away from using it. Just something to keep in mind if you encounter a problem. - -You can change the size of the debug window using the `SetOptions` call with the `debug_win_size` parameter. - ---- -# Custom Form API Calls (Your First Form) - -This is the FUN part of the programming of this GUI. In order to really get the most out of the API, you should be using an IDE that supports auto complete or will show you the definition of the function. This will make customizing go smoother. - -This first section on custom forms is for your typical, blocking, non-persistant form. By this I mean, when you "show" the form, the function will not return until the user has clicked a button or closed the window. When this happens, the form's window will be automatically closed. - -Two other types of forms exist. -1. Persistent form - rather than closing on button clicks, the show form function returns and the form continues to be visible. This is good for applications like a chat window. -2. Asynchronous form - the trickiest of the lot. Great care must be exercised. Examples are an MP3 player or status dashboard. Async forms are updated (refreshed) on a periodic basis. - -It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. Let's start with a basic Browse for a file and do something with it. -# Copy these design patterns! -## Pattern 1 - With Context Manager - - - with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: - form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], - [sg.InputText(), sg.FileBrowse()], - [sg.Submit(), sg.Cancel()]] - button, (source_filename,) = form.LayoutAndRead(form_rows) - -## Pattern 2 - No Context Manager - - - form = sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) - form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], - [sg.InputText(), sg.FileBrowse()], - [sg.Submit(), sg.Cancel()]] - button, (source_filename,) = form.LayoutAndRead(form_rows) - - - -These 2 design patters both produce this custom form: - -![snap0134](https://user-images.githubusercontent.com/13696193/43162410-e7775466-8f58-11e8-8d6a-da4772c00dd8.jpg) - -It's important to use the "with" context manager so that resources are freed as quickly as possible, using the currently executing thread. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. - -The second design pattern is not context manager based. If you are struggling with an unknown error, try modifying the code to run without a context manager. To do so, you simple remove the with, stick the form on the front of that statement, and un-indent the with-block code. - -You will use these design patterns or code templates for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. This is the most basic / normal of the design patterns. - -### How GUI Programming in Python Should Look - -GUI programming in Python is a mess. tkinter kinda sucks. Why is Python such a great teaching language and yet no GUI framework exists that lends itself to the basic building blocks of Python, the list? - -The key to custom forms in PySimpleGUI is to view forms as ROWS of Widgets (Elements). Each row is specified as a list of these widgets. Put the rows together and you've got a form. - -Let's look at this one. - - -![snap0131](https://user-images.githubusercontent.com/13696193/43417007-df6d8408-9407-11e8-9986-30f0415f08a5.jpg) - -Let's agree the form has 4 rows. - -The first row only has **text** that reads `Rename files or folders` - -The second row has 3 elements in it. First the **text** `Source for Folders`, then an **input** field, then a **browse** button. - -Now let's look at how those 2 rows and the other two row from Python code: - - layout = [[sg.Text('Rename files or folders')], - [sg.Text('Source for Folders', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], - [sg.Text('Source for Files ', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], - [sg.Submit(), sg.Cancel()]] - -See how the source code mirrors the layout? You simply make lists for each row, then submit that table to PySimpleGUI to show and get values from. - -And what about those return values? Most people simply want to show a form, get the input values and do something with them. So why break up the code into button callbacks, etc, when I simply want my form's input values to be given to me. - -The same "row" concept applies to return values. The form is scanned from top to bottom, left to right. Each field that's an input field will occupy a spot in the return values. - -In our example form, there are 2 fields, so the return values from this form will be a list with 2 values in it. - - button, (folder_path, file_path) = form.LayoutAndRead(layout) - -In the statement that shows and reads the form, the two input fields are directly assigned to the caller's variables `folder_path` and `file_path`, ready to use. No parsing no callbacks. - -Isn't this what almost every Python programmer looking for a GUI wants?? Something easy to work with to get the values and move on to the rest of the program, where the real action is taking place. Why write pages of tkinter code when the same layout can be achieved with PySimpleGUI in 3 or 4 lines of code. 4 lines or 40? I chose 4. - - -### Laying out your form -Your form is a 2 dimensional list in Python. The first dimension are rows, the second is a list of Elements for each row. The first thing you want to do is layout your form on paper. - - layout = [ [row 1], - [row 2], - [row 3] ] - -Simple enough... a list of lists. -A row is a list of Elements. For example this could be a row with a couple of elements on it. - - [ Input, Button] - -Turning back to our example. This GUI roughly looks like this: - - layout = [ [Text], - [InputText, FileBrowse] - [Submit, Cancel] ] - - Now let's put it all together into an entire program. - - -### Line by line explanation - -Going through each line of code in the above form will help explain how to use this design patter. Copy, modify and run it! - - with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: -This creates a new form, storing it in the variable `form`. - - form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], -The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. - - [sg.InputText(), sg.FileBrowse()], -Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. - - [sg.Submit(), sg.Cancel()]] - -The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its value to the caller. - - button, (source_filename, ) = form.LayoutAndRead(form_rows) -This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field. The result of the form is stored directly into the variable we wish to work with. - - -## Return values - - Return information from FlexForm, SG's primary form builder interface, is in this format: - - button, (value1, value2, ...) - -Each of the Elements that are Input Elements will have a value in the list of return values. You can unpack your GUI directly into the variables you want to use. - - button, (filename, folder1, folder2, should_overwrite) = form.LayoutAndRead(form_rows) - - Or, you can unpack the return results separately. - - button, values = form.LayoutAndRead(form_rows) - filename, folder1, folder2, should_overwrite = values - -If you have a SINGLE value being returned, it is written this way: - - button, (value1,) = form.LayoutAndRead(form_rows) - - - Another way of parsing the return values is to store the list of values into a variable representing the list of values. - - button, value_list = form.LayoutAndRead(form_rows) - value1 = value_list[0] - value2 = value_list[1] - ... - ---- -## All Widgets / Elements -This code utilizes as many of the elements in one form as possible. - - with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: - layout = [ - [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], - [sg.Text('Here is some text.... and a place to enter text')], - [sg.InputText()], - [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], - [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], - [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', - scale=(2, 10))], - [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), - sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], - [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), - sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], - [sg.Text('_' * 100, size=(70, 1))], - [sg.Text('Choose Source and Destination Folders', size=(35, 1))], - [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], - [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), - sg.FolderBrowse()], - [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] - ] - - button, values = form.LayoutAndRead(layout) - -This is a somewhat complex form with quite a bit of custom sizing to make things line up well. This is code you only have to write once. When looking at the code, remember that what you're seeing is a list of lists. Each row contains a list of Graphical Elements that are used to create the form. - -![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) - -Clicking the Submit button caused the form call to return. The call to MsgBox resulted in this dialog box. -![results 2](https://user-images.githubusercontent.com/13696193/43097502-44e3ed32-8e8a-11e8-9a51-2b8af0b1a682.jpg) - - -**`Note, button value can be None`**. The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. - -You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. - ---- -# Building Custom Forms -You will find it much easier to write code using PySimpleGUI if you use an IDE such as PyCharm. The features that show you documentation about the API call you are making will help you determine which settings you want to change, if any. In PyCharm, two commands are particularly helpful. - - Control-Q (when cursor is on function name) brings up a box with the function definition - Control-P (when cursor inside function call "()") shows a list of parameters and their default values - -## Synchronous Forms -The most common use of PySimpleGUI is to display and collect information from the user. The most straightforward way to do this is using a "blocking" GUI call. Execution is "blocked" while waiting for the user to close the GUI form/dialog box. -You've already seen a number of examples above that use blocking forms. Anytime you see a context manager used (see the `with` statement) it's most likely a blocking form. You can examine the show calls to be sure. If the form is a non-blocking form, it must indicate that in the call to `form.show`. - -NON-BLOCKING form call: - - form.Show(non_blocking=True) - -### Beginning a Form -The first step is to create the form object using the desired form customization. - - with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: - -This is the definition of the FlexForm object: - - def FlexForm(title, - default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), - auto_size_text=None, - auto_size_buttons=None, - scale=(None, None), - location=(None, None), - button_color=None,Font=None, - progress_bar_color=(None,None), - is_tabbed_form=False, - border_depth=None, - auto_close=False, - auto_close_duration=DEFAULT_AUTOCLOSE_TIME, - icon=DEFAULT_WINDOW_ICON): - -Parameter Descriptions. You will find these same parameters specified for each `Element` and some of them in `Row` specifications. The `Element` specified value will take precedence over the `Row` and `Form` values. - - default_element_size - Size of elements in form in characters (width, height) - auto_size_text - Bool. True if elements should size themselves according to contents - auto_size_buttons - Bool. True if button elements should size themselves according to their text label - scale - Set size of element to be a multiple of the Element size - location - Location to place window in pixels - button_color - Default color for buttons (foreground, background). Can be text or hex - progress_bar_color - Foreground and background colors for progress bars - is_tabbed_form - Bool. If True then form is a tabbed form - border_depth - Amount of 'bezel' to put on input boxes, buttons, etc. - auto_close - Bool. If True form will autoclose - auto_close_duration - Duration in seconds before form closes - icon - .ICO file that will appear on the Task Bar and end of Title Bar - - -#### Sizes -Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. - -The default Element size for PySimpleGUI is `(45,1)`. - -Sizes can be set at the element level, or in this case, the size variables apply to all elements in the form. Setting `size=(20,1)` in the form creation call will set all elements in the form to that size. - -In addition to `size` there is a `scale` option. `scale` will take the Element's size and scale it up or down depending on the scale value. `scale=(1,1)` doesn't change the Element's size. `scale=(2,1)` will set the Element's size to be twice as wide as the size setting. - -There are a couple of widgets where one of the size values is in pixels rather than characters. This is true for Progress Meters and Sliders. The second parameter is the 'height' in pixels. - -#### FlexForm - form-level variables overview -A summary of the variables that can be changed when a FlexForm is created - - default_element_size - set default size for all elements in the form - auto_size_text- true/false autosizing turned on / off - scale - set scale value for all elements - button_color- default button color (foreground, background) - font - font name and size for all text items - progress_bar_color - progress bar colors - is_tabbed_form - true/false indicates form is a tabbed or normal form - border_depth - style setting for buttons, input fields - auto_close - true/false indicates if form will automatically close - auto_close_duration - how long in seconds before closing form - icon - filename for icon that's displayed on the window on taskbar - - -## Elements -"Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. - - Text - Single Line Input - Buttons including these types: - File Browse - Folder Browse - Non-closing return - Close form - Realtime - Checkboxes - Radio Buttons - Listbox - Slider - Multi-line Text Input - Scroll-able Output - Progress Bar - Async/Non-Blocking Windows - Tabbed forms - Persistent Windows - Redirect Python Output/Errors to scrolling Window - "Higher level" APIs (e.g. MessageBox, YesNobox, ...) - - -### Output Elements -Building a form is simply making lists of Elements. Each list is a row in the overall GUI dialog box. The definition looks something like this: - - layout = [ [row 1 element, row 1 element], - [row 2 element, row 2 element, row 2 element] ] -The code is a crude representation of the GUI, laid out in text. -#### Text Element - - layout = [[sg.Text('This is what a Text Element looks like')]] - - - ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) - - -The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. - - Text(Text, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None, - text_color=None, - justification=None) -. - - Text - The text that's displayed - size - Element's size - auto_size_text - Bool. Change width to match size of text - font - Font name and size to use - text_color - text color - justification - Justification for the text. String - 'left', 'right', 'center' - -Some commonly used elements have 'shorthand' versions of the functions to make the code more compact. The functions `T` and `Txt` are the same as calling `Text`. - -**Fonts** in PySimpleGUI are always in this format: - - (font_name, point_size) - -The default font setting is - - ("Helvetica", 10) - -**Color** in PySimpleGUI are always in this format: - - (foreground, background) - -The values foreground and background can be the color names or the hex value formatted as a string: - - "#RRGGBB" - -**auto_size_text** -A `True` value for `auto_size_text`, when placed on any Element, indicates that the width of the Element should be shrunk do the width of the text. This is particularly useful with `Buttons` as fixed-width buttons are somewhat crude looking. The default value is `False`. You will often see this setting on FlexForm definitions. - -**Shorthand functions** -The shorthand functions for `Text` are `Txt` and `T` - - -#### Multiline Text Element - - layout = [[sg.Multiline('This is what a Multi-line Text Element looks like', size=(45,5))]] -![multiline text](https://user-images.githubusercontent.com/13696193/42670464-0824c754-8629-11e8-9741-6ed08f924618.jpg) -This Element doubles as both an input and output Element. The `DefaultText` optional parameter is used to indicate what to output to the window. - - Multiline(default_text='', - enter_submits = False, - scale=(None, None), - size=(None, None), - auto_size_text=None) -. - - default_text - Text to display in the text box - enter_submits - Bool. If True, pressing Enter key submits form - scale - Element's scale - size - Element's size - auto_size_text - Bool. Change width to match size of text - -#### Output Element -Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. More on this later. - - form.AddRow(gg.Output(size=(100,20))) - -![output element](https://user-images.githubusercontent.com/13696193/42704820-5446959c-869f-11e8-849e-047ea280387a.jpg) - - Output(scale=(None, None), - size=(None, None)) -. - - scale - How much to scale size of element - size - Size of element (width, height) in characters - -### Input Elements - These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. - -#### Text Input Element - - layout = [[sg.InputText('Default text')]] -![inputtext](https://user-images.githubusercontent.com/13696193/42693515-610a716c-867d-11e8-9a00-7e7fcf771230.jpg) - - def InputText(default_text = '', - scale=(None, None), - size=(None, None), - auto_size_text=None, - password_char='') -. - - default_text - Text initially shown in the input box - scale - Amount size is scaled by - size - (width, height) of element in characters - auto_size_text- Bool. True is element should be sized to fit text - password_char - Character that will be used to replace each entered character. Setting to a value indicates this field is a password entry field - -Shorthand functions that are equivalent to `InputText` are `Input` and `In` - - -#### Combo Element -Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. - - layout = [[sg.InputCombo(['choice 1', 'choice 2'])]] - -![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) - - InputCombo(values, - scale=(None, None), - size=(None, None), - auto_size_text=None) -. - - values - Choices to be displayed. List of strings - scale - Amount to scale size by - size - (width, height) of element in characters - auto_size_text - Bool. True if size should fit the text length - -#### Listbox Element -The standard listbox like you'll find in most GUIs. Note that the return values from this element will be a ***list of results, not a single result***. This is because the user can select more than 1 item from the list (if you set the right mode). - - layout = [[sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6))]] - -![snap0130](https://user-images.githubusercontent.com/13696193/43115859-2fbf0646-8ed3-11e8-9979-bbee8eaebfab.jpg) - - - Listbox(values, - select_mode=None, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None) -. - - values - Choices to be displayed. List of strings - select_mode - Defines how to list is to operate. - Choices include constants or strings: - Constants version: - LISTBOX_SELECT_MODE_BROWSE - LISTBOX_SELECT_MODE_EXTENDED - LISTBOX_SELECT_MODE_MULTIPLE - LISTBOX_SELECT_MODE_SINGLE - the default - Strings version: - 'browse' - 'extended' - 'multiple' - 'single' - scale - Amount to scale size by - size - (width, height) of element in characters - auto_size_text - Bool. True if size should fit the text length - -The `select_mode` option can be a string or a constant value defined as a variable. Generally speaking strings are used for these kinds of options. - -#### Slider Element -Sliders have a couple of slider-specific settings as well as appearance settings. Examples include the `orientation` and `range` settings. - - layout = [[sg.Slider(range=(1,500), default_value=222, size=(20,15), orientation='horizontal', font=('Helvetica', 12))]] - -![snap0129](https://user-images.githubusercontent.com/13696193/43115741-e1cb52c8-8ed2-11e8-80bb-0e99ae846ec1.jpg) - - Slider(range=(None,None), - default_value=None, - orientation=None, - border_width=None, - relief=None, - scale=(None, None), - size=(None, None), - font=None): -. - - range - (min, max) slider's range - default_value - default setting (within range) - orientation - 'horizontal' or 'vertical' ('h' or 'v' work) - border_width - how deep the widget looks - relief - relief style. Values are same as progress meter relief values. Can be a constant or a string: - RELIEF_RAISED= 'raised' - RELIEF_SUNKEN= 'sunken' - RELIEF_FLAT= 'flat' - RELIEF_RIDGE= 'ridge' - RELIEF_GROOVE= 'groove' - RELIEF_SOLID = 'solid' - scale - Amount to scale size by - size - (width, height) of element in characters - auto_size_text - Bool. True if size should fit the text - -#### Radio Button Element -Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. - - layout = [[sg.Radio('My first Radio!', "RADIO1", default=True), sg.Radio('My second radio!', "RADIO1")]] - -![radio element](https://user-images.githubusercontent.com/13696193/42705705-327b4b6c-86a2-11e8-81a7-740e57646ba8.jpg) - - Radio(text, - group_id, - default=False, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None) - -. - - text - Text to display next to button - group_id - Groups together multiple Radio Buttons. Can be any value - default - Bool. Initial state - scale - Amount to scale size of element - size- (width, height) size of element in characters - auto_size_text - Bool. True if should size width to fit text - font - Font type and size for text display - - -#### Checkbox Element -Checkbox elements are like Radio Button elements. They return a bool indicating whether or not they are checked. - - layout = [[sg.Checkbox('My first Checkbox!', default=True), sg.Checkbox('My second Checkbox!')]] - -![checkbox element](https://user-images.githubusercontent.com/13696193/42717015-655d73d2-86cc-11e8-9c69-3c810f48e578.jpg) - - - Checkbox(text, - default=False, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None): -. - - text - Text to display next to checkbox - default- Bool. Initial state - scale - Amount to scale size of element - size - (width, height) size of element in characters - auto_size_text- Bool. True if should size width to fit text - font- Font type and size for text display - - -#### Spin Element -An up/down spinner control. The valid values are passed in as a list. - - layout = [[sg.Spin([i for i in range(1,11)], initial_value=1), sg.Text('Volume level')]] - -![spin element](https://user-images.githubusercontent.com/13696193/42717231-8ddb51d4-86cd-11e8-827a-75f2237477fa.jpg) - - Spin(values, - intiial_value=None, - scale=(None, None), - size=(None, None), - auto_size_text=None, - font=None) -. - - values - List of valid values - initial_value - String with initial value - scale - Amount to scale size of element - size - (width, height) size of element in characters - auto_size_text - Bool. True if should size width to fit text - font - Font type and size for text display - -#### Button Element -Buttons are the most important element of all! They cause the majority of the action to happen. After all, it's a button press that will get you out of a form, whether it but Submit or Cancel, one way or another a button is involved in all forms. The only exception is to this is when the user closes the window using the "X" in the upper corner which means no button was involved. - -The Types of buttons include: -* Folder Browse -* File Browse -* Close Form -* Read Form -* Realtime - - - Close Form - Normal buttons like Submit, Cancel, Yes, No, etc, are "Close Form" buttons. They cause the input values to be read and then the form is closed, returning the values to the caller. - -Folder Browse - When clicked a folder browse dialog box is opened. The results of the Folder Browse dialog box are written into one of the input fields of the form. - -File Browse - Same as the Folder Browse except rather than choosing a folder, a single file is chosen. - -Read Form - This is an async form button that will read a snapshot of all of the input fields, but does not close the form after it's clicked. - -Realtime - This is another async form button. Normal button clicks occur after a button's click is released. Realtime buttons report a click the entire time the button is held down. - -While it's possible to build forms using the Button Element directly, you should never need to do that. There are pre-made buttons and shortcuts that will make life much easier. The most basic Button element call to use is `SimpleButton` - - SimpleButton(text, - scale=(None, None), - size=(None, None), - auto_size_button=None, - button_color=None, - font=None) - -Pre-made buttons include: - - OK - Ok - Submit - Cancel - Yes - No - FileBrowse - FolderBrowse -. - layout = [[sg.OK(), sg.Cancel()]] - -![ok cancel](https://user-images.githubusercontent.com/13696193/42717733-1803f584-86d1-11e8-9223-36b782971b9f.jpg) - -The FileBrowse and FolderBrowse buttons both fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. - -The default value for `Target` is `(ThisRow, -1)`. ThisRow is a special value that tells the GUI to use the same row as the button. The Y-value of -1 means the field one value to the left of the button. For a File or Folder Browse button, the field that it fills are generally to the left of the button is most cases. - -Let's examine this form as an example: - -![button target example](https://user-images.githubusercontent.com/13696193/42718075-b4dcb61e-86d3-11e8-904c-d709dd364108.jpg) - -The `InputText` element is located at (1,0)... row 1, column 0. The `Browse` button is located at position (2,0). The Target for the button could be any of these values: - - Target = (1,0) - Target = (-1,0) -The code for the entire form could be: - - layout = [[sg.T('Source Folder')], - [sg.In()], - [sg.FolderBrowse(Target=(-1,0)), sg.OK()]] - -**Custom Buttons** -Not all buttons are created equal. A button that closes a form is different that a button that returns from the form without closing it. If you want to define your own button, you will generally do this with the Button Element `SimpleButton`, which closes the form when clicked. - -layout = [[sg.SimpleButton('My Button')]] - -![singlebutton](https://user-images.githubusercontent.com/13696193/42718281-9453deca-86d5-11e8-83c7-4b6d33720858.jpg) - -All buttons can have their text changed by changing the `button_text` variable in the button call. It is this text that is returned when a form is read. This text will be what tells you which button is called so make it unique. Most of the convenience buttons (Submit, Cancel, Yes, etc) are all SimpleButtons. The two that are not are `FileBrowse` and `FolderBrowse`. They clearly do not close the form. Instead they bring up a file or folder browser dialog box. - -**Button Images** -Now this is an exciting feature not found in many simplified packages.... images on buttons! You can make a pretty spiffy user interface with the help of a few button images. - -Your button images need to be in PNG or GIF format. When you make a button with an image, set the button background to the same color as the background. There's a button color TRANSPARENT_BUTTON that you can set your button color to in order for it to blend into the background. Note that this value is currently the same as the color as the default system background on Windows. - -This example comes from the `Demo Media Player.py` example program. Because it's a non-blocking button, it's defined as `ReadFormButton`. You also put images on blocking buttons by using `SimpleButton`. - - - sg.ReadFormButton('Restart Song', button_color=sg.TRANSPARENT_BUTTON, - image_filename=image_restart, image_size=(50, 50), image_subsample=2, border_width=0) - -Three parameters are used for button images. - - image_filename - Filename. Can be a relative path - image_size - Size of image file in pixels - image_subsample - Amount to divide the size by. 2 means your image will be 1/2 the size. 3 means 1/3 - -Here's an example form made with button images. - -![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) - -You'll find the source code in the file Demo Media Player. Here is what the button calls look like to create media player form - - sg.ReadFormButton('Pause', button_color=sg.TRANSPARENT_BUTTON, - image_filename=image_pause, image_size=(50, 50), image_subsample=2, border_width=0) - -This is one you'll have to experiment with at this point. Not up for an exhaustive explanation. - - **Realtime Buttons** - - Normally buttons are considered "clicked" when the mouse button is let UP after a downward click on the button. What about times when you need to read the raw up/down button values. A classic example for this is a robotic remote control. Building a remote control using a GUI is easy enough. One button for each of the directions is a start. Perhaps something like this: - -![snap0135](https://user-images.githubusercontent.com/13696193/43440841-bcf8d184-9466-11e8-9f7b-30a1d5ce32d3.jpg) - -This form has 2 button types. There's the normal "Simple Button" (Quit) and 4 "Realtime Buttons". - -Here is the code to make, show and get results from this form: - - form = sg.FlexForm('Robotics Remote Control', auto_size_text=True) - - form_rows = [[sg.Text('Robotics Remote Control')], - [sg.T(' '*10), sg.RealtimeButton('Forward')], - [ sg.RealtimeButton('Left'), sg.T(' '*15), sg.RealtimeButton('Right')], - [sg.T(' '*10), sg.RealtimeButton('Reverse')], - [sg.T('')], - [sg.Quit(button_color=('black', 'orange'))] - ] - - form.LayoutAndRead(form_rows, non_blocking=True) - -Somewhere later in your code will be your main event loop. This is where you do your polling of devices, do input/output, etc. It's here that you will read your form's buttons. - - while (True): - # This is the code that reads and updates your window - button, values = form.ReadNonBlocking() - if button is not None: - sg.Print(button) - if button == 'Quit' or values is None: - break - time.sleep(.01) - -This loop will read button values and print them. When one of the Realtime buttons is clicked, the call to `form.ReadNonBlocking` will return a button name matching the name on the button that was depressed. It will continue to return values as long as the button remains depressed. Once released, the ReadNonBlocking will return None for buttons ules anutton was clicked. - -**File Types** -The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is - - FileTypes=(("ALL Files", "*.*"),) - -This code produces a form where the Browse button only shows files of type .TXT - - layout = [[sg.In() ,sg.FileBrowse(file_types=(("Text Files", "*.txt"),))]] - - ***The ENTER key*** - The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. - - --- -#### ProgressBar -The `ProgressBar` element is used to build custom Progress Bar forms. It is HIGHLY recommended that you use the functions that provide a complete progress meter solution for you. Progress Meters are not easy to work with because the forms have to be non-blocking and they are tricky to debug. - -The **easiest** way to get progress meters into your code is to use the `EasyProgessMeter` API. This consists of a pair of functions, `EasyProgessMeter` and `EasyProgressMeterCancel`. You can easily cancel any progress meter by calling it with the current value = max value. This will mark the meter as expired and close the window. -You've already seen EasyProgressMeter calls presented earlier in this readme. - - sg.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') - -The return value for `EasyProgressMeter` is: -`True` if meter updated correctly -`False` if user clicked the Cancel button, closed the form, or vale reached the max value. -**Customized Progress Bar** -If you want a bit more customization of your meter, then you can go up 1 level and use the calls to `ProgressMeter` and `ProgressMeterUpdate`. These APIs behave like an object we're all used to. First you create the `ProgressMeter` object, then you call the `Update` method to update it. - -You setup the progress meter by calling - - my_meter = ProgressMeter(title, - max_value, - *args, - orientantion=None, - bar_color=DEFAULT_PROGRESS_BAR_COLOR, - button_color=None, - size=DEFAULT_PROGRESS_BAR_SIZE, - scale=(None, None), - border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) -Then to update the bar within your loop - - return_code = ProgressMeterUpdate(my_meter, - value, - *args): -Putting it all together you get this design pattern - - my_meter = sg.ProgressMeter('Meter Title', 100000, orentation='Vert') - - for i in range(0, 100000): - sg.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') - - -The final way of using a Progress Meter with PySimpleGUI is to build a custom form with a `ProgressBar` Element in the form. You will need to run your form as a non-blocking form. When you are ready to update your progress bar, you call the `UpdateBar` method for the `ProgressBar` element itself. - - -#### Output -The Output Element is a re-direction of Stdout. Anything "printed" will be displayed in this element. - - Output(scale=(None, None), - size=(None, None)) - -Here's a complete solution for a chat-window using an Async form with an Output Element - - import PySimpleGUI as sg - # Blocking form that doesn't close - def ChatBot(): - with sg.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: - layout = [[(sg.Text('This is where standard out is being routed', size=[40, 1]))], - [sg.Output(size=(80, 20))], - [sg.Multiline(size=(70, 5), enter_submits=True), sg.ReadFormButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0])), sg.SimpleButton('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]] - # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form - # if you call LayoutAndRead from here, then you will miss the first button click - form.Layout(layout) - # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # - while True: - button, value = form.Read() - if button == 'SEND': - print(value) - else: - break - - -## Tabbed Forms -Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format - - results = ShowTabbedForm('Title for the form', - (form,layout,'Tab 1 label'), - (form2,layout2, 'Tab 2 label'), ...) - -Each of the tabs of the form is in fact a form. The same steps are taken to create the form as before. A `FlexForm` is created, then rows are filled with Elements, and finally the form is shown. When calling `ShowTabbedForm`, each form is passed in as a tuple. The tuple has the format: `(the form, the rows, a string shown on the tab)` - -Results are returned as a list of lists. For each form you'll get a list that's in the same format as a normal form. A single tab's values would be: - - (button, (values)) - -Recall that values is a list as well. Multiple tabs in the form would return like this: - - ((button1, (values1)), (button2, (values2)) - - ## Colors ## -Starting in version 2.5 you can change the background colors for the window and the Elements. - -Your forms can go from this: -![snap0155](https://user-images.githubusercontent.com/13696193/43273879-a9fdc10a-90cb-11e8-8c20-4f6a244ebe2f.jpg) - - -to this... with one function call... - -![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) - - - -While you can do it on an element by element or form level basis, the easiest way, by far, is a call to `SetOptions`. - -Be aware that once you change these options they are changed for the rest of your program's execution. All of your forms will have that look and feel, until you change it to something else (which could be the system default colors. - -This call sets all of the different color options. - - SetOptions(background_color='#9FB8AD', - text_element_background_color='#9FB8AD', - element_background_color='#9FB8AD', - scrollbar_color=None, - input_elements_background_color='#F7F3EC', - progress_meter_color = ('green', 'blue') - button_color=('white','#475841')) - - - -## Global Settings -**Global Settings** -Let's have some fun customizing! Make PySimpleGUI look the way you want it to look. You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. - - SetOptions(icon=None - button_color=(None,None) - element_size=(None,None), - margins=(None,None), - element_padding=(None,None) - auto_size_text=None - auto_size_buttons=None - font=None - border_width=None - slider_border_width=None - slider_relief=None - slider_orientation=None - autoclose_time=None - message_box_line_width=None - progress_meter_border_depth=None - progress_meter_style=None - progress_meter_relief=None - progress_meter_color=None - progress_meter_size=None - text_justification=None - background_color=None - element_background_color=None - text_element_background_color=None - input_elements_background_color=None - scrollbar_color=None, text_color=None - debug_win_size=(None,None) - window_location=(None,None) - -Explanation of parameters - - icon - filename of icon used for taskbar and title bar - button_color - button color (foreground, background) - element_size - element size (width, height) in characters - margins - tkinter margins around outsize - element_padding - tkinter padding around each element - auto_size_text - autosize the elements to fit their text - auto_size_buttons - autosize the buttons to fit their text - font - font used for elements - border_width - amount of bezel or border around sunken or raised elements - slider_border_width - changes the way sliders look - slider_relief - changes the way sliders look - slider_orientation - changes orientation of slider - autoclose_time - time in seconds for autoclose boxes - message_box_line_width - number of characers in a line of text in message boxes - progress_meter_border_depth - amount of border around raised or lowered progress meters - progress_meter_style - style of progress meter as defined by tkinter - progress_meter_relief - relief style - progress_meter_color - color of the bar and background of progress meters - progress_meter_size - size in (characters, pixels) - background_color - Color of the main window's background - element_background_color - Background color of the elements - text_element_background_color - Text element background color - input_elements_background_color - Input fields background color - scrollbar_color - Color for scrollbars (may not always work) - text_color - Text element default text color - text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' - debug_win_size - size of the Print output window - window_location - location on the screen (x,y) of window's top left cornder - - -These settings apply to all forms `SetOptions`. The Row options and Element options will take precedence over these settings. Settings can be thought of as levels of settings with the Form-level being the highest and the Element-level the lowest. Thus the levels are: - - - Form level - - Row level - - Element level - -Each lower level overrides the settings of the higher level. Once settings have been changed, they remain changed for the duration of the program (unless changed again). - -## Asynchronous (Non-Blocking) Forms -So you want to be a wizard do ya? Well go boldly! While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. With asynchronous forms the form is shown, user input is read, but your code keeps right on chugging. YOUR responsibility is to call `PySimpleGUI.ReadNonBlocking` on a periodic basis. Once a second or more will produce a reasonably snappy GUI. - -When do you use a non-blocking form? A couple of examples are -* A media file player like an MP3 player -* A status dashboard that's periodically updated -* Progress Meters - when you want to make your own progress meters -* Output using print to a scrolled text element. Good for debugging. - -Word of warning... version 2.2, the currently released, and upcoming version 2.3 differ in the return code for the `ReadNonBlocking` call. Previously the function returned 2 values, except when the form is closed using the "X" which returned a single value of `None`. The *new* way is that `ReadNonBlocking` always returns 2 values. If the user closed the form with the "X" then the return values will be None, None. You will want to key off the second value to catch this case. -The proper code to check if the user has exited the form will be a polling-loop that looks something like this: - - while True: - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': - break - -We're going to build an app that does the latter. It's going to update our form with a running clock. - -The basic flow and functions you will be calling are: -Setup - - - form = FlexForm() - form_rows = ..... - form.LayoutAndRead(form_rows, non_blocking=True) - - -Periodic refresh - - form.ReadNonBlocking() -If you need to close the form - - form.CloseNonBlockingForm() - -Rather than the usual `form.LayoutAndRead()` call, we're manually adding the rows (doing the layout) and then showing the form. After the form is shown, you simply call `form.ReadNonBlocking()` every now and then. - -When you are ready to close the form (assuming the form wasn't closed by the user or a button click) you simply call `form.CloseNonBlockingForm()` - -**Example - Running timer that updates** -See the sample code on the GitHub named Demo Media Player for another example of Async Forms. We're going to make a form and update one of the elements of that form every .01 seconds. Here's the entire code to do that. - - - import PySimpleGUI as sg - import time - - # form that doesn't block - # Make a form, but don't use context manager - form = sg.FlexForm('Running Timer', auto_size_text=True) - # Create a text element that will be updated with status information on the GUI itself - output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) - # Create the rows - form_rows = [[sg.Text('Non-blocking GUI with updates')], - [output_element], - [sg.SimpleButton('Quit')]] - # Layout the rows of the form and perform a read. Indicate the form is non-blocking! - form.LayoutAndRead(form_rows, non_blocking=True) - - # - # Some place later in your code... - # You need to perform a ReadNonBlocking on your form every now and then or - # else it won't refresh - # - - for i in range(1, 1000): - output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) - button, values = form.ReadNonBlocking() - if values is None or button == 'Quit': - break - time.sleep(.01) - else: - form.CloseNonBlockingForm() - - - -What we have here is the same sequence of function calls as in the description. Get a form, add rows to it, show the form, and then refresh it every now and then. - -The new thing in this example is the call use of the Update method for the Text Element. The first thing we do inside the loop is "update" the text element that we made earlier. This changes the value of the text field on the form. The new value will be displayed when `form.ReadNonBlocking()` is called. - -Note the `else` statement on the for loop. This is needed because we're about to exit the loop while the form is still open. The user has not closed the form using the X nor a button so it's up to the caller to close the form using `CloseNonBlockingForm`. - -That's it... this example follows the async design pattern well. - - - -## Sample Applications -Use the example programs as a starting basis for your GUI. Copy, paste, modify and run! The demo files are: - -`Demo Recipes.py` - Sample forms for all major form types and situations. This is the place to get your code template from. Includes asynchronous forms, etc. - -`Demo DisplayHash1and256.py` - Demonstrates using High Level API calls to get a filename - -`Demo DupliucateFileFinder.py` - Demonstrates High Level API to get a folder & Easy Progress Meter to show progress of the file scanning - -`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. If anyone wants to help me package this application up, I could use a hand. - -## Fun Stuff -Here are some things to try if you're bored or want to further customize - -**Debug Output** -Be sure and check out the EasyPrint (Print) function described in the high-level API section. Leave your code the way it is, route your stdout and stderror to a scrolling window. - -For a fun time, add these lines to the top of your script - - import PySimpleGUI as sg - print = sg.Print - -This will turn all of your print statements into prints that display in a window on your screen rather than to the terminal. - -**Look and Feel** -Dial in the look and feel that you like with the `SetOptions` function. You can change all of the defaults in one function call. One line of code to customize the entire GUI. - -**ObjToString** -Ever wanted to easily display an objects contents easily? Use ObjToString to get a nicely formatted recursive walk of your objects. -This statement: - - print(sg.ObjToSting(x)) - -And this was the output - - - abc = abc - attr12 = 12 - c = - b = - a = - attr1 = 1 - attr2 = 2 - attr3 = three - attr10 = 10 - attrx = x - -You'll quickly wonder how you ever coded without it. - ---- -# Known Issues -While not an "issue" this is a ***stern warning*** - -## **Do not attempt** to call `PySimpleGUI` from multiple threads! It's `tkinter` based and `tkinter` has issues with multiple threads - -**Progress Meters** - the visual graphic portion of the meter may be off. May return to the native tkinter progress meter solution in the future. Right now a "custom" progress meter is used. On the bright side, the statistics shown are extremely accurate and can tell you something about the performance of your code. - -**Async Forms** - these include the 'easy' forms (EasyProgressMeter and EasyPrint/Print). If you start overlapping having Async forms open with normal forms then things get a littler squirrelly. Still tracking down the issues and am making it more solid every day possible. You'll know there's an issue when you see blank form. - -**EasyPrint** - EasyPrint is a new feature that's pretty awesome. You print and the output goes to a window, with a scroll bar, that you can copy and paste from. Being a new feature, it's got some potential problems. There are known interaction problems with other GUI windows. For example, closing a Print window can also close other windows you have open. For now, don't close your debug print window until other windows are closed too. - -## Contributing - -A MikeTheWatchGuy production... entirely responsible for this code.... unless it causes you trouble in which case I'm not at all responsible. - -## Versions -|Version | Description | -|--|--| -| 1.0.9 | July 10, 2018 - Initial Release | -| 1.0.21 | July 13, 2018 - Readme updates | -| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case -| 2.1.1 | July 18, 2018 - Global settings exposed, fixes -| 2.2.0| July 20, 2018 - Image Elements, Print output -| 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. -| 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi -| 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. -| 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ -| 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting - - -### Release Notes -2.3 - Sliders, Listbox's and Image elements (oh my!) - -If using Progress Meters, avoid cancelling them when you have another window open. It could lead to future windows being blank. It's being worked on. - -New debug printing capability. `sg.Print` - -2.5 Discovered issue with scroll bar on `Output` elements. The bar will match size of ROW not the size of the element. Normally you never notice this due to where on a form the `Output` element goes. - -Listboxes are still without scrollwheels. The mouse can drag to see more items. The mouse scrollwheel will also scroll the list and will `page up` and `page down` keys. - -2.7 Is the "feature complete" release. Pretty much all features are done and in the code - - -### Upcoming -Make suggestions people! Future release features - -Columns. How multiple columns would be specified in the SDK interface are still being designed. - -Port to other graphic engines. Hook up the front-end interface to a backend other than tkinter. Qt, WxPython, etc. - - - -## Code Condition - - Make it run - Make it right - Make it fast - -It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor for PEP 8 compliance. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. - -While the internals to PySimpleGUI are a tad sketchy, the public interfaces into the SDK are more strictly defined and comply with PEP 8 for the most part. - -Please log bugs and suggestions in the GitHub! It will only make the code stronger and better in the end, a good thing for us all, right? - -## Design - -A moment about the design-spirit of `PySimpleGUI`. From the beginning, this package was meant to take advantage of Python's capabilities with the goal of programming ease. - -**Single File** -While not the best programming practice, the implementation resulted in a single file solution. Only one file is needed, PySimpleGUI.py. You can post this file, email it, and easily import it using one statement. - -**Functions as objects** -In Python, functions behave just like object. When you're placing a Text Element into your form, you may be sometimes calling a function and other times declaring an object. If you use the word Text, then you're getting an object. If you're using `Txt`, then you're calling a function that returns a `Text` object. - -**Lists** -It seemed quite natural to use Python's powerful list constructs when possible. The form is specified as a series of lists. Each "row" of the GUI is represented as a list of Elements. When the form read returns the results to the user, all of the results are presented as a single list. This makes reading a form's values super-simple to do in a single line of Python code. - - -## Authors -MikeTheWatchGuy - -## License - -GNU Lesser General Public License (LGPL 3) + - -## Acknowledgments - -* Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence -* [Fredrik Lundh](https://wiki.python.org/moin/FredrikLundh) for his work on `tkinter` - - -## How Do I -Finally, I must thank the fine folks at How Do I. -https://github.com/gleitz/howdoi -Their utility has forever changed the way and pace in which I can program. I urge you to try the HowDoI.py application here on GitHub. Trust me, **it's going to be worth the effort!** -Here are the steps to run that application - - Install howdoi: - pip install howdoi - Test your install: - python -m howdoi howdoi.py - To run it: - Python HowDoI.py - -The pip command is all there is to the setup. - -The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. -For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. -![snap0109](https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg) - -In the hands of a competent programmer, this tool is **amazing**. It's a must-try kind of program that has completely changed my programming process. I'm not afraid of asking for help! You just have to be smart about using what you find. - -The PySimpleGUI window that the results are shown in is an 'input' field which means you can copy and paste the results right into your code. \ No newline at end of file From 344c14a59835c4fe92e443f4b00699d0f945944a Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 3 Aug 2018 19:30:01 -0400 Subject: [PATCH 107/209] / to \ --- docs/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index 88bb4950f..301abe654 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -9,7 +9,7 @@ Welcome to PySimpleGUI's documentation! .. toctree:: :maxdepth: 2 :caption: Contents: -../readme.md +..\readme.md Indices and tables From dbc7caeea6c914927a019eeb9786739ab6ed5667 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 3 Aug 2018 19:30:57 -0400 Subject: [PATCH 108/209] readme --- docs/readme.md | 1506 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1506 insertions(+) create mode 100644 docs/readme.md diff --git a/docs/readme.md b/docs/readme.md new file mode 100644 index 000000000..f03d65375 --- /dev/null +++ b/docs/readme.md @@ -0,0 +1,1506 @@ + + +![pysimplegui_logo](https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png) + +[![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 +# PySimpleGUI + (Ver 2.7) + +Super-simple GUI to grasp... Powerfully customizable. + +Note - *Python3* is required to run PySimpleGUI. It takes advantage of some Python3 features that do not translate well into Python2. + +Looking to take your Python code from the world of command lines and into the convenience of a GUI? Have a Raspberry Pi with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK? Look no further, you've found your GUI package. + + import PySimpleGUI as sg + + sg.MsgBox('Hello From PySimpleGUI!', 'This is the shortest GUI program ever!') + + +![snap0136](https://user-images.githubusercontent.com/13696193/43162494-33095ece-8f59-11e8-86de-b6d8bcc5a52f.jpg) + + Build beautiful customized forms that fit your specific problem. Let PySimpleGUI solve your GUI problem while you solve the real problems. Do you really want to plod through the mountains of code required to program tkinter? + +![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) + +Perhaps you're looking for a way to interact with your Raspberry Pi in a more friendly way. The is the same form as above, except shown on a Pi. + +![raspberry pi](https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg) + + +In addition to a primary GUI, you can add a Progress Meter to your code with ONE LINE of code. Slide this into any of your `for` loops and get a nice meter like this: + + EasyProgressMeter('My meter title', current_value, max value) + + ![snap0177](https://user-images.githubusercontent.com/13696193/43658025-947973d2-9725-11e8-902f-e2d5effb6e3e.jpg) + +You can build an async media player GUI with custom buttons in 30 lines of code. + +![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) + +I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? + +There are a number of 'easy to use' Python GUIs, but they're **very** limiting. PySimpleGUI takes the best of packages like `EasyGUI`and `WxSimpleGUI` , both really handy but limited. The primary difference between these and PySimpleGUI is that in addition to getting the simple Message Boxes you also get the ability to make your own forms that are highly customizeable. Don't like the standard Message Box? Then make your own! + +Every call has optional parameters so that you can change the look and feel. Don't like the button color? It's easy to change by adding a button_color parameter to your widget. + +GUI Packages with more functionality, like QT and WxPython, require configuring and can take a ***week*** to get *reasonably familiar* with the interfaces. Clearly there needs to be a middle ground between forms with 1 or two input fields and a full-blown GUI. You'll be making your own custom forms with PySimpleGUI within minutes, even Async forms. + +With a simple GUI, it becomes practical to "associate" .py files with the python interpreter on Windows. Double click a py file and up pops a GUI window, a more pleasant experience than opening a dos Window and typing a command line. + +The `PySimpleGUI` package is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? + + Features of PySimpleGUI include: + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Realtime + Checkboxes + Radio Buttons + Listbox + Slider + Icons + Multi-line Text Input + Scroll-able Output + Images + Progress Bar + Async/Non-Blocking Windows + Tabbed forms + Persistent Windows + Redirect Python Output/Errors to scrolling window + 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) + Single-Line-Of-Coide Proress Bar & Debug Print + Complete control of colors, look and feel + Button images + + +An example of many widgets used on a single form. A little further down you'll find the TWENTY lines of code required to create this complex form. Try it if you don't believe it. Start Python, copy and paste the code below into the >>> prompt and hit enter. This will pop up... + +![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) + +Here is the code that produced the above screenshot. + + import PySimpleGUI as sg + + with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText()], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [sg.Text('_' * 100, size=(70, 1))], + [sg.Text('Choose Source and Destination Folders', size=(35, 1))], + [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], + [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), + sg.FolderBrowse()], + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + + **A note on screen shots** +You will see a number of different styles of buttons, data entry fields, etc, in this readme. They were all made with the same SDK, the only difference is in the settings that are specified on a per-element, row, form, or global basis. One setting in particular, border_width, can make a big difference on the look of the form. Some of the screenshots had a border_width of 6, others a value of 1. + + +--- +### Design Goals +> Copy, Paste, Run. + +`PySimpleGUI's` goal with the API is to be easy on the programmer, and to function in a Python-like way. Since GUIs are visual, it was desirable for the code to visually match what's on the screen. + + > Be Pythonic + + Be Pythonic... Attempted to use language constructs in a natural way and to exploit some of Python's interesting features. Python's lists and optional parameters make PySimpleGUI work. + - Forms are represented as Python lists. + - A form is a list of rows + - A row is a list of elements +- Return values are a list of button presses and input values. + +It's stunning that after so many years Python still hasn't put forth a GUI framework that truly fits the language's basic data structures, especially lists. It's hard to argue with the success to be had in quickly building GUI applications using this package's syntax. + + ----- +## Getting Started with PySimpleGUI + +### Installing + + pip install PySimpleGUI + or +Simply download the file - PySimpleGUI.py and import it into your code + + +### Prerequisites + +Python 3 +tkinter + +Runs on all Python platforms that have tkinter running on them. Thoroughly tested on Windows. Runs on Windows, Mac, Linux, Raspberry Pi. Even runs on `pypy3`. + +### Using + +To use in your code, simply import.... + `import PySimpleGUI as sg` + +Then use either "high level" API calls or build your own forms. + + sg.MsgBox('This is my first message box') + +![snap0178](https://user-images.githubusercontent.com/13696193/43658024-945c83f8-9725-11e8-8ddd-0bbe67a9fc5d.jpg) + + +Yes, it's just that easy to have a window appear on the screen using Python. With PySimpleGUI, making a custom form appear isn't much more difficult. The goal is to get you running on your GUI within ***minutes***, not hours nor days. + +--- +## APIs + +PySimpleGUI can be broken down into 2 types of API's: + * High Level single call functions + * Custom form functions + + +### Python Language Features + + There are a couple of Python language features that PySimpleGUI utilizes heavily that should be understood first... + * Variable number of arguments to a function call + * Optional parameters to a function call + +#### Variable Number of Arguments + + The "High Level" API calls that *output* values take a variable number of arguments so that they match a "print" statement as much as possible. The idea is to make it simple for the programmer to output as many items as desired and in any format. The user need not convert the variables to be output into the strings. The PySimpleGUI functions do that for the user. + + sg.MsgBox('Variable number of parameters example', var1, var2, "etc") + +Each new item begins on a new line in the Message Box + + ![snap0179](https://user-images.githubusercontent.com/13696193/43658129-f6ca49c6-9725-11e8-9317-1f77443eb04a.jpg) + + + +#### Optional Parameters to a Function Call + +This feature of the Python language is utilized ***heavily*** as a method of customizing forms and form Elements. Rather than requiring the programmer to specify every possible option for a widget, instead only the options the caller wants to override are specified. + +Here is the function definition for the MsgBox function. The details aren't important. What is important is seeing that there is a long list of potential tweaks that a caller can make. However, they don't *have* to be specified on each and every call. + + def MsgBox(*args, + button_color=None, + button_type=MSG_BOX_OK, + auto_close=False, + auto_close_duration=None, + icon=DEFAULT_WINDOW_ICON, + line_width=MESSAGE_BOX_LINE_WIDTH, + font=None): + +If the caller wanted to change the button color to be black on yellow, the call would look something like this: + + sg.MsgBox('This box has a custom button color', button_color=('black', 'yellow')) + + +![snap0180](https://user-images.githubusercontent.com/13696193/43658171-13a72bfe-9726-11e8-8c7a-0a46e46fb202.jpg) + + +--- + +### High Level API Calls + +The classic "input a value, print result" example. +Often command line programs simply take some value as input on the command line, do something with it and then display the results. Moving from the command line to a GUI is very simple. +This code prompts user to input a line of text and then displays that text in a messages box: + + + import PySimpleGUI as sg + + rc = sg.GetTextBox('Title', 'Please input something') + sg.MsgBox('Results', 'The value returned from GetTextBox', rc) + + + ![snap0181](https://user-images.githubusercontent.com/13696193/43658233-48cc7794-9726-11e8-8582-8844280c344e.jpg) + +![snap0182](https://user-images.githubusercontent.com/13696193/43658232-48aaad4e-9726-11e8-95f5-aa9b9213bb77.jpg) + + +#### Message Boxes +In addition to MsgBox, you'll find a several API calls that are shortcuts to common messages boxes. You can achieve similar results by calling MsgBox with the correct parameters. + +The differences tend to be the number and types of buttons. Here are the calls and the windows that are created. + + import PySimpleGUI as sg + + `sg.MsgBoxOK('This is an OK MsgBox')` + + ![ok](https://user-images.githubusercontent.com/13696193/43667331-723ac666-9745-11e8-8666-230c35a6afd6.jpg) + + + sg.MsgBoxOKCancel('This is an OK Cancel MsgBox') + +![ok cancel 2](https://user-images.githubusercontent.com/13696193/43667330-71d5bea6-9745-11e8-8944-b3900853aa62.jpg) + + sg.MsgBoxCancel('This is a Cancel MsgBox') + +![cancel](https://user-images.githubusercontent.com/13696193/43667329-71a007de-9745-11e8-974b-d028f68798e7.jpg) + + sg.MsgBoxYesNo('This is a Yes No MsgBox') + +![yesno](https://user-images.githubusercontent.com/13696193/43667327-717ff7dc-9745-11e8-9dce-52c305a85101.jpg) + + + sg.MsgBoxError('This is an error MsgBox') + +![error msgbox](https://user-images.githubusercontent.com/13696193/43667326-71621712-9745-11e8-87c4-56e2ab500f8e.jpg) + + sg.MsgBoxAutoClose('This is an autoclose MsgBox') + +![autoclose](https://user-images.githubusercontent.com/13696193/43667325-714997dc-9745-11e8-836a-7185dc80329f.jpg) + + sg.ScrolledTextBox(my_text, height=10) + +![scrolledtextbox 2](https://user-images.githubusercontent.com/13696193/43667324-712aa0d4-9745-11e8-83a9-a0d0570d0865.jpg) + + +Take a moment to look at that last one. It's such a simple API call and yet the result is awesome. Rather than seeing your printed text scrolling past on your display, you can capture that text and present it in a scrolled interface. It's handy enough of an API call that it can also be called using the name `sprint` which is easier to remember than `ScrollectTextBox`. Your code could contain a line like: + + sprint(f'My variables values include x={x}', f'y={y}') + +This becomes a debug print of sorts that will route to a scrolled window. + +See also the `EasyPrint` and `Print` functions. + +#### High Level User Input + +There are 3 very basic user input high-level function calls. It's expected that for most applications, a custom input form will be created. If you need only 1 value, then perhaps one of these high level functions will work. + - GetTextBox + - GetFileBox + - GetFolderBox + + `submit_clicked, value = sg.GetTextBox('Title', 'Please enter anything')` + +![gettextbox 2](https://user-images.githubusercontent.com/13696193/43667510-355b23a2-9746-11e8-9f1e-91c0dd0f4ed8.jpg) + + submit_clicked, value = sg.GetFileBox('Title', 'Choose a file') + +![getfilebox 2](https://user-images.githubusercontent.com/13696193/43667535-5821fc94-9746-11e8-95c3-82395099e994.jpg) + + submit_clicked, value = sg.GetPathBox('Title', 'Choose a folder') + +![getpathbox](https://user-images.githubusercontent.com/13696193/43667556-79874c22-9746-11e8-80f2-8262d32802c2.jpg) + + +#### Progress Meter! +We all have loops in our code. 'Isn't it joyful waiting, watching a counter scrolling past in a text window? How about one line of code to get a progress meter, that contains statistics about your code? + + + EasyProgressMeter(title, + current_value, + max_value, + *args, + orientation=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH): + +Here's the one-line Progress Meter in action! + + for i in range(1,10000): + sg.EasyProgressMeter('My Meter', i+1, 10000, 'Optional message') + +That line of code resulted in this window popping up and updating. + +![preogress meter](https://user-images.githubusercontent.com/13696193/43667625-d47da702-9746-11e8-91e6-e5177883abae.jpg) + +A meter AND fun statistics to watch while your machine grinds away, all for the price of 1 line of code. +With a little trickery you can provide a way to break out of your loop using the Progress Meter form. The cancel button results in a `False` return value from `EasyProgressMeter`. It normally returns `True`. + +***Be sure and add one to your loop counter*** so that your counter goes from 1 to the max value. If you do not add one, your counter will never hit the max value. Instead it will go from 0 to max-1. + +#### Debug Output +Another call in the 'Easy' families of APIs is `EasyPrint`. It will output to a debug window. If the debug window isn't open, then the first call will open it. No need to do anything but stick a 'print' call in your code. You can even replace your 'print' calls with calls to EasyPrint by simply sticking the statement + + print = sg.EasyPrint + +at the top of your code. +There are a number of names for the same EasyPrint function. `Print` is one of the better ones to use as it's easy to remember. It is simply `print` with a capital P. + + import PySimpleGUI as sg + + for i in range(100): + sg.Print(i) + +![snap0125](https://user-images.githubusercontent.com/13696193/43114979-a696189e-8ecf-11e8-83c7-473fcf0ccc66.jpg) +Or if you didn't want to change your code: + + import PySimpleGUI as sg + + print=sg.Print + for i in range(100): + print(i) + +Just like the standard print call, `EasyPrint` supports the `sep` and `end` keyword arguments. Other names that can be used to call `EasyPrint` include Print, `eprint`, If you want to close the window, call the function `EasyPrintClose`. + +A word of caution. There are known problems when multiple PySimpleGUI windows are opened, particularly if the user closes them in an unusual way. Not a reason to stay away from using it. Just something to keep in mind if you encounter a problem. + +You can change the size of the debug window using the `SetOptions` call with the `debug_win_size` parameter. + +--- +# Custom Form API Calls (Your First Form) + +This is the FUN part of the programming of this GUI. In order to really get the most out of the API, you should be using an IDE that supports auto complete or will show you the definition of the function. This will make customizing go smoother. + +This first section on custom forms is for your typical, blocking, non-persistant form. By this I mean, when you "show" the form, the function will not return until the user has clicked a button or closed the window. When this happens, the form's window will be automatically closed. + +Two other types of forms exist. +1. Persistent form - rather than closing on button clicks, the show form function returns and the form continues to be visible. This is good for applications like a chat window. +2. Asynchronous form - the trickiest of the lot. Great care must be exercised. Examples are an MP3 player or status dashboard. Async forms are updated (refreshed) on a periodic basis. + +It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. Let's start with a basic Browse for a file and do something with it. +# Copy these design patterns! +## Pattern 1 - With Context Manager + + + with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: + form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], + [sg.InputText(), sg.FileBrowse()], + [sg.Submit(), sg.Cancel()]] + button, (source_filename,) = form.LayoutAndRead(form_rows) + +## Pattern 2 - No Context Manager + + + form = sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) + form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], + [sg.InputText(), sg.FileBrowse()], + [sg.Submit(), sg.Cancel()]] + button, (source_filename,) = form.LayoutAndRead(form_rows) + + + +These 2 design patters both produce this custom form: + +![snap0134](https://user-images.githubusercontent.com/13696193/43162410-e7775466-8f58-11e8-8d6a-da4772c00dd8.jpg) + +It's important to use the "with" context manager so that resources are freed as quickly as possible, using the currently executing thread. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. + +The second design pattern is not context manager based. If you are struggling with an unknown error, try modifying the code to run without a context manager. To do so, you simple remove the with, stick the form on the front of that statement, and un-indent the with-block code. + +You will use these design patterns or code templates for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. This is the most basic / normal of the design patterns. + +### How GUI Programming in Python Should Look + +GUI programming in Python is a mess. tkinter kinda sucks. Why is Python such a great teaching language and yet no GUI framework exists that lends itself to the basic building blocks of Python, the list? + +The key to custom forms in PySimpleGUI is to view forms as ROWS of Widgets (Elements). Each row is specified as a list of these widgets. Put the rows together and you've got a form. + +Let's look at this one. + + +![snap0131](https://user-images.githubusercontent.com/13696193/43417007-df6d8408-9407-11e8-9986-30f0415f08a5.jpg) + +Let's agree the form has 4 rows. + +The first row only has **text** that reads `Rename files or folders` + +The second row has 3 elements in it. First the **text** `Source for Folders`, then an **input** field, then a **browse** button. + +Now let's look at how those 2 rows and the other two row from Python code: + + layout = [[sg.Text('Rename files or folders')], + [sg.Text('Source for Folders', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], + [sg.Text('Source for Files ', size=(15, 1)), sg.InputText(), sg.FolderBrowse()], + [sg.Submit(), sg.Cancel()]] + +See how the source code mirrors the layout? You simply make lists for each row, then submit that table to PySimpleGUI to show and get values from. + +And what about those return values? Most people simply want to show a form, get the input values and do something with them. So why break up the code into button callbacks, etc, when I simply want my form's input values to be given to me. + +The same "row" concept applies to return values. The form is scanned from top to bottom, left to right. Each field that's an input field will occupy a spot in the return values. + +In our example form, there are 2 fields, so the return values from this form will be a list with 2 values in it. + + button, (folder_path, file_path) = form.LayoutAndRead(layout) + +In the statement that shows and reads the form, the two input fields are directly assigned to the caller's variables `folder_path` and `file_path`, ready to use. No parsing no callbacks. + +Isn't this what almost every Python programmer looking for a GUI wants?? Something easy to work with to get the values and move on to the rest of the program, where the real action is taking place. Why write pages of tkinter code when the same layout can be achieved with PySimpleGUI in 3 or 4 lines of code. 4 lines or 40? I chose 4. + + +### Laying out your form +Your form is a 2 dimensional list in Python. The first dimension are rows, the second is a list of Elements for each row. The first thing you want to do is layout your form on paper. + + layout = [ [row 1], + [row 2], + [row 3] ] + +Simple enough... a list of lists. +A row is a list of Elements. For example this could be a row with a couple of elements on it. + + [ Input, Button] + +Turning back to our example. This GUI roughly looks like this: + + layout = [ [Text], + [InputText, FileBrowse] + [Submit, Cancel] ] + + Now let's put it all together into an entire program. + + +### Line by line explanation + +Going through each line of code in the above form will help explain how to use this design patter. Copy, modify and run it! + + with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: +This creates a new form, storing it in the variable `form`. + + form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], +The next few rows of code lay out the rows of elements in the window to be displayed. The variable `form_rows` holds our entire GUI window. The first row of this form has a Text element. These simply display text on the form. + + [sg.InputText(), sg.FileBrowse()], +Now we're on the second row of the form. On this row there are 2 elements. The first is an `Input` field. It's a place the user can enter `strings`. The second element is a `File Browse Button`. A file or folder browse button will always fill in the text field to it's left unless otherwise specified. In this example, the File Browse Button will interact with the `InputText` field to its left. + + [sg.Submit(), sg.Cancel()]] + +The last line of the `form_rows` variable assignment contains a Submit and a Cancel Button. These are buttons that will cause a form to return its value to the caller. + + button, (source_filename, ) = form.LayoutAndRead(form_rows) +This is the code that **displays** the form, collects the information and returns the data collected. In this example we have a button return code and only 1 input field. The result of the form is stored directly into the variable we wish to work with. + + +## Return values + + Return information from FlexForm, SG's primary form builder interface, is in this format: + + button, (value1, value2, ...) + +Each of the Elements that are Input Elements will have a value in the list of return values. You can unpack your GUI directly into the variables you want to use. + + button, (filename, folder1, folder2, should_overwrite) = form.LayoutAndRead(form_rows) + + Or, you can unpack the return results separately. + + button, values = form.LayoutAndRead(form_rows) + filename, folder1, folder2, should_overwrite = values + +If you have a SINGLE value being returned, it is written this way: + + button, (value1,) = form.LayoutAndRead(form_rows) + + + Another way of parsing the return values is to store the list of values into a variable representing the list of values. + + button, value_list = form.LayoutAndRead(form_rows) + value1 = value_list[0] + value2 = value_list[1] + ... + +--- +## All Widgets / Elements +This code utilizes as many of the elements in one form as possible. + + with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25), text_color='blue')], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText()], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text shoulsd you decide not to type anything', + scale=(2, 10))], + [sg.InputCombo(['Combobox 1', 'Combobox 2'], size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(35, 20), default_value=85)], + [sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6)), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], + [sg.Text('_' * 100, size=(70, 1))], + [sg.Text('Choose Source and Destination Folders', size=(35, 1))], + [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], + [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), + sg.FolderBrowse()], + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] + ] + + button, values = form.LayoutAndRead(layout) + +This is a somewhat complex form with quite a bit of custom sizing to make things line up well. This is code you only have to write once. When looking at the code, remember that what you're seeing is a list of lists. Each row contains a list of Graphical Elements that are used to create the form. + +![everything example](https://user-images.githubusercontent.com/13696193/43097412-0a4652aa-8e8a-11e8-8e09-939484e3c568.jpg) + +Clicking the Submit button caused the form call to return. The call to MsgBox resulted in this dialog box. +![results 2](https://user-images.githubusercontent.com/13696193/43097502-44e3ed32-8e8a-11e8-9a51-2b8af0b1a682.jpg) + + +**`Note, button value can be None`**. The value for `button` will be the text that is displayed on the button element when it was created. If the user closed the form using something other than a button, then `button` will be `None`. + +You can see in the MsgBox that the values returned are a list. Each input field in the form generates one item in the return values list. All input fields return a `string` except for Check Boxes and Radio Buttons. These return `bool`. + +--- +# Building Custom Forms +You will find it much easier to write code using PySimpleGUI if you use an IDE such as PyCharm. The features that show you documentation about the API call you are making will help you determine which settings you want to change, if any. In PyCharm, two commands are particularly helpful. + + Control-Q (when cursor is on function name) brings up a box with the function definition + Control-P (when cursor inside function call "()") shows a list of parameters and their default values + +## Synchronous Forms +The most common use of PySimpleGUI is to display and collect information from the user. The most straightforward way to do this is using a "blocking" GUI call. Execution is "blocked" while waiting for the user to close the GUI form/dialog box. +You've already seen a number of examples above that use blocking forms. Anytime you see a context manager used (see the `with` statement) it's most likely a blocking form. You can examine the show calls to be sure. If the form is a non-blocking form, it must indicate that in the call to `form.show`. + +NON-BLOCKING form call: + + form.Show(non_blocking=True) + +### Beginning a Form +The first step is to create the form object using the desired form customization. + + with FlexForm('Everything bagel', auto_size_text=True, default_element_size=(30,1)) as form: + +This is the definition of the FlexForm object: + + def FlexForm(title, + default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), + auto_size_text=None, + auto_size_buttons=None, + scale=(None, None), + location=(None, None), + button_color=None,Font=None, + progress_bar_color=(None,None), + is_tabbed_form=False, + border_depth=None, + auto_close=False, + auto_close_duration=DEFAULT_AUTOCLOSE_TIME, + icon=DEFAULT_WINDOW_ICON): + +Parameter Descriptions. You will find these same parameters specified for each `Element` and some of them in `Row` specifications. The `Element` specified value will take precedence over the `Row` and `Form` values. + + default_element_size - Size of elements in form in characters (width, height) + auto_size_text - Bool. True if elements should size themselves according to contents + auto_size_buttons - Bool. True if button elements should size themselves according to their text label + scale - Set size of element to be a multiple of the Element size + location - Location to place window in pixels + button_color - Default color for buttons (foreground, background). Can be text or hex + progress_bar_color - Foreground and background colors for progress bars + is_tabbed_form - Bool. If True then form is a tabbed form + border_depth - Amount of 'bezel' to put on input boxes, buttons, etc. + auto_close - Bool. If True form will autoclose + auto_close_duration - Duration in seconds before form closes + icon - .ICO file that will appear on the Task Bar and end of Title Bar + + +#### Sizes +Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. + +The default Element size for PySimpleGUI is `(45,1)`. + +Sizes can be set at the element level, or in this case, the size variables apply to all elements in the form. Setting `size=(20,1)` in the form creation call will set all elements in the form to that size. + +In addition to `size` there is a `scale` option. `scale` will take the Element's size and scale it up or down depending on the scale value. `scale=(1,1)` doesn't change the Element's size. `scale=(2,1)` will set the Element's size to be twice as wide as the size setting. + +There are a couple of widgets where one of the size values is in pixels rather than characters. This is true for Progress Meters and Sliders. The second parameter is the 'height' in pixels. + +#### FlexForm - form-level variables overview +A summary of the variables that can be changed when a FlexForm is created + + default_element_size - set default size for all elements in the form + auto_size_text- true/false autosizing turned on / off + scale - set scale value for all elements + button_color- default button color (foreground, background) + font - font name and size for all text items + progress_bar_color - progress bar colors + is_tabbed_form - true/false indicates form is a tabbed or normal form + border_depth - style setting for buttons, input fields + auto_close - true/false indicates if form will automatically close + auto_close_duration - how long in seconds before closing form + icon - filename for icon that's displayed on the window on taskbar + + +## Elements +"Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. + + Text + Single Line Input + Buttons including these types: + File Browse + Folder Browse + Non-closing return + Close form + Realtime + Checkboxes + Radio Buttons + Listbox + Slider + Multi-line Text Input + Scroll-able Output + Progress Bar + Async/Non-Blocking Windows + Tabbed forms + Persistent Windows + Redirect Python Output/Errors to scrolling Window + "Higher level" APIs (e.g. MessageBox, YesNobox, ...) + + +### Output Elements +Building a form is simply making lists of Elements. Each list is a row in the overall GUI dialog box. The definition looks something like this: + + layout = [ [row 1 element, row 1 element], + [row 2 element, row 2 element, row 2 element] ] +The code is a crude representation of the GUI, laid out in text. +#### Text Element + + layout = [[sg.Text('This is what a Text Element looks like')]] + + + ![textelem](https://user-images.githubusercontent.com/13696193/42670173-4c1fcb40-8627-11e8-851a-5a9ee4672320.jpg) + + +The most basic element is the Text element. It simply displays text. Many of the 'options' that can be set for a Text element are shared by other elements. Size, Scale are a couple that you will see in every element. + + Text(Text, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None, + text_color=None, + justification=None) +. + + Text - The text that's displayed + size - Element's size + auto_size_text - Bool. Change width to match size of text + font - Font name and size to use + text_color - text color + justification - Justification for the text. String - 'left', 'right', 'center' + +Some commonly used elements have 'shorthand' versions of the functions to make the code more compact. The functions `T` and `Txt` are the same as calling `Text`. + +**Fonts** in PySimpleGUI are always in this format: + + (font_name, point_size) + +The default font setting is + + ("Helvetica", 10) + +**Color** in PySimpleGUI are always in this format: + + (foreground, background) + +The values foreground and background can be the color names or the hex value formatted as a string: + + "#RRGGBB" + +**auto_size_text** +A `True` value for `auto_size_text`, when placed on any Element, indicates that the width of the Element should be shrunk do the width of the text. This is particularly useful with `Buttons` as fixed-width buttons are somewhat crude looking. The default value is `False`. You will often see this setting on FlexForm definitions. + +**Shorthand functions** +The shorthand functions for `Text` are `Txt` and `T` + + +#### Multiline Text Element + + layout = [[sg.Multiline('This is what a Multi-line Text Element looks like', size=(45,5))]] +![multiline text](https://user-images.githubusercontent.com/13696193/42670464-0824c754-8629-11e8-9741-6ed08f924618.jpg) +This Element doubles as both an input and output Element. The `DefaultText` optional parameter is used to indicate what to output to the window. + + Multiline(default_text='', + enter_submits = False, + scale=(None, None), + size=(None, None), + auto_size_text=None) +. + + default_text - Text to display in the text box + enter_submits - Bool. If True, pressing Enter key submits form + scale - Element's scale + size - Element's size + auto_size_text - Bool. Change width to match size of text + +#### Output Element +Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. More on this later. + + form.AddRow(gg.Output(size=(100,20))) + +![output element](https://user-images.githubusercontent.com/13696193/42704820-5446959c-869f-11e8-849e-047ea280387a.jpg) + + Output(scale=(None, None), + size=(None, None)) +. + + scale - How much to scale size of element + size - Size of element (width, height) in characters + +### Input Elements + These make up the majority of the form definition. Optional variables at the Element level override the Form level values (e.g. `size` is specified in the Element). All input Elements create an entry in the list of return values. A Text Input Element creates a string in the list of items returned. + +#### Text Input Element + + layout = [[sg.InputText('Default text')]] +![inputtext](https://user-images.githubusercontent.com/13696193/42693515-610a716c-867d-11e8-9a00-7e7fcf771230.jpg) + + def InputText(default_text = '', + scale=(None, None), + size=(None, None), + auto_size_text=None, + password_char='') +. + + default_text - Text initially shown in the input box + scale - Amount size is scaled by + size - (width, height) of element in characters + auto_size_text- Bool. True is element should be sized to fit text + password_char - Character that will be used to replace each entered character. Setting to a value indicates this field is a password entry field + +Shorthand functions that are equivalent to `InputText` are `Input` and `In` + + +#### Combo Element +Also known as a drop-down list. Only required parameter is the list of choices. The return value is a string matching what's visible on the GUI. + + layout = [[sg.InputCombo(['choice 1', 'choice 2'])]] + +![combo](https://user-images.githubusercontent.com/13696193/42694431-631c4108-8680-11e8-8e99-c1a642734464.jpg) + + InputCombo(values, + scale=(None, None), + size=(None, None), + auto_size_text=None) +. + + values - Choices to be displayed. List of strings + scale - Amount to scale size by + size - (width, height) of element in characters + auto_size_text - Bool. True if size should fit the text length + +#### Listbox Element +The standard listbox like you'll find in most GUIs. Note that the return values from this element will be a ***list of results, not a single result***. This is because the user can select more than 1 item from the list (if you set the right mode). + + layout = [[sg.Listbox(values=['Listbox 1', 'Listbox 2', 'Listbox 3'], size=(30, 6))]] + +![snap0130](https://user-images.githubusercontent.com/13696193/43115859-2fbf0646-8ed3-11e8-9979-bbee8eaebfab.jpg) + + + Listbox(values, + select_mode=None, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None) +. + + values - Choices to be displayed. List of strings + select_mode - Defines how to list is to operate. + Choices include constants or strings: + Constants version: + LISTBOX_SELECT_MODE_BROWSE + LISTBOX_SELECT_MODE_EXTENDED + LISTBOX_SELECT_MODE_MULTIPLE + LISTBOX_SELECT_MODE_SINGLE - the default + Strings version: + 'browse' + 'extended' + 'multiple' + 'single' + scale - Amount to scale size by + size - (width, height) of element in characters + auto_size_text - Bool. True if size should fit the text length + +The `select_mode` option can be a string or a constant value defined as a variable. Generally speaking strings are used for these kinds of options. + +#### Slider Element +Sliders have a couple of slider-specific settings as well as appearance settings. Examples include the `orientation` and `range` settings. + + layout = [[sg.Slider(range=(1,500), default_value=222, size=(20,15), orientation='horizontal', font=('Helvetica', 12))]] + +![snap0129](https://user-images.githubusercontent.com/13696193/43115741-e1cb52c8-8ed2-11e8-80bb-0e99ae846ec1.jpg) + + Slider(range=(None,None), + default_value=None, + orientation=None, + border_width=None, + relief=None, + scale=(None, None), + size=(None, None), + font=None): +. + + range - (min, max) slider's range + default_value - default setting (within range) + orientation - 'horizontal' or 'vertical' ('h' or 'v' work) + border_width - how deep the widget looks + relief - relief style. Values are same as progress meter relief values. Can be a constant or a string: + RELIEF_RAISED= 'raised' + RELIEF_SUNKEN= 'sunken' + RELIEF_FLAT= 'flat' + RELIEF_RIDGE= 'ridge' + RELIEF_GROOVE= 'groove' + RELIEF_SOLID = 'solid' + scale - Amount to scale size by + size - (width, height) of element in characters + auto_size_text - Bool. True if size should fit the text + +#### Radio Button Element +Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. + + layout = [[sg.Radio('My first Radio!', "RADIO1", default=True), sg.Radio('My second radio!', "RADIO1")]] + +![radio element](https://user-images.githubusercontent.com/13696193/42705705-327b4b6c-86a2-11e8-81a7-740e57646ba8.jpg) + + Radio(text, + group_id, + default=False, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None) + +. + + text - Text to display next to button + group_id - Groups together multiple Radio Buttons. Can be any value + default - Bool. Initial state + scale - Amount to scale size of element + size- (width, height) size of element in characters + auto_size_text - Bool. True if should size width to fit text + font - Font type and size for text display + + +#### Checkbox Element +Checkbox elements are like Radio Button elements. They return a bool indicating whether or not they are checked. + + layout = [[sg.Checkbox('My first Checkbox!', default=True), sg.Checkbox('My second Checkbox!')]] + +![checkbox element](https://user-images.githubusercontent.com/13696193/42717015-655d73d2-86cc-11e8-9c69-3c810f48e578.jpg) + + + Checkbox(text, + default=False, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None): +. + + text - Text to display next to checkbox + default- Bool. Initial state + scale - Amount to scale size of element + size - (width, height) size of element in characters + auto_size_text- Bool. True if should size width to fit text + font- Font type and size for text display + + +#### Spin Element +An up/down spinner control. The valid values are passed in as a list. + + layout = [[sg.Spin([i for i in range(1,11)], initial_value=1), sg.Text('Volume level')]] + +![spin element](https://user-images.githubusercontent.com/13696193/42717231-8ddb51d4-86cd-11e8-827a-75f2237477fa.jpg) + + Spin(values, + intiial_value=None, + scale=(None, None), + size=(None, None), + auto_size_text=None, + font=None) +. + + values - List of valid values + initial_value - String with initial value + scale - Amount to scale size of element + size - (width, height) size of element in characters + auto_size_text - Bool. True if should size width to fit text + font - Font type and size for text display + +#### Button Element +Buttons are the most important element of all! They cause the majority of the action to happen. After all, it's a button press that will get you out of a form, whether it but Submit or Cancel, one way or another a button is involved in all forms. The only exception is to this is when the user closes the window using the "X" in the upper corner which means no button was involved. + +The Types of buttons include: +* Folder Browse +* File Browse +* Close Form +* Read Form +* Realtime + + + Close Form - Normal buttons like Submit, Cancel, Yes, No, etc, are "Close Form" buttons. They cause the input values to be read and then the form is closed, returning the values to the caller. + +Folder Browse - When clicked a folder browse dialog box is opened. The results of the Folder Browse dialog box are written into one of the input fields of the form. + +File Browse - Same as the Folder Browse except rather than choosing a folder, a single file is chosen. + +Read Form - This is an async form button that will read a snapshot of all of the input fields, but does not close the form after it's clicked. + +Realtime - This is another async form button. Normal button clicks occur after a button's click is released. Realtime buttons report a click the entire time the button is held down. + +While it's possible to build forms using the Button Element directly, you should never need to do that. There are pre-made buttons and shortcuts that will make life much easier. The most basic Button element call to use is `SimpleButton` + + SimpleButton(text, + scale=(None, None), + size=(None, None), + auto_size_button=None, + button_color=None, + font=None) + +Pre-made buttons include: + + OK + Ok + Submit + Cancel + Yes + No + FileBrowse + FolderBrowse +. + layout = [[sg.OK(), sg.Cancel()]] + +![ok cancel](https://user-images.githubusercontent.com/13696193/42717733-1803f584-86d1-11e8-9223-36b782971b9f.jpg) + +The FileBrowse and FolderBrowse buttons both fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. + +The default value for `Target` is `(ThisRow, -1)`. ThisRow is a special value that tells the GUI to use the same row as the button. The Y-value of -1 means the field one value to the left of the button. For a File or Folder Browse button, the field that it fills are generally to the left of the button is most cases. + +Let's examine this form as an example: + +![button target example](https://user-images.githubusercontent.com/13696193/42718075-b4dcb61e-86d3-11e8-904c-d709dd364108.jpg) + +The `InputText` element is located at (1,0)... row 1, column 0. The `Browse` button is located at position (2,0). The Target for the button could be any of these values: + + Target = (1,0) + Target = (-1,0) +The code for the entire form could be: + + layout = [[sg.T('Source Folder')], + [sg.In()], + [sg.FolderBrowse(Target=(-1,0)), sg.OK()]] + +**Custom Buttons** +Not all buttons are created equal. A button that closes a form is different that a button that returns from the form without closing it. If you want to define your own button, you will generally do this with the Button Element `SimpleButton`, which closes the form when clicked. + +layout = [[sg.SimpleButton('My Button')]] + +![singlebutton](https://user-images.githubusercontent.com/13696193/42718281-9453deca-86d5-11e8-83c7-4b6d33720858.jpg) + +All buttons can have their text changed by changing the `button_text` variable in the button call. It is this text that is returned when a form is read. This text will be what tells you which button is called so make it unique. Most of the convenience buttons (Submit, Cancel, Yes, etc) are all SimpleButtons. The two that are not are `FileBrowse` and `FolderBrowse`. They clearly do not close the form. Instead they bring up a file or folder browser dialog box. + +**Button Images** +Now this is an exciting feature not found in many simplified packages.... images on buttons! You can make a pretty spiffy user interface with the help of a few button images. + +Your button images need to be in PNG or GIF format. When you make a button with an image, set the button background to the same color as the background. There's a button color TRANSPARENT_BUTTON that you can set your button color to in order for it to blend into the background. Note that this value is currently the same as the color as the default system background on Windows. + +This example comes from the `Demo Media Player.py` example program. Because it's a non-blocking button, it's defined as `ReadFormButton`. You also put images on blocking buttons by using `SimpleButton`. + + + sg.ReadFormButton('Restart Song', button_color=sg.TRANSPARENT_BUTTON, + image_filename=image_restart, image_size=(50, 50), image_subsample=2, border_width=0) + +Three parameters are used for button images. + + image_filename - Filename. Can be a relative path + image_size - Size of image file in pixels + image_subsample - Amount to divide the size by. 2 means your image will be 1/2 the size. 3 means 1/3 + +Here's an example form made with button images. + +![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) + +You'll find the source code in the file Demo Media Player. Here is what the button calls look like to create media player form + + sg.ReadFormButton('Pause', button_color=sg.TRANSPARENT_BUTTON, + image_filename=image_pause, image_size=(50, 50), image_subsample=2, border_width=0) + +This is one you'll have to experiment with at this point. Not up for an exhaustive explanation. + + **Realtime Buttons** + + Normally buttons are considered "clicked" when the mouse button is let UP after a downward click on the button. What about times when you need to read the raw up/down button values. A classic example for this is a robotic remote control. Building a remote control using a GUI is easy enough. One button for each of the directions is a start. Perhaps something like this: + +![snap0135](https://user-images.githubusercontent.com/13696193/43440841-bcf8d184-9466-11e8-9f7b-30a1d5ce32d3.jpg) + +This form has 2 button types. There's the normal "Simple Button" (Quit) and 4 "Realtime Buttons". + +Here is the code to make, show and get results from this form: + + form = sg.FlexForm('Robotics Remote Control', auto_size_text=True) + + form_rows = [[sg.Text('Robotics Remote Control')], + [sg.T(' '*10), sg.RealtimeButton('Forward')], + [ sg.RealtimeButton('Left'), sg.T(' '*15), sg.RealtimeButton('Right')], + [sg.T(' '*10), sg.RealtimeButton('Reverse')], + [sg.T('')], + [sg.Quit(button_color=('black', 'orange'))] + ] + + form.LayoutAndRead(form_rows, non_blocking=True) + +Somewhere later in your code will be your main event loop. This is where you do your polling of devices, do input/output, etc. It's here that you will read your form's buttons. + + while (True): + # This is the code that reads and updates your window + button, values = form.ReadNonBlocking() + if button is not None: + sg.Print(button) + if button == 'Quit' or values is None: + break + time.sleep(.01) + +This loop will read button values and print them. When one of the Realtime buttons is clicked, the call to `form.ReadNonBlocking` will return a button name matching the name on the button that was depressed. It will continue to return values as long as the button remains depressed. Once released, the ReadNonBlocking will return None for buttons ules anutton was clicked. + +**File Types** +The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is + + FileTypes=(("ALL Files", "*.*"),) + +This code produces a form where the Browse button only shows files of type .TXT + + layout = [[sg.In() ,sg.FileBrowse(file_types=(("Text Files", "*.txt"),))]] + + ***The ENTER key*** + The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. + + --- +#### ProgressBar +The `ProgressBar` element is used to build custom Progress Bar forms. It is HIGHLY recommended that you use the functions that provide a complete progress meter solution for you. Progress Meters are not easy to work with because the forms have to be non-blocking and they are tricky to debug. + +The **easiest** way to get progress meters into your code is to use the `EasyProgessMeter` API. This consists of a pair of functions, `EasyProgessMeter` and `EasyProgressMeterCancel`. You can easily cancel any progress meter by calling it with the current value = max value. This will mark the meter as expired and close the window. +You've already seen EasyProgressMeter calls presented earlier in this readme. + + sg.EasyProgressMeter('My Meter', i+1, 1000, 'Optional message') + +The return value for `EasyProgressMeter` is: +`True` if meter updated correctly +`False` if user clicked the Cancel button, closed the form, or vale reached the max value. +**Customized Progress Bar** +If you want a bit more customization of your meter, then you can go up 1 level and use the calls to `ProgressMeter` and `ProgressMeterUpdate`. These APIs behave like an object we're all used to. First you create the `ProgressMeter` object, then you call the `Update` method to update it. + +You setup the progress meter by calling + + my_meter = ProgressMeter(title, + max_value, + *args, + orientantion=None, + bar_color=DEFAULT_PROGRESS_BAR_COLOR, + button_color=None, + size=DEFAULT_PROGRESS_BAR_SIZE, + scale=(None, None), + border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH) +Then to update the bar within your loop + + return_code = ProgressMeterUpdate(my_meter, + value, + *args): +Putting it all together you get this design pattern + + my_meter = sg.ProgressMeter('Meter Title', 100000, orentation='Vert') + + for i in range(0, 100000): + sg.ProgressMeterUpdate(my_meter, i+1, 'Some variable', 'Another variable') + + +The final way of using a Progress Meter with PySimpleGUI is to build a custom form with a `ProgressBar` Element in the form. You will need to run your form as a non-blocking form. When you are ready to update your progress bar, you call the `UpdateBar` method for the `ProgressBar` element itself. + + +#### Output +The Output Element is a re-direction of Stdout. Anything "printed" will be displayed in this element. + + Output(scale=(None, None), + size=(None, None)) + +Here's a complete solution for a chat-window using an Async form with an Output Element + + import PySimpleGUI as sg + # Blocking form that doesn't close + def ChatBot(): + with sg.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + layout = [[(sg.Text('This is where standard out is being routed', size=[40, 1]))], + [sg.Output(size=(80, 20))], + [sg.Multiline(size=(70, 5), enter_submits=True), sg.ReadFormButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0])), sg.SimpleButton('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]] + # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form + # if you call LayoutAndRead from here, then you will miss the first button click + form.Layout(layout) + # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # + while True: + button, value = form.Read() + if button == 'SEND': + print(value) + else: + break + + +## Tabbed Forms +Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format + + results = ShowTabbedForm('Title for the form', + (form,layout,'Tab 1 label'), + (form2,layout2, 'Tab 2 label'), ...) + +Each of the tabs of the form is in fact a form. The same steps are taken to create the form as before. A `FlexForm` is created, then rows are filled with Elements, and finally the form is shown. When calling `ShowTabbedForm`, each form is passed in as a tuple. The tuple has the format: `(the form, the rows, a string shown on the tab)` + +Results are returned as a list of lists. For each form you'll get a list that's in the same format as a normal form. A single tab's values would be: + + (button, (values)) + +Recall that values is a list as well. Multiple tabs in the form would return like this: + + ((button1, (values1)), (button2, (values2)) + + ## Colors ## +Starting in version 2.5 you can change the background colors for the window and the Elements. + +Your forms can go from this: +![snap0155](https://user-images.githubusercontent.com/13696193/43273879-a9fdc10a-90cb-11e8-8c20-4f6a244ebe2f.jpg) + + +to this... with one function call... + +![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) + + + +While you can do it on an element by element or form level basis, the easiest way, by far, is a call to `SetOptions`. + +Be aware that once you change these options they are changed for the rest of your program's execution. All of your forms will have that look and feel, until you change it to something else (which could be the system default colors. + +This call sets all of the different color options. + + SetOptions(background_color='#9FB8AD', + text_element_background_color='#9FB8AD', + element_background_color='#9FB8AD', + scrollbar_color=None, + input_elements_background_color='#F7F3EC', + progress_meter_color = ('green', 'blue') + button_color=('white','#475841')) + + + +## Global Settings +**Global Settings** +Let's have some fun customizing! Make PySimpleGUI look the way you want it to look. You can set the global settings using the function `PySimpleGUI.SetOptions`. Each option has an optional parameter that's used to set it. + + SetOptions(icon=None + button_color=(None,None) + element_size=(None,None), + margins=(None,None), + element_padding=(None,None) + auto_size_text=None + auto_size_buttons=None + font=None + border_width=None + slider_border_width=None + slider_relief=None + slider_orientation=None + autoclose_time=None + message_box_line_width=None + progress_meter_border_depth=None + progress_meter_style=None + progress_meter_relief=None + progress_meter_color=None + progress_meter_size=None + text_justification=None + background_color=None + element_background_color=None + text_element_background_color=None + input_elements_background_color=None + scrollbar_color=None, text_color=None + debug_win_size=(None,None) + window_location=(None,None) + +Explanation of parameters + + icon - filename of icon used for taskbar and title bar + button_color - button color (foreground, background) + element_size - element size (width, height) in characters + margins - tkinter margins around outsize + element_padding - tkinter padding around each element + auto_size_text - autosize the elements to fit their text + auto_size_buttons - autosize the buttons to fit their text + font - font used for elements + border_width - amount of bezel or border around sunken or raised elements + slider_border_width - changes the way sliders look + slider_relief - changes the way sliders look + slider_orientation - changes orientation of slider + autoclose_time - time in seconds for autoclose boxes + message_box_line_width - number of characers in a line of text in message boxes + progress_meter_border_depth - amount of border around raised or lowered progress meters + progress_meter_style - style of progress meter as defined by tkinter + progress_meter_relief - relief style + progress_meter_color - color of the bar and background of progress meters + progress_meter_size - size in (characters, pixels) + background_color - Color of the main window's background + element_background_color - Background color of the elements + text_element_background_color - Text element background color + input_elements_background_color - Input fields background color + scrollbar_color - Color for scrollbars (may not always work) + text_color - Text element default text color + text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' + debug_win_size - size of the Print output window + window_location - location on the screen (x,y) of window's top left cornder + + +These settings apply to all forms `SetOptions`. The Row options and Element options will take precedence over these settings. Settings can be thought of as levels of settings with the Form-level being the highest and the Element-level the lowest. Thus the levels are: + + - Form level + - Row level + - Element level + +Each lower level overrides the settings of the higher level. Once settings have been changed, they remain changed for the duration of the program (unless changed again). + +## Asynchronous (Non-Blocking) Forms +So you want to be a wizard do ya? Well go boldly! While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. With asynchronous forms the form is shown, user input is read, but your code keeps right on chugging. YOUR responsibility is to call `PySimpleGUI.ReadNonBlocking` on a periodic basis. Once a second or more will produce a reasonably snappy GUI. + +When do you use a non-blocking form? A couple of examples are +* A media file player like an MP3 player +* A status dashboard that's periodically updated +* Progress Meters - when you want to make your own progress meters +* Output using print to a scrolled text element. Good for debugging. + +Word of warning... version 2.2, the currently released, and upcoming version 2.3 differ in the return code for the `ReadNonBlocking` call. Previously the function returned 2 values, except when the form is closed using the "X" which returned a single value of `None`. The *new* way is that `ReadNonBlocking` always returns 2 values. If the user closed the form with the "X" then the return values will be None, None. You will want to key off the second value to catch this case. +The proper code to check if the user has exited the form will be a polling-loop that looks something like this: + + while True: + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + +We're going to build an app that does the latter. It's going to update our form with a running clock. + +The basic flow and functions you will be calling are: +Setup + + + form = FlexForm() + form_rows = ..... + form.LayoutAndRead(form_rows, non_blocking=True) + + +Periodic refresh + + form.ReadNonBlocking() +If you need to close the form + + form.CloseNonBlockingForm() + +Rather than the usual `form.LayoutAndRead()` call, we're manually adding the rows (doing the layout) and then showing the form. After the form is shown, you simply call `form.ReadNonBlocking()` every now and then. + +When you are ready to close the form (assuming the form wasn't closed by the user or a button click) you simply call `form.CloseNonBlockingForm()` + +**Example - Running timer that updates** +See the sample code on the GitHub named Demo Media Player for another example of Async Forms. We're going to make a form and update one of the elements of that form every .01 seconds. Here's the entire code to do that. + + + import PySimpleGUI as sg + import time + + # form that doesn't block + # Make a form, but don't use context manager + form = sg.FlexForm('Running Timer', auto_size_text=True) + # Create a text element that will be updated with status information on the GUI itself + output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20)) + # Create the rows + form_rows = [[sg.Text('Non-blocking GUI with updates')], + [output_element], + [sg.SimpleButton('Quit')]] + # Layout the rows of the form and perform a read. Indicate the form is non-blocking! + form.LayoutAndRead(form_rows, non_blocking=True) + + # + # Some place later in your code... + # You need to perform a ReadNonBlocking on your form every now and then or + # else it won't refresh + # + + for i in range(1, 1000): + output_element.Update('{:02d}:{:02d}.{:02d}'.format(*divmod(int(i / 100), 60), i % 100)) + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': + break + time.sleep(.01) + else: + form.CloseNonBlockingForm() + + + +What we have here is the same sequence of function calls as in the description. Get a form, add rows to it, show the form, and then refresh it every now and then. + +The new thing in this example is the call use of the Update method for the Text Element. The first thing we do inside the loop is "update" the text element that we made earlier. This changes the value of the text field on the form. The new value will be displayed when `form.ReadNonBlocking()` is called. + +Note the `else` statement on the for loop. This is needed because we're about to exit the loop while the form is still open. The user has not closed the form using the X nor a button so it's up to the caller to close the form using `CloseNonBlockingForm`. + +That's it... this example follows the async design pattern well. + + + +## Sample Applications +Use the example programs as a starting basis for your GUI. Copy, paste, modify and run! The demo files are: + +`Demo Recipes.py` - Sample forms for all major form types and situations. This is the place to get your code template from. Includes asynchronous forms, etc. + +`Demo DisplayHash1and256.py` - Demonstrates using High Level API calls to get a filename + +`Demo DupliucateFileFinder.py` - Demonstrates High Level API to get a folder & Easy Progress Meter to show progress of the file scanning + +`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. If anyone wants to help me package this application up, I could use a hand. + +## Fun Stuff +Here are some things to try if you're bored or want to further customize + +**Debug Output** +Be sure and check out the EasyPrint (Print) function described in the high-level API section. Leave your code the way it is, route your stdout and stderror to a scrolling window. + +For a fun time, add these lines to the top of your script + + import PySimpleGUI as sg + print = sg.Print + +This will turn all of your print statements into prints that display in a window on your screen rather than to the terminal. + +**Look and Feel** +Dial in the look and feel that you like with the `SetOptions` function. You can change all of the defaults in one function call. One line of code to customize the entire GUI. + +**ObjToString** +Ever wanted to easily display an objects contents easily? Use ObjToString to get a nicely formatted recursive walk of your objects. +This statement: + + print(sg.ObjToSting(x)) + +And this was the output + + + abc = abc + attr12 = 12 + c = + b = + a = + attr1 = 1 + attr2 = 2 + attr3 = three + attr10 = 10 + attrx = x + +You'll quickly wonder how you ever coded without it. + +--- +# Known Issues +While not an "issue" this is a ***stern warning*** + +## **Do not attempt** to call `PySimpleGUI` from multiple threads! It's `tkinter` based and `tkinter` has issues with multiple threads + +**Progress Meters** - the visual graphic portion of the meter may be off. May return to the native tkinter progress meter solution in the future. Right now a "custom" progress meter is used. On the bright side, the statistics shown are extremely accurate and can tell you something about the performance of your code. + +**Async Forms** - these include the 'easy' forms (EasyProgressMeter and EasyPrint/Print). If you start overlapping having Async forms open with normal forms then things get a littler squirrelly. Still tracking down the issues and am making it more solid every day possible. You'll know there's an issue when you see blank form. + +**EasyPrint** - EasyPrint is a new feature that's pretty awesome. You print and the output goes to a window, with a scroll bar, that you can copy and paste from. Being a new feature, it's got some potential problems. There are known interaction problems with other GUI windows. For example, closing a Print window can also close other windows you have open. For now, don't close your debug print window until other windows are closed too. + +## Contributing + +A MikeTheWatchGuy production... entirely responsible for this code.... unless it causes you trouble in which case I'm not at all responsible. + +## Versions +|Version | Description | +|--|--| +| 1.0.9 | July 10, 2018 - Initial Release | +| 1.0.21 | July 13, 2018 - Readme updates | +| 2.0.0 | July 16, 2018 - ALL optional parameters renamed from CamelCase to all_lower_case +| 2.1.1 | July 18, 2018 - Global settings exposed, fixes +| 2.2.0| July 20, 2018 - Image Elements, Print output +| 2.3.0 | July 23, 2018 - Changed form.Read return codes, Slider Elements, Listbox element. Renamed some methods but left legacy calls in place for now. +| 2.4.0 | July 24, 2018 - Button images. Fixes so can run on Raspberry Pi +| 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. +| 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ +| 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting + + +### Release Notes +2.3 - Sliders, Listbox's and Image elements (oh my!) + +If using Progress Meters, avoid cancelling them when you have another window open. It could lead to future windows being blank. It's being worked on. + +New debug printing capability. `sg.Print` + +2.5 Discovered issue with scroll bar on `Output` elements. The bar will match size of ROW not the size of the element. Normally you never notice this due to where on a form the `Output` element goes. + +Listboxes are still without scrollwheels. The mouse can drag to see more items. The mouse scrollwheel will also scroll the list and will `page up` and `page down` keys. + +2.7 Is the "feature complete" release. Pretty much all features are done and in the code + + +### Upcoming +Make suggestions people! Future release features + +Columns. How multiple columns would be specified in the SDK interface are still being designed. + +Port to other graphic engines. Hook up the front-end interface to a backend other than tkinter. Qt, WxPython, etc. + + + +## Code Condition + + Make it run + Make it right + Make it fast + +It's a recipe for success if done right. PySimpleGUI has completed the "Make it run" phase. It's far from "right" in many ways. These are being worked on. The module is particularly poor for PEP 8 compliance. It was a learning exercise that turned into a somewhat complete GUI solution for lightweight problems. + +While the internals to PySimpleGUI are a tad sketchy, the public interfaces into the SDK are more strictly defined and comply with PEP 8 for the most part. + +Please log bugs and suggestions in the GitHub! It will only make the code stronger and better in the end, a good thing for us all, right? + +## Design + +A moment about the design-spirit of `PySimpleGUI`. From the beginning, this package was meant to take advantage of Python's capabilities with the goal of programming ease. + +**Single File** +While not the best programming practice, the implementation resulted in a single file solution. Only one file is needed, PySimpleGUI.py. You can post this file, email it, and easily import it using one statement. + +**Functions as objects** +In Python, functions behave just like object. When you're placing a Text Element into your form, you may be sometimes calling a function and other times declaring an object. If you use the word Text, then you're getting an object. If you're using `Txt`, then you're calling a function that returns a `Text` object. + +**Lists** +It seemed quite natural to use Python's powerful list constructs when possible. The form is specified as a series of lists. Each "row" of the GUI is represented as a list of Elements. When the form read returns the results to the user, all of the results are presented as a single list. This makes reading a form's values super-simple to do in a single line of Python code. + + +## Authors +MikeTheWatchGuy + +## License + +GNU Lesser General Public License (LGPL 3) + + +## Acknowledgments + +* Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence +* [Fredrik Lundh](https://wiki.python.org/moin/FredrikLundh) for his work on `tkinter` + + +## How Do I +Finally, I must thank the fine folks at How Do I. +https://github.com/gleitz/howdoi +Their utility has forever changed the way and pace in which I can program. I urge you to try the HowDoI.py application here on GitHub. Trust me, **it's going to be worth the effort!** +Here are the steps to run that application + + Install howdoi: + pip install howdoi + Test your install: + python -m howdoi howdoi.py + To run it: + Python HowDoI.py + +The pip command is all there is to the setup. + +The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. +For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. +![snap0109](https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg) + +In the hands of a competent programmer, this tool is **amazing**. It's a must-try kind of program that has completely changed my programming process. I'm not afraid of asking for help! You just have to be smart about using what you find. + +The PySimpleGUI window that the results are shown in is an 'input' field which means you can copy and paste the results right into your code. \ No newline at end of file From cb3975083b848e3186ad7ba501361bbdfd47f9b9 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 3 Aug 2018 19:32:07 -0400 Subject: [PATCH 109/209] remvoved import of readme --- docs/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index 301abe654..4bd996253 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -9,7 +9,7 @@ Welcome to PySimpleGUI's documentation! .. toctree:: :maxdepth: 2 :caption: Contents: -..\readme.md + Indices and tables From 453c07b62edcb7cb743e5773b49a8ea77f92af7f Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 3 Aug 2018 19:33:43 -0400 Subject: [PATCH 110/209] renamed readme to index --- docs/{readme.md => index.md} | 0 docs/index.rst | 20 -------------------- 2 files changed, 20 deletions(-) rename docs/{readme.md => index.md} (100%) delete mode 100644 docs/index.rst diff --git a/docs/readme.md b/docs/index.md similarity index 100% rename from docs/readme.md rename to docs/index.md diff --git a/docs/index.rst b/docs/index.rst deleted file mode 100644 index 4bd996253..000000000 --- a/docs/index.rst +++ /dev/null @@ -1,20 +0,0 @@ -.. PySimpleGUI documentation master file, created by - sphinx-quickstart on Fri Aug 3 19:09:46 2018. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -Welcome to PySimpleGUI's documentation! -======================================= - -.. toctree:: - :maxdepth: 2 - :caption: Contents: - - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` From 31a85377093a66be27e0180e91f996b626023ab1 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 4 Aug 2018 07:38:36 -0400 Subject: [PATCH 111/209] New Demo Func Callback Sim --- Demo_Func_Callback_Simulation.py | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Demo_Func_Callback_Simulation.py diff --git a/Demo_Func_Callback_Simulation.py b/Demo_Func_Callback_Simulation.py new file mode 100644 index 000000000..618ff94ea --- /dev/null +++ b/Demo_Func_Callback_Simulation.py @@ -0,0 +1,36 @@ +import PySimpleGUI as sg + +# This design pattern simulates button callbacks +# Note that callbacks are NOT a part of the package's interface to the +# caller intentionally. The underlying implementation actually does use +# tkinter callbacks. They are simply hidden from the user. + +# The callback functions +def button1(): + print('Button 1 callback') + +def button2(): + print('Button 2 callback') + +# Create a standard form +form = sg.FlexForm('Button callback example') +# Layout the design of the GUI +layout = [[sg.Text('Please click a button', auto_size_text=True)], + [sg.ReadFormButton('1'), sg.ReadFormButton('2'), sg.Quit()]] +# Show the form to the user +form.Layout(layout) + +# Event loop. Read buttons, make callbacks +while True: + # Read the form + button, value = form.Read() + # Take appropriate action based on button + if button == '1': + button1() + elif button == '2': + button2() + elif button =='Quit' or button is None: + break + +# All done! +sg.MsgBoxOK('Done') From 41561e8d54532f5ce6f4430e0499204fc4519345 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sun, 5 Aug 2018 23:17:42 -0400 Subject: [PATCH 112/209] Super Simple Demo initial checkin --- Demo_Super_Simple_Form.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Demo_Super_Simple_Form.py diff --git a/Demo_Super_Simple_Form.py b/Demo_Super_Simple_Form.py new file mode 100644 index 000000000..0d13708e8 --- /dev/null +++ b/Demo_Super_Simple_Form.py @@ -0,0 +1,13 @@ +import PySimpleGUI as sg + +form = sg.FlexForm('Simple data entry form') # begin with a blank form + +layout = [[sg.Text('Please enter your Name, Address, Phone')], + [sg.Text('Name', size=(15, 1)), sg.InputText()], + [sg.Text('Address', size=(15, 1)), sg.InputText()], + [sg.Text('Phone', size=(15, 1)), sg.InputText()], + [sg.Submit(), sg.Cancel()]] + +button, (name, address, phone) = form.LayoutAndRead(layout) + +print(name, address, phone) \ No newline at end of file From 99035fb5e8cca8fcb4a646511864844fb4d74ed2 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 6 Aug 2018 12:20:18 -0400 Subject: [PATCH 113/209] A bunch of fixes Removed some color defaults Added _ to some class methods so users won't get confused and call them. _close in particular. Fix for combobox problem Fixed CRASH when using tabbed forms demo due to rename _ Removed random colors --- PySimpleGUI.py | 74 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 29 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index b6c0d7380..d547fc0cd 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -9,7 +9,7 @@ import sys import textwrap -# ----====----====----==== Constants the use CAN safely change ====----====----====----# +# ----====----====----==== Constants the user CAN safely change ====----====----====----# DEFAULT_WINDOW_ICON = '' DEFAULT_ELEMENT_SIZE = (45,1) # In CHARACTERS DEFAULT_MARGINS = (10,5) # Margins for each LEFT/RIGHT margin is first term @@ -34,8 +34,8 @@ COLOR_SYSTEM_DEFAULT = '1234567890' # Colors should never be this long DEFAULT_BUTTON_COLOR = ('white', BLUES[0]) # Foreground, Background (None, None) == System Default +# DEFAULT_BUTTON_COLOR = COLOR_SYSTEM_DEFAULT # Foreground, Background (None, None) == System Default DEFAULT_ERROR_BUTTON_COLOR =("#FFFFFF", "#FF0000") -DEFAULT_CANCEL_BUTTON_COLOR = (GREENS[3], TANS[0]) DEFAULT_BACKGROUND_COLOR = None DEFAULT_ELEMENT_BACKGROUND_COLOR = None DEFAULT_TEXT_ELEMENT_BACKGROUND_COLOR = None @@ -646,9 +646,9 @@ def ButtonCallBack(self): self.ParentForm.Results[r][c] = True # mark this button's location in results # if the form is tabbed, must collect all form's results and destroy all forms if self.ParentForm.IsTabbedForm: - self.ParentForm.UberParent.Close() + self.ParentForm.UberParent._Close() else: - self.ParentForm.Close() + self.ParentForm._Close() self.ParentForm.TKroot.quit() if self.ParentForm.NonBlocking: self.ParentForm.TKroot.destroy() @@ -718,8 +718,6 @@ def UpdateBar(self, current_count): target_element = self.ParentForm.GetElementAtLocation(target) strvar = target_element.TKStringVar rc = strvar.set(self.TextToDisplay) - # update the progress bar counter - # self.TKProgressBar['value'] = self.CurrentValue self.TKProgressBar.Update(current_count) try: @@ -848,7 +846,7 @@ def AddRow(self, *args, auto_size_text=None): ''' Parms are a variable number of Elements ''' NumRows = len(self.Rows) # number of existing rows is our row number CurrentRowNumber = NumRows # this row's number - CurrentRow = Row(auto_size_text) # start with a blank row and build up + CurrentRow = Row(auto_size_text=auto_size_text) # start with a blank row and build up # ------------------------- Add the elements to a row ------------------------- # for i, element in enumerate(args): # Loop through list of elements and add them to the row element.Position = (CurrentRowNumber, i) @@ -900,17 +898,17 @@ def GetElementAtLocation(self, location): element = row.Elements[col_num] return element - def GetDefaultElementSize(self): + def _GetDefaultElementSize(self): return self.DefaultElementSize - def AutoCloseAlarmCallback(self): + def _AutoCloseAlarmCallback(self): try: if self.UberParent: window = self.UberParent else: window = self if window: - window.Close() + window._Close() self.TKroot.quit() self.RootNeedsDestroying = True except: @@ -953,7 +951,7 @@ def Refresh(self, Message=''): _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 return BuildResults(self) - def Close(self): + def _Close(self): try: self.TKroot.update() except: pass @@ -1008,10 +1006,10 @@ def __init__(self): def AddForm(self, form): self.FormList.append(form) - def Close(self): + def _Close(self): self.FormReturnValues = [] for form in self.FormList: - form.Close() + form._Close() self.FormReturnValues.append(form.ReturnValues) if not self.TKrootDestroyed: self.TKrootDestroyed = True @@ -1033,8 +1031,8 @@ def Input(default_text ='', scale=(None, None), size=(None, None), auto_size_tex return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text) # ------------------------- INPUT COMBO Element lazy functions ------------------------- # -def Combo(values, scale=(None, None), size=(None, None), auto_size_text=None): - return InputCombo(values=values, scale=scale, size=size, auto_size_text=auto_size_text) +def Combo(values, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None): + return InputCombo(values=values, scale=scale, size=size, auto_size_text=auto_size_text, background_color=background_color) def DropDown(values, scale=(None, None), size=(None, None), auto_size_text=None): return InputCombo(values=values, scale=scale, size=size, auto_size_text=auto_size_text) @@ -1331,15 +1329,15 @@ def CharWidthInPixels(): bc = MyFlexForm.ButtonColor else: bc = DEFAULT_BUTTON_COLOR - if bc == 'Random' or bc == 'random': - bc = GetRandomColorPair() border_depth = element.BorderWidth if btype != BUTTON_TYPE_REALTIME: - tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height,command=element.ButtonCallBack, justify=tk.LEFT, foreground=bc[0], background=bc[1], bd=border_depth) + tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height,command=element.ButtonCallBack, justify=tk.LEFT, bd=border_depth) else: - tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height, justify=tk.LEFT, foreground=bc[0], background=bc[1], bd=border_depth) + tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height, justify=tk.LEFT, bd=border_depth) tkbutton.bind('', element.ButtonReleaseCallBack) tkbutton.bind('', element.ButtonPressCallBack) + if bc != (None, None) and bc != COLOR_SYSTEM_DEFAULT: + tkbutton.config(foreground=bc[0], background=bc[1]) element.TKButton = tkbutton # not used yet but save the TK button in case wraplen = tkbutton.winfo_reqwidth() # width of widget in Pixels if element.ImageFilename: # if button has an image on it @@ -1389,7 +1387,16 @@ def CharWidthInPixels(): 'fieldbackground': element.BackgroundColor, 'background': element.BackgroundColor} }}) - except: pass + except: + try: + combostyle.theme_settings('combostyle', + settings={'TCombobox': + {'configure': + {'selectbackground': element.BackgroundColor, + 'fieldbackground': element.BackgroundColor, + 'background': element.BackgroundColor} + }}) + except: pass # ATTENTION: this applies the new style 'combostyle' to all ttk.Combobox combostyle.theme_use('combostyle') element.TKCombo = ttk.Combobox(tk_row_frame, width=width, textvariable=element.TKStringVar,font=font ) @@ -1602,7 +1609,7 @@ def ShowTabbedForm(title, *args, auto_close=False, auto_close_duration=DEFAULT_A uber.FormReturnValues.append(form.ReturnValues) # dangerous?? or clever? use the final form as a callback for autoclose - id = root.after(auto_close_duration * 1000, form.AutoCloseAlarmCallback) if auto_close else 0 + id = root.after(auto_close_duration * 1000, form._AutoCloseAlarmCallback) if auto_close else 0 icon = fav_icon if not _my_windows.user_defined_icon else _my_windows.user_defined_icon try: uber.TKroot.iconbitmap(icon) except: pass @@ -1631,7 +1638,7 @@ def StartupTK(my_flex_form): if my_flex_form.AutoClose: duration = DEFAULT_AUTOCLOSE_TIME if my_flex_form.AutoCloseDuration is None else my_flex_form.AutoCloseDuration - my_flex_form.TKAfterID = root.after(duration * 1000, my_flex_form.AutoCloseAlarmCallback) + my_flex_form.TKAfterID = root.after(duration * 1000, my_flex_form._AutoCloseAlarmCallback) if my_flex_form.NonBlocking: my_flex_form.TKroot.protocol("WM_WINDOW_DESTROYED", my_flex_form.OnClosingCallback()) pass @@ -1766,7 +1773,7 @@ def MsgBoxError(*args, button_color=DEFAULT_ERROR_BUTTON_COLOR, auto_close=False # ============================== MsgBoxCancel =====# # # # ===================================================# -def MsgBoxCancel(*args, button_color=DEFAULT_CANCEL_BUTTON_COLOR, auto_close=False, auto_close_duration=None, font=None): +def MsgBoxCancel(*args, button_color=None, auto_close=False, auto_close_duration=None, font=None): ''' Display a MsgBox with a single "Cancel" button. :param args: @@ -1782,7 +1789,7 @@ def MsgBoxCancel(*args, button_color=DEFAULT_CANCEL_BUTTON_COLOR, auto_close=Fal # ============================== MsgBoxOK =====# # Like MsgBox but only 1 button # # ===================================================# -def MsgBoxOK(*args, button_color=('white', 'black'), auto_close=False, auto_close_duration=None, font=None): +def MsgBoxOK(*args, button_color=None, auto_close=False, auto_close_duration=None, font=None): ''' Display a MsgBox with a single buttoned labelled "OK" :param args: @@ -1908,7 +1915,7 @@ def ProgressMeterUpdate(bar, value, *args): rc = bar.UpdateBar(value) if value >= bar.MaxValue or not rc: bar.BarExpired = True - bar.ParentForm.Close() + bar.ParentForm._Close() if bar.ParentForm.RootNeedsDestroying: try: _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 @@ -2102,6 +2109,15 @@ def eprint(*args, size=(None,None), end=None, sep=None): EasyPrint(*args, size=size, end=end, sep=sep) def EasyPrint(*args, size=(None,None), end=None, sep=None): + global _easy_print_data + + if _easy_print_data is None: + _easy_print_data = DebugWin(size=size) + _easy_print_data.Print(*args, end=end, sep=sep) + + + +def EasyPrintold(*args, size=(None,None), end=None, sep=None): if 'easy_print_data' not in EasyPrint.__dict__: # use a function property to save DebugWin object (static variable) EasyPrint.easy_print_data = DebugWin(size=size) if EasyPrint.easy_print_data is None: @@ -2111,7 +2127,7 @@ def EasyPrint(*args, size=(None,None), end=None, sep=None): def EasyPrintClose(): if 'easy_print_data' in EasyPrint.__dict__: if EasyPrint.easy_print_data is not None: - EasyPrint.easy_print_data.Close() + EasyPrint.easy_print_data._Close() EasyPrint.easy_print_data = None # del EasyPrint.easy_print_data @@ -2224,7 +2240,7 @@ def SetGlobalIcon(icon): # ============================== SetOptions =========# # Sets the icon to be used by default # # ===================================================# -def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), margins=(None,None), +def SetOptions(icon=None, button_color=None, element_size=(None,None), margins=(None,None), element_padding=(None,None),auto_size_text=None, auto_size_buttons=None, font=None, border_width=None, slider_border_width=None, slider_relief=None, slider_orientation=None, autoclose_time=None, message_box_line_width=None, @@ -2271,8 +2287,8 @@ def SetOptions(icon=None, button_color=(None,None), element_size=(None,None), ma raise FileNotFoundError _my_windows.user_defined_icon = icon - if button_color != (None,None): - DEFAULT_BUTTON_COLOR = (button_color[0], button_color[1]) + if button_color != None: + DEFAULT_BUTTON_COLOR = button_color if element_size != (None,None): DEFAULT_ELEMENT_SIZE = element_size From d603ab04bd55873792020fa2bfcc2fe02cccf303 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 7 Aug 2018 07:30:51 -0400 Subject: [PATCH 114/209] Text color option for all elements, New None value for checkbox initial value --- PySimpleGUI.py | 140 ++++++++++++++++++++++++------------------------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index d547fc0cd..1d98d7da1 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -38,8 +38,9 @@ DEFAULT_ERROR_BUTTON_COLOR =("#FFFFFF", "#FF0000") DEFAULT_BACKGROUND_COLOR = None DEFAULT_ELEMENT_BACKGROUND_COLOR = None +DEFAULT_ELEMENT_TEXT_COLOR = COLOR_SYSTEM_DEFAULT DEFAULT_TEXT_ELEMENT_BACKGROUND_COLOR = None -DEFAULT_TEXT_COLOR = 'black' +DEFAULT_TEXT_COLOR = COLOR_SYSTEM_DEFAULT DEFAULT_INPUT_ELEMENTS_COLOR = COLOR_SYSTEM_DEFAULT DEFAULT_SCROLLBAR_COLOR = None # DEFAULT_BUTTON_COLOR = (YELLOWS[0], PURPLES[0]) # (Text, Background) or (Color "on", Color) as a way to remember @@ -72,7 +73,7 @@ DEFAULT_METER_ORIENTATION = 'Horizontal' DEFAULT_SLIDER_ORIENTATION = 'vertical' DEFAULT_SLIDER_BORDER_WIDTH=1 -DEFAULT_SLIDER_RELIEF = tk.SUNKEN +DEFAULT_SLIDER_RELIEF = tk.FLAT DEFAULT_LISTBOX_SELECT_MODE = tk.SINGLE SELECT_MODE_MULTIPLE = tk.MULTIPLE @@ -153,7 +154,7 @@ def RGB(red,green,blue): return '#%02x%02x%02x' % (red,green,blue) # Element CLASS # # ------------------------------------------------------------------------- # class Element(): - def __init__(self, type, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None): + def __init__(self, type, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None): self.Size = size self.Type = type self.AutoSizeText = auto_size_text @@ -171,7 +172,7 @@ def __init__(self, type, scale=(None, None), size=(None, None), auto_size_text=N self.TextInputDefault = None self.Position = (0,0) # Default position Row 0, Col 0 self.BackgroundColor = background_color if background_color is not None else DEFAULT_ELEMENT_BACKGROUND_COLOR - return + self.TextColor = text_color if text_color is not None else DEFAULT_ELEMENT_TEXT_COLOR def __del__(self): try: @@ -195,7 +196,7 @@ def __del__(self): # Input Class # # ---------------------------------------------------------------------- # class InputText(Element): - def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None): + def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None, text_color=None): ''' Input a line of text Element :param default_text: Default value to display @@ -208,14 +209,13 @@ def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto self.DefaultText = default_text self.PasswordCharacter = password_char bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR - super().__init__(ELEM_TYPE_INPUT_TEXT, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg) - return + super().__init__(ELEM_TYPE_INPUT_TEXT, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=text_color) def ReturnKeyHandler(self, event): MyForm = self.ParentForm # search through this form and find the first button that will exit the form for row in MyForm.Rows: - for element in row.Elements: + for element in row: if element.Type == ELEM_TYPE_BUTTON: if element.BType == BUTTON_TYPE_CLOSES_WIN or element.BType == BUTTON_TYPE_READ_FORM: element.ButtonCallBack() @@ -229,7 +229,7 @@ def __del__(self): # ---------------------------------------------------------------------- # class InputCombo(Element): - def __init__(self, values, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None): + def __init__(self, values, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None): ''' Input Combo Box Element (also called Dropdown box) :param values: @@ -241,8 +241,7 @@ def __init__(self, values, scale=(None, None), size=(None, None), auto_size_text self.Values = values self.TKComboBox = None bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR - super().__init__(ELEM_TYPE_INPUT_COMBO, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg) - return + super().__init__(ELEM_TYPE_INPUT_COMBO, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=text_color) def __del__(self): try: @@ -257,7 +256,7 @@ def __del__(self): # ---------------------------------------------------------------------- # class Listbox(Element): - def __init__(self, values, select_mode=None, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None): + def __init__(self, values, select_mode=None, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None): ''' Listbox Element :param values: @@ -280,8 +279,7 @@ def __init__(self, values, select_mode=None, scale=(None, None), size=(None, Non else: self.SelectMode = DEFAULT_LISTBOX_SELECT_MODE bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR - super().__init__(ELEM_TYPE_INPUT_LISTBOX, scale=scale, size=size, auto_size_text=auto_size_text, font=font, background_color=bg) - return + super().__init__(ELEM_TYPE_INPUT_LISTBOX, scale=scale, size=size, auto_size_text=auto_size_text, font=font, background_color=bg, text_color=text_color) def __del__(self): try: @@ -296,7 +294,7 @@ def __del__(self): # Radio # # ---------------------------------------------------------------------- # class Radio(Element): - def __init__(self, text, group_id, default=False, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, font=None): + def __init__(self, text, group_id, default=False, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None, font=None): ''' Radio Button Element :param text: @@ -313,8 +311,7 @@ def __init__(self, text, group_id, default=False, scale=(None, None), size=(None self.TKRadio = None self.GroupID = group_id self.Value = None - super().__init__(ELEM_TYPE_INPUT_RADIO, scale=scale , size=size, auto_size_text=auto_size_text, font=font, background_color=background_color) - return + super().__init__(ELEM_TYPE_INPUT_RADIO, scale=scale , size=size, auto_size_text=auto_size_text, font=font, background_color=background_color, text_color=text_color) def __del__(self): try: @@ -327,7 +324,7 @@ def __del__(self): # Checkbox # # ---------------------------------------------------------------------- # class Checkbox(Element): - def __init__(self, text, default=False, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None): + def __init__(self, text, default=False, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None): ''' Check Box Element :param text: @@ -343,8 +340,7 @@ def __init__(self, text, default=False, scale=(None, None), size=(None, None), a self.Value = None self.TKCheckbox = None - super().__init__(ELEM_TYPE_INPUT_CHECKBOX, scale=scale, size=size, auto_size_text=auto_size_text, font=font, background_color=background_color) - return + super().__init__(ELEM_TYPE_INPUT_CHECKBOX, scale=scale, size=size, auto_size_text=auto_size_text, font=font, background_color=background_color, text_color=text_color) def __del__(self): try: @@ -360,7 +356,7 @@ def __del__(self): class Spin(Element): # Values = None # TKSpinBox = None - def __init__(self, values, initial_value=None, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None): + def __init__(self, values, initial_value=None, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None): ''' Spin Box Element :param values: @@ -375,7 +371,7 @@ def __init__(self, values, initial_value=None, scale=(None, None), size=(None, N self.DefaultValue = initial_value self.TKSpinBox = None bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR - super().__init__(ELEM_TYPE_INPUT_SPIN, scale, size, auto_size_text, font=font,background_color=bg) + super().__init__(ELEM_TYPE_INPUT_SPIN, scale, size, auto_size_text, font=font,background_color=bg, text_color=text_color) return def __del__(self): @@ -389,7 +385,7 @@ def __del__(self): # Multiline # # ---------------------------------------------------------------------- # class Multiline(Element): - def __init__(self, default_text='', enter_submits = False, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None): + def __init__(self, default_text='', enter_submits = False, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None): ''' Input Multi-line Element :param default_text: @@ -402,14 +398,14 @@ def __init__(self, default_text='', enter_submits = False, scale=(None, None), s self.DefaultText = default_text self.EnterSubmits = enter_submits bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR - super().__init__(ELEM_TYPE_INPUT_MULTILINE, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg) + super().__init__(ELEM_TYPE_INPUT_MULTILINE, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=text_color) return def ReturnKeyHandler(self, event): MyForm = self.ParentForm # search through this form and find the first button that will exit the form for row in MyForm.Rows: - for element in row.Elements: + for element in row: if element.Type == ELEM_TYPE_BUTTON: if element.BType == BUTTON_TYPE_CLOSES_WIN or element.BType == BUTTON_TYPE_READ_FORM: element.ButtonCallBack() @@ -443,7 +439,7 @@ def __init__(self, text, scale=(None, None), size=(None, None), auto_size_text=N bg = background_color # self.Font = Font if Font else DEFAULT_FONT # i=1/0 - super().__init__(ELEM_TYPE_TEXT, scale, size, auto_size_text, background_color=bg, font=font if font else DEFAULT_FONT) + super().__init__(ELEM_TYPE_TEXT, scale, size, auto_size_text, background_color=bg, font=font if font else DEFAULT_FONT, text_color=self.TextColor) return def Update(self, NewValue): @@ -508,11 +504,13 @@ def __del__(self): # Scroll bar will span the length of the frame # ---------------------------------------------------------------------- # class TKOutput(tk.Frame): - def __init__(self, parent, width, height, bd, background_color=None): + def __init__(self, parent, width, height, bd, background_color=None, text_color=None): tk.Frame.__init__(self, parent) self.output = tk.Text(parent, width=width, height=height, bd=bd) if background_color and background_color != COLOR_SYSTEM_DEFAULT: self.output.configure(background=background_color) + if text_color and text_color != COLOR_SYSTEM_DEFAULT: + self.output.configure(fg=text_color) self.vsb = tk.Scrollbar(parent, orient="vertical", command=self.output.yview) self.output.configure(yscrollcommand=self.vsb.set) self.output.pack(side="left", fill="both", expand=True) @@ -548,7 +546,7 @@ def __del__(self): # Routes stdout, stderr to a scrolled window # # ---------------------------------------------------------------------- # class Output(Element): - def __init__(self, scale=(None, None), size=(None, None), background_color=None): + def __init__(self, scale=(None, None), size=(None, None), background_color=None, text_color=None): ''' Output Element - reroutes stdout, stderr to this window :param scale: Adds multiplier to size (w,h) @@ -557,7 +555,7 @@ def __init__(self, scale=(None, None), size=(None, None), background_color=None) ''' self.TKOut = None bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR - super().__init__(ELEM_TYPE_OUTPUT, scale=scale, size=size, background_color=bg) + super().__init__(ELEM_TYPE_OUTPUT, scale=scale, size=size, background_color=bg, text_color=text_color) def __del__(self): try: @@ -665,7 +663,7 @@ def ReturnKeyHandler(self, event): MyForm = self.ParentForm # search through this form and find the first button that will exit the form for row in MyForm.Rows: - for element in row.Elements: + for element in row: if element.Type == ELEM_TYPE_BUTTON: if element.BType == BUTTON_TYPE_CLOSES_WIN or element.BType == BUTTON_TYPE_READ_FORM: element.ButtonCallBack() @@ -756,7 +754,7 @@ def __del__(self): # Slider # # ---------------------------------------------------------------------- # class Slider(Element): - def __init__(self, range=(None,None), default_value=None, orientation=None, border_width=None, relief=None, scale=(None, None), size=(None, None), font=None, background_color=None): + def __init__(self, range=(None,None), default_value=None, orientation=None, border_width=None, relief=None, scale=(None, None), size=(None, None), font=None, background_color=None, text_color=None): ''' Slider Element :param range: @@ -775,7 +773,7 @@ def __init__(self, range=(None,None), default_value=None, orientation=None, bord self.Orientation = orientation if orientation else DEFAULT_SLIDER_ORIENTATION self.BorderWidth = border_width if border_width else DEFAULT_SLIDER_BORDER_WIDTH self.Relief = relief if relief else DEFAULT_SLIDER_RELIEF - super().__init__(ELEM_TYPE_INPUT_SLIDER, scale=scale, size=size, font=font, background_color=background_color) + super().__init__(ELEM_TYPE_INPUT_SLIDER, scale=scale, size=size, font=font, background_color=background_color, text_color=text_color) return def __del__(self): @@ -783,28 +781,6 @@ def __del__(self): -# ------------------------------------------------------------------------- # -# Row CLASS # -# ------------------------------------------------------------------------- # -class Row(): - def __init__(self, auto_size_text = None): - self.AutoSizeText = auto_size_text # Setting to override the form's policy on autosizing. - self.Elements = [] # List of Elements in this Rrow - return - - # ------------------------- AddElement ------------------------- # - def AddElement(self, element): - self.Elements.append(element) - return - - # ------------------------- Print ------------------------- # - def __str__(self): - outstr = '' - for i, element in enumerate(self.Elements): - outstr += 'Element #%i = %s'%(i,element) - # outstr += f'Element #{i} = {element}' - return outstr - # ------------------------------------------------------------------------- # # FlexForm CLASS # # ------------------------------------------------------------------------- # @@ -842,16 +818,15 @@ def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT self.ResultsBuilt = False # ------------------------- Add ONE Row to Form ------------------------- # - def AddRow(self, *args, auto_size_text=None): + def AddRow(self, *args): ''' Parms are a variable number of Elements ''' NumRows = len(self.Rows) # number of existing rows is our row number CurrentRowNumber = NumRows # this row's number - CurrentRow = Row(auto_size_text=auto_size_text) # start with a blank row and build up + CurrentRow = [] # start with a blank row and build up # ------------------------- Add the elements to a row ------------------------- # for i, element in enumerate(args): # Loop through list of elements and add them to the row element.Position = (CurrentRowNumber, i) - CurrentRow.Elements.append(element) - CurrentRow.AutoSizeText = auto_size_text + CurrentRow.append(element) # ------------------------- Append the row to list of Rows ------------------------- # self.Rows.append(CurrentRow) @@ -878,7 +853,7 @@ def Show(self, non_blocking=False): self.Shown = True # Compute num rows & num cols (it'll come in handy debugging) self.NumRows = len(self.Rows) - self.NumCols = max(len(row.Elements) for row in self.Rows) + self.NumCols = max(len(row) for row in self.Rows) self.NonBlocking=non_blocking # -=-=-=-=-=-=-=-=- RUN the GUI -=-=-=-=-=-=-=-=- ## @@ -895,7 +870,7 @@ def SetIcon(self, icon): def GetElementAtLocation(self, location): (row_num,col_num) = location row = self.Rows[row_num] - element = row.Elements[col_num] + element = row[col_num] return element def _GetDefaultElementSize(self): @@ -981,7 +956,7 @@ def __exit__(self, *a): def __del__(self): for row in self.Rows: - for element in row.Elements: + for element in row: element.__del__() try: del(self.TKroot) @@ -1106,7 +1081,7 @@ def InitializeResults(form): return_vals = [] for row_num,row in enumerate(form.Rows): r = [] - for element in row.Elements: + for element in row: if element.Type == ELEM_TYPE_TEXT: r.append(None) if element.Type == ELEM_TYPE_IMAGE: @@ -1169,7 +1144,7 @@ def BuildResults(form): button_pressed_text = None input_values = [] for row_num,row in enumerate(form.Rows): - for col_num, element in enumerate(row.Elements): + for col_num, element in enumerate(row): if element.Type == ELEM_TYPE_INPUT_TEXT: value=element.TKStringVar.get() results[row_num][col_num] = value @@ -1253,7 +1228,7 @@ def CharWidthInPixels(): # *********** ------- Loop through ELEMENTS ------- ***********# # *********** Make TK Row ***********# tk_row_frame = tk.Frame(master) - for col_num, element in enumerate(flex_row.Elements): + for col_num, element in enumerate(flex_row): element.ParentForm = MyFlexForm # save the button's parent form object if MyFlexForm.Font and (element.Font == DEFAULT_FONT or not element.Font): font = MyFlexForm.Font @@ -1262,8 +1237,6 @@ def CharWidthInPixels(): # ------- Determine Auto-Size setting on a cascading basis ------- # if element.AutoSizeText is not None: # if element overide auto_size_text = element.AutoSizeText - elif flex_row.AutoSizeText is not None: # if Row override - auto_size_text = flex_row.AutoSizeText elif MyFlexForm.AutoSizeText is not None: # if form override auto_size_text = MyFlexForm.AutoSizeText else: @@ -1278,6 +1251,8 @@ def CharWidthInPixels(): element_size = (int(element_size[0] * element.Scale[0]), int(element_size[1] * element.Scale[1])) elif MyFlexForm.Scale != (None, None): element_size = (int(element_size[0] * MyFlexForm.Scale[0]), int(element_size[1] * MyFlexForm.Scale[1])) + # Set foreground color + text_color = element.TextColor # ------------------------- TEXT element ------------------------- # element_type = element.Type if element_type == ELEM_TYPE_TEXT: @@ -1301,13 +1276,16 @@ def CharWidthInPixels(): width = 0 justify = tk.LEFT if element.Justification == 'left' else tk.CENTER if element.Justification == 'center' else tk.RIGHT anchor = tk.NW if element.Justification == 'left' else tk.N if element.Justification == 'center' else tk.NE - tktext_label = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height, justify=justify, bd=border_depth, fg=element.TextColor) + tktext_label = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height, justify=justify, bd=border_depth) # tktext_label = tk.Label(tk_row_frame,anchor=tk.NW, text=display_text, width=width, height=height, justify=tk.LEFT, bd=border_depth) # Set wrap-length for text (in PIXELS) == PAIN IN THE ASS wraplen = tktext_label.winfo_reqwidth() # width of widget in Pixels tktext_label.configure(anchor=anchor, font=font, wraplen=wraplen*2 ) # set wrap to width of widget if element.BackgroundColor is not None: tktext_label.configure(background=element.BackgroundColor) + if element.TextColor != COLOR_SYSTEM_DEFAULT and element.TextColor is not None: + tktext_label.configure(fg=element.TextColor) + tktext_label.pack(side=tk.LEFT) # ------------------------- BUTTON element ------------------------- # elif element_type == ELEM_TYPE_BUTTON: @@ -1367,6 +1345,8 @@ def CharWidthInPixels(): element.TKEntry.bind('', element.ReturnKeyHandler) if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: element.TKEntry.configure(background=element.BackgroundColor) + if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: + element.TKEntry.configure(fg=text_color) element.TKEntry.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) if not focus_set: focus_set = True @@ -1385,6 +1365,7 @@ def CharWidthInPixels(): {'configure': {'selectbackground': element.BackgroundColor, 'fieldbackground': element.BackgroundColor, + 'foreground': text_color, 'background': element.BackgroundColor} }}) except: @@ -1394,6 +1375,7 @@ def CharWidthInPixels(): {'configure': {'selectbackground': element.BackgroundColor, 'fieldbackground': element.BackgroundColor, + 'foreground': text_color, 'background': element.BackgroundColor} }}) except: pass @@ -1419,6 +1401,8 @@ def CharWidthInPixels(): element.TKListbox.selection_set(0,0) if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: element.TKListbox.configure(background=element.BackgroundColor) + if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: + element.TKListbox.configure(fg=text_color) # vsb = tk.Scrollbar(tk_row_frame, orient="vertical", command=element.TKListbox.yview) # element.TKListbox.configure(yscrollcommand=vsb.set) element.TKListbox.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) @@ -1438,15 +1422,21 @@ def CharWidthInPixels(): if not focus_set: focus_set = True element.TKText.focus_set() + if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: + element.TKText.configure(fg=text_color) # ------------------------- INPUT CHECKBOX element ------------------------- # elif element_type == ELEM_TYPE_INPUT_CHECKBOX: width = 0 if auto_size_text else element_size[0] default_value = element.InitialState element.TKIntVar = tk.IntVar() - element.TKIntVar.set(default_value) + element.TKIntVar.set(default_value if default_value is not None else 0) element.TKCheckbutton = tk.Checkbutton(tk_row_frame, anchor=tk.NW, text=element.Text, width=width, variable=element.TKIntVar, bd=border_depth, font=font) + if default_value is None: + element.TKCheckbutton.configure(state='disable') if element.BackgroundColor is not None: element.TKCheckbutton.configure(background=element.BackgroundColor) + if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: + element.TKCheckbutton.configure(fg=text_color) element.TKCheckbutton.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) # ------------------------- PROGRESS BAR element ------------------------- # elif element_type == ELEM_TYPE_PROGRESS_BAR: @@ -1485,6 +1475,8 @@ def CharWidthInPixels(): variable=element.TKIntVar, value=value, bd=border_depth, font=font) if element.BackgroundColor is not None: element.TKRadio.configure(background=element.BackgroundColor) + if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: + element.TKRadio.configure(fg=text_color) element.TKRadio.pack(side=tk.LEFT, padx=element.Pad[0],pady=element.Pad[1]) # ------------------------- INPUT SPIN Box element ------------------------- # elif element_type == ELEM_TYPE_INPUT_SPIN: @@ -1497,10 +1489,12 @@ def CharWidthInPixels(): if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: element.TKSpinBox.configure(background=element.BackgroundColor) element.TKSpinBox.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) + if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: + element.TKSpinBox.configure(fg=text_color) # ------------------------- OUTPUT element ------------------------- # elif element_type == ELEM_TYPE_OUTPUT: width, height = element_size - element.TKOut = TKOutput(tk_row_frame, width=width, height=height, bd=border_depth, background_color=element.BackgroundColor) + element.TKOut = TKOutput(tk_row_frame, width=width, height=height, bd=border_depth, background_color=element.BackgroundColor, text_color=text_color) element.TKOut.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) # ------------------------- IMAGE Box element ------------------------- # elif element_type == ELEM_TYPE_IMAGE: @@ -1530,6 +1524,8 @@ def CharWidthInPixels(): if element.BackgroundColor is not None: tkscale.configure(background=element.BackgroundColor) tkscale.config(troughcolor=DEFAULT_SCROLLBAR_COLOR) + if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: + tkscale.configure(fg=text_color) tkscale.pack(side=tk.LEFT) #............................DONE WITH ROW pack the row of widgets ..........................# # done with row, pack the row of widgets @@ -2248,7 +2244,7 @@ def SetOptions(icon=None, button_color=None, element_size=(None,None), margins=( progress_meter_relief=None, progress_meter_color=None, progress_meter_size=None, text_justification=None, background_color=None, element_background_color=None, text_element_background_color=None, input_elements_background_color=None, - scrollbar_color=None, text_color=None, debug_win_size=(None,None), window_location=(None,None)): + scrollbar_color=None, text_color=None, element_text_color = None, debug_win_size=(None,None), window_location=(None,None)): global DEFAULT_ELEMENT_SIZE global DEFAULT_MARGINS # Margins for each LEFT/RIGHT margin is first term @@ -2277,6 +2273,7 @@ def SetOptions(icon=None, button_color=None, element_size=(None,None), margins=( global DEFAULT_SCROLLBAR_COLOR global DEFAULT_TEXT_COLOR global DEFAULT_WINDOW_LOCATION + global DEFAULT_ELEMENT_TEXT_COLOR global _my_windows if icon: @@ -2368,6 +2365,9 @@ def SetOptions(icon=None, button_color=None, element_size=(None,None), margins=( if scrollbar_color != None: DEFAULT_SCROLLBAR_COLOR = scrollbar_color + if element_text_color != None: + DEFAULT_ELEMENT_TEXT_COLOR = element_text_color + return True # ============================== sprint ======# From 984f4b6d72fb1e872348876c2a0f7b23d5024912 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 8 Aug 2018 10:40:40 -0400 Subject: [PATCH 115/209] Dictionary Return Values! Return values in dictionary form, removed random colors capability --- PySimpleGUI.py | 94 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 37 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 1d98d7da1..8082c2024 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -4,7 +4,6 @@ from tkinter import ttk import tkinter.scrolledtext as tkst import tkinter.font -from random import randint import datetime import sys import textwrap @@ -154,7 +153,7 @@ def RGB(red,green,blue): return '#%02x%02x%02x' % (red,green,blue) # Element CLASS # # ------------------------------------------------------------------------- # class Element(): - def __init__(self, type, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None): + def __init__(self, type, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None, key=None): self.Size = size self.Type = type self.AutoSizeText = auto_size_text @@ -173,6 +172,7 @@ def __init__(self, type, scale=(None, None), size=(None, None), auto_size_text=N self.Position = (0,0) # Default position Row 0, Col 0 self.BackgroundColor = background_color if background_color is not None else DEFAULT_ELEMENT_BACKGROUND_COLOR self.TextColor = text_color if text_color is not None else DEFAULT_ELEMENT_TEXT_COLOR + self.Key = key # dictionary key for return values def __del__(self): try: @@ -196,7 +196,7 @@ def __del__(self): # Input Class # # ---------------------------------------------------------------------- # class InputText(Element): - def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None, text_color=None): + def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None, text_color=None, key=None): ''' Input a line of text Element :param default_text: Default value to display @@ -209,7 +209,7 @@ def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto self.DefaultText = default_text self.PasswordCharacter = password_char bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR - super().__init__(ELEM_TYPE_INPUT_TEXT, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=text_color) + super().__init__(ELEM_TYPE_INPUT_TEXT, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=text_color, key=key) def ReturnKeyHandler(self, event): MyForm = self.ParentForm @@ -229,7 +229,7 @@ def __del__(self): # ---------------------------------------------------------------------- # class InputCombo(Element): - def __init__(self, values, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None): + def __init__(self, values, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None, key=None): ''' Input Combo Box Element (also called Dropdown box) :param values: @@ -241,7 +241,7 @@ def __init__(self, values, scale=(None, None), size=(None, None), auto_size_text self.Values = values self.TKComboBox = None bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR - super().__init__(ELEM_TYPE_INPUT_COMBO, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=text_color) + super().__init__(ELEM_TYPE_INPUT_COMBO, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=text_color, key=key) def __del__(self): try: @@ -256,7 +256,7 @@ def __del__(self): # ---------------------------------------------------------------------- # class Listbox(Element): - def __init__(self, values, select_mode=None, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None): + def __init__(self, values, select_mode=None, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None, key=None): ''' Listbox Element :param values: @@ -279,7 +279,7 @@ def __init__(self, values, select_mode=None, scale=(None, None), size=(None, Non else: self.SelectMode = DEFAULT_LISTBOX_SELECT_MODE bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR - super().__init__(ELEM_TYPE_INPUT_LISTBOX, scale=scale, size=size, auto_size_text=auto_size_text, font=font, background_color=bg, text_color=text_color) + super().__init__(ELEM_TYPE_INPUT_LISTBOX, scale=scale, size=size, auto_size_text=auto_size_text, font=font, background_color=bg, text_color=text_color, key=key) def __del__(self): try: @@ -294,7 +294,7 @@ def __del__(self): # Radio # # ---------------------------------------------------------------------- # class Radio(Element): - def __init__(self, text, group_id, default=False, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None, font=None): + def __init__(self, text, group_id, default=False, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None, font=None, key=None): ''' Radio Button Element :param text: @@ -311,7 +311,7 @@ def __init__(self, text, group_id, default=False, scale=(None, None), size=(None self.TKRadio = None self.GroupID = group_id self.Value = None - super().__init__(ELEM_TYPE_INPUT_RADIO, scale=scale , size=size, auto_size_text=auto_size_text, font=font, background_color=background_color, text_color=text_color) + super().__init__(ELEM_TYPE_INPUT_RADIO, scale=scale , size=size, auto_size_text=auto_size_text, font=font, background_color=background_color, text_color=text_color, key=key) def __del__(self): try: @@ -324,7 +324,7 @@ def __del__(self): # Checkbox # # ---------------------------------------------------------------------- # class Checkbox(Element): - def __init__(self, text, default=False, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None): + def __init__(self, text, default=False, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None, key=None): ''' Check Box Element :param text: @@ -340,7 +340,7 @@ def __init__(self, text, default=False, scale=(None, None), size=(None, None), a self.Value = None self.TKCheckbox = None - super().__init__(ELEM_TYPE_INPUT_CHECKBOX, scale=scale, size=size, auto_size_text=auto_size_text, font=font, background_color=background_color, text_color=text_color) + super().__init__(ELEM_TYPE_INPUT_CHECKBOX, scale=scale, size=size, auto_size_text=auto_size_text, font=font, background_color=background_color, text_color=text_color, key=key) def __del__(self): try: @@ -356,7 +356,7 @@ def __del__(self): class Spin(Element): # Values = None # TKSpinBox = None - def __init__(self, values, initial_value=None, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None): + def __init__(self, values, initial_value=None, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None, key=None): ''' Spin Box Element :param values: @@ -371,7 +371,7 @@ def __init__(self, values, initial_value=None, scale=(None, None), size=(None, N self.DefaultValue = initial_value self.TKSpinBox = None bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR - super().__init__(ELEM_TYPE_INPUT_SPIN, scale, size, auto_size_text, font=font,background_color=bg, text_color=text_color) + super().__init__(ELEM_TYPE_INPUT_SPIN, scale, size, auto_size_text, font=font,background_color=bg, text_color=text_color, key=key) return def __del__(self): @@ -385,7 +385,7 @@ def __del__(self): # Multiline # # ---------------------------------------------------------------------- # class Multiline(Element): - def __init__(self, default_text='', enter_submits = False, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None): + def __init__(self, default_text='', enter_submits = False, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None, key=None): ''' Input Multi-line Element :param default_text: @@ -398,7 +398,7 @@ def __init__(self, default_text='', enter_submits = False, scale=(None, None), s self.DefaultText = default_text self.EnterSubmits = enter_submits bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR - super().__init__(ELEM_TYPE_INPUT_MULTILINE, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=text_color) + super().__init__(ELEM_TYPE_INPUT_MULTILINE, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=text_color, key=key) return def ReturnKeyHandler(self, event): @@ -754,7 +754,7 @@ def __del__(self): # Slider # # ---------------------------------------------------------------------- # class Slider(Element): - def __init__(self, range=(None,None), default_value=None, orientation=None, border_width=None, relief=None, scale=(None, None), size=(None, None), font=None, background_color=None, text_color=None): + def __init__(self, range=(None,None), default_value=None, orientation=None, border_width=None, relief=None, scale=(None, None), size=(None, None), font=None, background_color=None, text_color=None, key=None): ''' Slider Element :param range: @@ -773,7 +773,7 @@ def __init__(self, range=(None,None), default_value=None, orientation=None, bord self.Orientation = orientation if orientation else DEFAULT_SLIDER_ORIENTATION self.BorderWidth = border_width if border_width else DEFAULT_SLIDER_BORDER_WIDTH self.Relief = relief if relief else DEFAULT_SLIDER_RELIEF - super().__init__(ELEM_TYPE_INPUT_SLIDER, scale=scale, size=size, font=font, background_color=background_color, text_color=text_color) + super().__init__(ELEM_TYPE_INPUT_SLIDER, scale=scale, size=size, font=font, background_color=background_color, text_color=text_color, key=key) return def __del__(self): @@ -788,7 +788,7 @@ class FlexForm: ''' Display a user defined for and return the filled in data ''' - def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=None, auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON): + def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=None, auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, use_dictionary=False): self.AutoSizeText = auto_size_text if auto_size_text is not None else DEFAULT_AUTOSIZE_TEXT self.AutoSizeButtons = auto_size_buttons if auto_size_buttons is not None else DEFAULT_AUTOSIZE_BUTTONS self.Title = title @@ -815,7 +815,9 @@ def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT self.RootNeedsDestroying = False self.Shown = False self.ReturnValues = None + self.ReturnValuesDictionary = None self.ResultsBuilt = False + self.UseDictionary = use_dictionary # ------------------------- Add ONE Row to Form ------------------------- # def AddRow(self, *args): @@ -1143,22 +1145,32 @@ def BuildResults(form): results=form.Results button_pressed_text = None input_values = [] + input_values_dictionary = {} for row_num,row in enumerate(form.Rows): for col_num, element in enumerate(row): if element.Type == ELEM_TYPE_INPUT_TEXT: value=element.TKStringVar.get() results[row_num][col_num] = value input_values.append(value) + try: + input_values_dictionary[element.Key] = value + except: pass elif element.Type == ELEM_TYPE_INPUT_CHECKBOX: value=element.TKIntVar.get() results[row_num][col_num] = value input_values.append(value != 0) + try: + input_values_dictionary[element.Key] = value + except: pass elif element.Type == ELEM_TYPE_INPUT_RADIO: RadVar=element.TKIntVar.get() this_rowcol = EncodeRadioRowCol(row_num,col_num) value = RadVar == this_rowcol results[row_num][col_num] = value input_values.append(value) + try: + input_values_dictionary[element.Key] = value + except: pass elif element.Type == ELEM_TYPE_BUTTON: if results[row_num][col_num] is True: button_pressed_text = element.ButtonText @@ -1168,11 +1180,17 @@ def BuildResults(form): value=element.TKStringVar.get() results[row_num][col_num] = value input_values.append(value) + try: + input_values_dictionary[element.Key] = value + except: pass elif element.Type == ELEM_TYPE_INPUT_LISTBOX: items=element.TKListbox.curselection() value = [element.Values[int(item)] for item in items] results[row_num][col_num] = value input_values.append(value) + try: + input_values_dictionary[element.Key] = value + except: pass elif element.Type == ELEM_TYPE_INPUT_SPIN: try: value=element.TKStringVar.get() @@ -1180,6 +1198,9 @@ def BuildResults(form): value = 0 results[row_num][col_num] = value input_values.append(value) + try: + input_values_dictionary[element.Key] = value + except: pass elif element.Type == ELEM_TYPE_INPUT_SLIDER: try: value=element.TKIntVar.get() @@ -1187,6 +1208,9 @@ def BuildResults(form): value = 0 results[row_num][col_num] = value input_values.append(value) + try: + input_values_dictionary[element.Key] = value + except: pass elif element.Type == ELEM_TYPE_INPUT_MULTILINE: try: value=element.TKText.get(1.0, tk.END) @@ -1196,11 +1220,21 @@ def BuildResults(form): value = None results[row_num][col_num] = value input_values.append(value) + try: + input_values_dictionary[element.Key] = value + except: pass - return_value = button_pressed_text,input_values - form.ReturnValues = return_value + try: + input_values_dictionary.pop(None, None) # clean up dictionary include None was included + except: pass + + if not form.UseDictionary: + form.ReturnValues = button_pressed_text, input_values + else: + form.ReturnValues = button_pressed_text, input_values_dictionary + form.ReturnValuesDictionary = button_pressed_text, input_values_dictionary form.ResultsBuilt = True - return return_value + return form.ReturnValues # ------------------------------------------------------------------------------------------------------------------ # @@ -1447,9 +1481,7 @@ def CharWidthInPixels(): progress_length = width*char_width progress_width = element_size[1] direction = element.Orientation - if element.BarColor == 'Random' or element.BarColor == 'random': - bar_color = GetRandomColorPair() - elif element.BarColor != (None, None): # if element has a bar color, use it + if element.BarColor != (None, None): # if element has a bar color, use it bar_color = element.BarColor else: bar_color = DEFAULT_PROGRESS_BAR_COLOR @@ -2034,18 +2066,6 @@ def EasyProgressMeterCancel(title, *args): return True -def GetRandomColor(): - nums = randint(0,255), randint(0,255), randint(0,255) - color_code ='#' + ''.join('{:02X}'.format(a) for a in nums) - return color_code - - -def GetRandomColorPair(): - fg = GetRandomColor() - bg = GetComplimentaryHex(fg) - color_code = (fg, bg) - return color_code - # input is #RRGGBB # output is #RRGGBB def GetComplimentaryHex(color): From 5cf0d26ac095f29fa3f2ca955414435ac42374b2 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 8 Aug 2018 10:44:11 -0400 Subject: [PATCH 116/209] Demo Dictionary Feature Requires latest PySimpleGUI.py file --- Demo_Dictionary.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Demo_Dictionary.py diff --git a/Demo_Dictionary.py b/Demo_Dictionary.py new file mode 100644 index 000000000..c1a060da4 --- /dev/null +++ b/Demo_Dictionary.py @@ -0,0 +1,22 @@ +import PySimpleGUI as sg + +# THIS FILE REQIRES THE LATEST PySimpleGUI.py FILE +# IT WILL NOT WORK WITH CURRENT PIP RELEASE (2.7) + +# Shows how to use return values in dictionary form + +form = sg.FlexForm('Simple data entry form', use_dictionary=True) # begin with a blank form + +layout = [ + [sg.Text('Please enter your Name, Address, Phone')], + [sg.Text('Name', size=(15, 1)), sg.InputText('1', key='name')], + [sg.Text('Address', size=(15, 1)), sg.InputText('2', key='address')], + [sg.Text('Phone', size=(15, 1)), sg.InputText('3', key='phone')], + [sg.Submit(), sg.Cancel()] + ] + +button, values = form.LayoutAndRead(layout) + +sg.MsgBox(button, values, values['name'], values['address'], values['phone']) + +print(values) From 90925af23ede07fe0dff455e872bb14e9a7c918c Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 8 Aug 2018 12:42:58 -0400 Subject: [PATCH 117/209] Support for Dictionary return values --- readme.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/readme.md b/readme.md index f03d65375..b433cf533 100644 --- a/readme.md +++ b/readme.md @@ -2,15 +2,19 @@ ![pysimplegui_logo](https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png) -[![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 +[![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 + +![Documentation Status](https://readthedocs.org/projects/pysimplegui/badge/?version=latest) + + # PySimpleGUI (Ver 2.7) Super-simple GUI to grasp... Powerfully customizable. -Note - *Python3* is required to run PySimpleGUI. It takes advantage of some Python3 features that do not translate well into Python2. +Note - ***Python3*** is required to run PySimpleGUI. It takes advantage of some Python3 features that do not translate well into Python2. -Looking to take your Python code from the world of command lines and into the convenience of a GUI? Have a Raspberry Pi with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK? Look no further, you've found your GUI package. +Looking to take your Python code from the world of command lines and into the convenience of a GUI? Have a Raspberry **Pi** with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK? Look no further, **you've found your GUI package**. import PySimpleGUI as sg @@ -23,7 +27,7 @@ Looking to take your Python code from the world of command lines and into the co ![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) -Perhaps you're looking for a way to interact with your Raspberry Pi in a more friendly way. The is the same form as above, except shown on a Pi. +Perhaps you're looking for a way to interact with your **Raspberry Pi** in a more friendly way. The is the same form as above, except shown on a Pi. ![raspberry pi](https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg) @@ -40,7 +44,7 @@ You can build an async media player GUI with custom buttons in 30 lines of code. I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? -There are a number of 'easy to use' Python GUIs, but they're **very** limiting. PySimpleGUI takes the best of packages like `EasyGUI`and `WxSimpleGUI` , both really handy but limited. The primary difference between these and PySimpleGUI is that in addition to getting the simple Message Boxes you also get the ability to make your own forms that are highly customizeable. Don't like the standard Message Box? Then make your own! +There are a number of 'easy to use' Python GUIs, but they're **very** limiting. PySimpleGUI takes the best of packages like `EasyGUI`and `WxSimpleGUI` , both really handy but limited. The primary difference between these and `PySimpleGUI` is that in addition to getting the simple Message Boxes you also get the ability to **make your own forms** that are highly customizeable. Don't like the standard Message Box? Then make your own! Every call has optional parameters so that you can change the look and feel. Don't like the button color? It's easy to change by adding a button_color parameter to your widget. @@ -73,7 +77,7 @@ The `PySimpleGUI` package is focused on the ***developer***. How can the desire Persistent Windows Redirect Python Output/Errors to scrolling window 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) - Single-Line-Of-Coide Proress Bar & Debug Print + Single-Line-Of-Code Proress Bar & Debug Print Complete control of colors, look and feel Button images @@ -480,6 +484,10 @@ This is the code that **displays** the form, collects the information and return ## Return values + As of version 2.8 there are 2 forms of return values, list and dictionary. +### Return values as a list + By default return values are a list of values, one entry for each input field. + Return information from FlexForm, SG's primary form builder interface, is in this format: button, (value1, value2, ...) @@ -498,14 +506,40 @@ If you have a SINGLE value being returned, it is written this way: button, (value1,) = form.LayoutAndRead(form_rows) - Another way of parsing the return values is to store the list of values into a variable representing the list of values. + Another way of parsing the return values is to store the list of values into a variable representing the list of values and then index each individual value. This is not the preferred way of doing it. button, value_list = form.LayoutAndRead(form_rows) value1 = value_list[0] value2 = value_list[1] ... +### Return values as a dictionary + +If you wish to receive the return values as a dictionary rather than a simple list, then you'll have to do 2 things: +1. Indicate in the form creation that the return should be a dictionary by setting `use_dictionary = True` +2. Mark each input element you wish to be in the dictionary with the keyword `key`. + +This sample program demonstrates these 2 steps as well as how to address the return values (e.g. `values['name']`) + + + import PySimpleGUI as sg + form = sg.FlexForm('Simple data entry form', use_dictionary=True) + layout = [ + [sg.Text('Please enter your Name, Address, Phone')], + [sg.Text('Name', size=(15, 1)), sg.InputText('1', key='name')], + [sg.Text('Address', size=(15, 1)), sg.InputText('2', key='address')], + [sg.Text('Phone', size=(15, 1)), sg.InputText('3', key='phone')], + [sg.Submit(), sg.Cancel()] + ] + + button, values = form.LayoutAndRead(layout) + + sg.MsgBox(button, values, values['name'], values['address'], values['phone']) + + --- + + ## All Widgets / Elements This code utilizes as many of the elements in one form as possible. @@ -588,7 +622,7 @@ Parameter Descriptions. You will find these same parameters specified for each auto_size_text - Bool. True if elements should size themselves according to contents auto_size_buttons - Bool. True if button elements should size themselves according to their text label scale - Set size of element to be a multiple of the Element size - location - Location to place window in pixels + location - (x,y) Location to place window in pixels button_color - Default color for buttons (foreground, background). Can be text or hex progress_bar_color - Foreground and background colors for progress bars is_tabbed_form - Bool. If True then form is a tabbed form @@ -598,6 +632,9 @@ Parameter Descriptions. You will find these same parameters specified for each icon - .ICO file that will appear on the Task Bar and end of Title Bar +#### Window Location +PySimpleGUI computes the exact center of your window and centers the window on the screen. If you want to locate your window elsewhere, such as the system default of (0,0), if you have 2 ways of doing this. The first is when the form is created. Use the `location` parameter to set where the window. The second way of doing this is to use the `SetOptions` call which will set the default window location for all windows in the future. + #### Sizes Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. @@ -892,7 +929,7 @@ Checkbox elements are like Radio Button elements. They return a bool indicating . text - Text to display next to checkbox - default- Bool. Initial state + default- Bool + None. Initial state. True = Checked, False = unchecked, None = Not available (grayed out) scale - Amount to scale size of element size - (width, height) size of element in characters auto_size_text- Bool. True if should size width to fit text @@ -1418,6 +1455,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. | 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ | 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting +| 2.8.0 | Aug xx, 2018 - PLANNED - New None default option for Checkbox element, text color option for all elements, return values as a dictionary ### Release Notes From 4962b02799ab621bd54fb73b2d69bcd37be933c3 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 9 Aug 2018 06:53:13 -0400 Subject: [PATCH 118/209] New "launcher" demo program Initial checkin --- Demo_Script_Launcher.py | 36 ++++++++++++++++++++++++++++++++++++ SimScript_.py | 4 ++++ 2 files changed, 40 insertions(+) create mode 100644 Demo_Script_Launcher.py create mode 100644 SimScript_.py diff --git a/Demo_Script_Launcher.py b/Demo_Script_Launcher.py new file mode 100644 index 000000000..bcc06b004 --- /dev/null +++ b/Demo_Script_Launcher.py @@ -0,0 +1,36 @@ +import PySimpleGUI as sg +import os + +def Launcher(): + + form = sg.FlexForm('Script launcher') + + layout = [ + [sg.Text('Script output....', size=(40, 1))], + [sg.Output(size=(88, 20))], + [sg.ReadFormButton('script1'), sg.ReadFormButton('script2'), sg.SimpleButton('EXIT')] + ] + + form.Layout(layout) + + # ---===--- Loop taking in user input and using it to query HowDoI --- # + while True: + (button, value) = form.Read() + if button == 'EXIT' or button is None: + break # exit button clicked + if button == 'script1': + ExecuteCommandOS('python SimScript.py') + elif button == 'script2': + ExecuteCommandOS('python SimScript.py') + elif button == 'Enter': + ExecuteCommandOS(value[0]) # send string without carriage return on end + + +def ExecuteCommandOS(command): + output = os.popen(command).read() + print(output) + + +if __name__ == '__main__': + Launcher() + diff --git a/SimScript_.py b/SimScript_.py new file mode 100644 index 000000000..2185935b3 --- /dev/null +++ b/SimScript_.py @@ -0,0 +1,4 @@ +import time + +for i in range(100): + print(i,'', end='') From 49e89c787577483a2fda4b2428de6220e8c30ff9 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 9 Aug 2018 09:35:21 -0400 Subject: [PATCH 119/209] Focus set and return key handling options Exposed the ability to set where the initial forus is as well as which elements should be bound to the return key. --- PySimpleGUI.py | 135 +++++++++++++++++++++++++------------------------ 1 file changed, 68 insertions(+), 67 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 8082c2024..c75a160fe 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -174,6 +174,15 @@ def __init__(self, type, scale=(None, None), size=(None, None), auto_size_text=N self.TextColor = text_color if text_color is not None else DEFAULT_ELEMENT_TEXT_COLOR self.Key = key # dictionary key for return values + def ReturnKeyHandler(self, event): + MyForm = self.ParentForm + # search through this form and find the first button that will exit the form + for row in MyForm.Rows: + for element in row: + if element.Type == ELEM_TYPE_BUTTON: + if element.BindReturnKey: + element.ButtonCallBack() + def __del__(self): try: self.TKStringVar.__del__() @@ -196,7 +205,7 @@ def __del__(self): # Input Class # # ---------------------------------------------------------------------- # class InputText(Element): - def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None, text_color=None, key=None): + def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None, text_color=None, key=None, focus=False): ''' Input a line of text Element :param default_text: Default value to display @@ -209,17 +218,10 @@ def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto self.DefaultText = default_text self.PasswordCharacter = password_char bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR + self.Focus = focus super().__init__(ELEM_TYPE_INPUT_TEXT, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=text_color, key=key) - def ReturnKeyHandler(self, event): - MyForm = self.ParentForm - # search through this form and find the first button that will exit the form - for row in MyForm.Rows: - for element in row: - if element.Type == ELEM_TYPE_BUTTON: - if element.BType == BUTTON_TYPE_CLOSES_WIN or element.BType == BUTTON_TYPE_READ_FORM: - element.ButtonCallBack() - return + def __del__(self): super().__del__() @@ -385,7 +387,7 @@ def __del__(self): # Multiline # # ---------------------------------------------------------------------- # class Multiline(Element): - def __init__(self, default_text='', enter_submits = False, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None, key=None): + def __init__(self, default_text='', enter_submits = False, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None, key=None, focus=False): ''' Input Multi-line Element :param default_text: @@ -398,18 +400,10 @@ def __init__(self, default_text='', enter_submits = False, scale=(None, None), s self.DefaultText = default_text self.EnterSubmits = enter_submits bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR + self.Focus = focus super().__init__(ELEM_TYPE_INPUT_MULTILINE, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=text_color, key=key) return - def ReturnKeyHandler(self, event): - MyForm = self.ParentForm - # search through this form and find the first button that will exit the form - for row in MyForm.Rows: - for element in row: - if element.Type == ELEM_TYPE_BUTTON: - if element.BType == BUTTON_TYPE_CLOSES_WIN or element.BType == BUTTON_TYPE_READ_FORM: - element.ButtonCallBack() - return def __del__(self): super().__del__() @@ -568,7 +562,7 @@ def __del__(self): # Button Class # # ---------------------------------------------------------------------- # class Button(Element): - def __init__(self, button_type=BUTTON_TYPE_CLOSES_WIN, target=(None, None), button_text='', file_types=(("ALL Files", "*.*"),), image_filename=None, image_size=(None, None), image_subsample=None, border_width=None, scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): + def __init__(self, button_type=BUTTON_TYPE_CLOSES_WIN, target=(None, None), button_text='', file_types=(("ALL Files", "*.*"),), image_filename=None, image_size=(None, None), image_subsample=None, border_width=None, scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False): ''' Button Element - Specifies all types of buttons :param button_type: @@ -597,6 +591,8 @@ def __init__(self, button_type=BUTTON_TYPE_CLOSES_WIN, target=(None, None), butt self.ImageSubsample = image_subsample self.UserData = None self.BorderWidth = border_width if border_width is not None else DEFAULT_BORDER_WIDTH + self.BindReturnKey = bind_return_key + self.Focus = focus super().__init__(ELEM_TYPE_BUTTON, scale, size, font=font) return @@ -659,16 +655,6 @@ def ButtonCallBack(self): self.ParentForm.TKroot.quit() # kick the users out of the mainloop return - def ReturnKeyHandler(self, event): - MyForm = self.ParentForm - # search through this form and find the first button that will exit the form - for row in MyForm.Rows: - for element in row: - if element.Type == ELEM_TYPE_BUTTON: - if element.BType == BUTTON_TYPE_CLOSES_WIN or element.BType == BUTTON_TYPE_READ_FORM: - element.ButtonCallBack() - return - def __del__(self): try: self.TKButton.__del__() @@ -818,6 +804,7 @@ def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT self.ReturnValuesDictionary = None self.ResultsBuilt = False self.UseDictionary = use_dictionary + self.UseDefaultFocus = False # ------------------------- Add ONE Row to Form ------------------------- # def AddRow(self, *args): @@ -858,6 +845,19 @@ def Show(self, non_blocking=False): self.NumCols = max(len(row) for row in self.Rows) self.NonBlocking=non_blocking + # Search through entire form to see if any elements set the focus + # if not, then will set the focus to the first input element + found_focus = False + for row in self.Rows: + for element in row: + try: + if element.Focus: + found_focus = True + break + except: + pass + if not found_focus: + self.UseDefaultFocus = True # -=-=-=-=-=-=-=-=- RUN the GUI -=-=-=-=-=-=-=-=- ## StartupTK(self) return self.ReturnValues @@ -1001,11 +1001,11 @@ def __del__(self): # ====================================================================== # # ------------------------- INPUT TEXT Element lazy functions ------------------------- # -def In(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None): - return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text) +def In(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, focus=False): + return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, focus=focus) -def Input(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None): - return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text) +def Input(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, focus=False): + return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, focus=focus) # ------------------------- INPUT COMBO Element lazy functions ------------------------- # def Combo(values, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None): @@ -1032,45 +1032,44 @@ def FileBrowse(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_ return Button(BUTTON_TYPE_BROWSE_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) # ------------------------- SUBMIT BUTTON Element lazy function ------------------------- # -def Submit(button_text='Submit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) +def Submit(button_text='Submit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True, focus=False): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, bind_return_key=bind_return_key, focus=focus) # ------------------------- OK BUTTON Element lazy function ------------------------- # -def OK(button_text='OK', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) +def OK(button_text='OK', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True, focus=False): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, bind_return_key=bind_return_key, focus=focus) # ------------------------- YES BUTTON Element lazy function ------------------------- # -def Ok(button_text='Ok', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) +def Ok(button_text='Ok', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True, focus=False): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, bind_return_key=bind_return_key, focus=focus) # ------------------------- CANCEL BUTTON Element lazy function ------------------------- # -def Cancel(button_text='Cancel', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) +def Cancel(button_text='Cancel', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus) # ------------------------- QUIT BUTTON Element lazy function ------------------------- # -def Quit(button_text='Quit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) +def Quit(button_text='Quit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus) # ------------------------- YES BUTTON Element lazy function ------------------------- # -def Yes(button_text='Yes', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) +def Yes(button_text='Yes', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True, focus=False): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, bind_return_key=bind_return_key, focus=focus) # ------------------------- NO BUTTON Element lazy function ------------------------- # -def No(button_text='No', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) +def No(button_text='No', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=False, focus=False): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, bind_return_key=bind_return_key, focus=focus) # ------------------------- GENERIC BUTTON Element lazy function ------------------------- # # this is the only button that REQUIRES button text field -def SimpleButton(button_text, image_filename=None, image_size=(None, None), image_subsample=None, border_width=None, scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): - return Button(BUTTON_TYPE_CLOSES_WIN, image_filename=image_filename, image_size=image_size, image_subsample=image_subsample, button_text=button_text, border_width=border_width, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) - +def SimpleButton(button_text, image_filename=None, image_size=(None, None), image_subsample=None, border_width=None, scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False): + return Button(BUTTON_TYPE_CLOSES_WIN, image_filename=image_filename, image_size=image_size, image_subsample=image_subsample, button_text=button_text, border_width=border_width, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus) # ------------------------- GENERIC BUTTON Element lazy function ------------------------- # # this is the only button that REQUIRES button text field -def ReadFormButton(button_text, image_filename=None, image_size=(None, None),image_subsample=None,border_width=None,scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): - return Button(BUTTON_TYPE_READ_FORM, image_filename=image_filename, image_size=image_size, image_subsample=image_subsample, border_width=border_width, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) +def ReadFormButton(button_text, image_filename=None, image_size=(None, None),image_subsample=None,border_width=None,scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False): + return Button(BUTTON_TYPE_READ_FORM, image_filename=image_filename, image_size=image_size, image_subsample=image_subsample, border_width=border_width, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus) -def RealtimeButton(button_text, image_filename=None, image_size=(None, None),image_subsample=None,border_width=None,scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): - return Button(BUTTON_TYPE_REALTIME, image_filename=image_filename, image_size=image_size, image_subsample=image_subsample, border_width=border_width, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) +def RealtimeButton(button_text, image_filename=None, image_size=(None, None),image_subsample=None,border_width=None,scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False): + return Button(BUTTON_TYPE_REALTIME, image_filename=image_filename, image_size=image_size, image_subsample=image_subsample, border_width=border_width, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus) #------------------------------------------------------------------------------------------------------# # ------- FUNCTION InitializeResults. Sets up form results matrix ------- # @@ -1152,6 +1151,8 @@ def BuildResults(form): value=element.TKStringVar.get() results[row_num][col_num] = value input_values.append(value) + if not form.NonBlocking: + element.TKStringVar.set('') try: input_values_dictionary[element.Key] = value except: pass @@ -1364,7 +1365,7 @@ def CharWidthInPixels(): tkbutton.image = photo tkbutton.configure(wraplength=wraplen+10, font=font) # set wrap to width of widget tkbutton.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) - if not focus_set and btype == BUTTON_TYPE_CLOSES_WIN: + if element.Focus is True or (MyFlexForm.UseDefaultFocus and not focus_set): focus_set = True element.TKButton.bind('', element.ReturnKeyHandler) element.TKButton.focus_set() @@ -1382,7 +1383,7 @@ def CharWidthInPixels(): if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: element.TKEntry.configure(fg=text_color) element.TKEntry.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) - if not focus_set: + if element.Focus is True or (MyFlexForm.UseDefaultFocus and not focus_set): focus_set = True element.TKEntry.focus_set() # ------------------------- COMBO BOX (Drop Down) element ------------------------- # @@ -1453,7 +1454,7 @@ def CharWidthInPixels(): element.TKText.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) if element.EnterSubmits: element.TKText.bind('', element.ReturnKeyHandler) - if not focus_set: + if element.Focus is True or (MyFlexForm.UseDefaultFocus and not focus_set): focus_set = True element.TKText.focus_set() if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: @@ -1748,19 +1749,19 @@ def MsgBox(*args, button_color=None, button_type=MSG_BOX_OK, auto_close=False, a pad =1 # show either an OK or Yes/No depending on paramater if button_type is MSG_BOX_YES_NO: - form.AddRow(Text('', size=(pad, 1), auto_size_text=False), Yes(button_color=button_color), No( + form.AddRow(Text('', size=(pad, 1), auto_size_text=False), Yes(button_color=button_color, focus=True, bind_return_key=True), No( button_color=button_color)) (button_text, values) = form.Show() return button_text == 'Yes' elif button_type is MSG_BOX_CANCELLED: - form.AddRow(Text('', size=(pad, 1), auto_size_text=False), SimpleButton('Cancelled', button_color=button_color)) + form.AddRow(Text('', size=(pad, 1), auto_size_text=False), SimpleButton('Cancelled', button_color=button_color, focus=True, bind_return_key=True)) elif button_type is MSG_BOX_ERROR: - form.AddRow(Text('', size=(pad, 1), auto_size_text=False), SimpleButton('ERROR', size=(5, 1), button_color=button_color)) + form.AddRow(Text('', size=(pad, 1), auto_size_text=False), SimpleButton('ERROR', size=(5, 1), button_color=button_color, focus=True, bind_return_key=True)) elif button_type is MSG_BOX_OK_CANCEL: - form.AddRow(Text('', size=(pad, 1), auto_size_text=False), SimpleButton('OK', size=(5, 1), button_color=button_color), + form.AddRow(Text('', size=(pad, 1), auto_size_text=False), SimpleButton('OK', size=(5, 1), button_color=button_color, focus=True, bind_return_key=True), SimpleButton('Cancel', size=(5, 1), button_color=button_color)) else: - form.AddRow(Text('', size=(pad, 1), auto_size_text=False), SimpleButton('OK', size=(5, 1), button_color=button_color)) + form.AddRow(Text('', size=(pad, 1), auto_size_text=False), SimpleButton('OK', size=(5, 1), button_color=button_color, focus=True, bind_return_key=True)) button, values = form.Show() return button @@ -2169,7 +2170,7 @@ def ScrolledTextBox(*args, button_color=None, yes_no=False, auto_close=False, au height_computed = MAX_SCROLLED_TEXT_BOX_HEIGHT if height_computed > MAX_SCROLLED_TEXT_BOX_HEIGHT else height_computed if height: height_computed = height - form.AddRow(Multiline(complete_output, size=(max_line_width, height_computed)), auto_size_text=True) + form.AddRow(Multiline(complete_output, size=(max_line_width, height_computed))) pad = max_line_total-15 if max_line_total > 15 else 1 # show either an OK or Yes/No depending on paramater if yes_no: @@ -2415,9 +2416,9 @@ def main(): form_rows = [[Text('You are running the PySimpleGUI.py file itself')], [Text('You should be importing it rather than running it\n')], [Text('Here is your sample input form....')], - [Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), InputText('Source'),FolderBrowse()], + [Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), InputText('Source', focus=True),FolderBrowse()], [Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), InputText('Dest'), FolderBrowse()], - [Submit(), Cancel()]] + [Submit(bind_return_key=True), Cancel()]] button, (source, dest) = form.LayoutAndRead(form_rows) From 9c1ebeb0b4d3bb2a41c6f20adf06eeb2f77b45d6 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 9 Aug 2018 11:37:44 -0400 Subject: [PATCH 120/209] Removed need to flag a form as one returning a dictionary --- Demo_Dictionary.py | 13 +++++++---- PySimpleGUI.py | 54 +++++++++++++++++++++++++++++++--------------- 2 files changed, 46 insertions(+), 21 deletions(-) diff --git a/Demo_Dictionary.py b/Demo_Dictionary.py index c1a060da4..9b001eae6 100644 --- a/Demo_Dictionary.py +++ b/Demo_Dictionary.py @@ -2,14 +2,19 @@ # THIS FILE REQIRES THE LATEST PySimpleGUI.py FILE # IT WILL NOT WORK WITH CURRENT PIP RELEASE (2.7) +# +# If you want to use the return values as Dictionary feature, you need to download the PySimpleGUI.py file +# from GitHub and then place it in your project's folder. This SHOULD cause it to use this downloaded version +# instead of the pip installed one, if you've pip installed it. You can always uninstall the pip one :-) -# Shows how to use return values in dictionary form -form = sg.FlexForm('Simple data entry form', use_dictionary=True) # begin with a blank form +# This design pattern shows how to use return values in dictionary form + +form = sg.FlexForm('Simple data entry form') # begin with a blank form layout = [ [sg.Text('Please enter your Name, Address, Phone')], - [sg.Text('Name', size=(15, 1)), sg.InputText('1', key='name')], + [sg.Text('Name', size=(15, 1)), sg.InputText('1')], [sg.Text('Address', size=(15, 1)), sg.InputText('2', key='address')], [sg.Text('Phone', size=(15, 1)), sg.InputText('3', key='phone')], [sg.Submit(), sg.Cancel()] @@ -17,6 +22,6 @@ button, values = form.LayoutAndRead(layout) -sg.MsgBox(button, values, values['name'], values['address'], values['phone']) +sg.MsgBox(button, values, values[0], values['address'], values['phone']) print(values) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index c75a160fe..07bbc3afe 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -774,7 +774,7 @@ class FlexForm: ''' Display a user defined for and return the filled in data ''' - def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=None, auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, use_dictionary=False): + def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=None, auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON): self.AutoSizeText = auto_size_text if auto_size_text is not None else DEFAULT_AUTOSIZE_TEXT self.AutoSizeButtons = auto_size_buttons if auto_size_buttons is not None else DEFAULT_AUTOSIZE_BUTTONS self.Title = title @@ -803,7 +803,7 @@ def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT self.ReturnValues = None self.ReturnValuesDictionary = None self.ResultsBuilt = False - self.UseDictionary = use_dictionary + self.UseDictionary = False self.UseDefaultFocus = False # ------------------------- Add ONE Row to Form ------------------------- # @@ -853,9 +853,14 @@ def Show(self, non_blocking=False): try: if element.Focus: found_focus = True - break except: pass + try: + if element.Key is not None: + self.UseDictionary = True + except: + pass + if not found_focus: self.UseDefaultFocus = True # -=-=-=-=-=-=-=-=- RUN the GUI -=-=-=-=-=-=-=-=- ## @@ -1145,6 +1150,7 @@ def BuildResults(form): button_pressed_text = None input_values = [] input_values_dictionary = {} + key_counter = 0 for row_num,row in enumerate(form.Rows): for col_num, element in enumerate(row): if element.Type == ELEM_TYPE_INPUT_TEXT: @@ -1153,25 +1159,31 @@ def BuildResults(form): input_values.append(value) if not form.NonBlocking: element.TKStringVar.set('') - try: + if element.Key is None: + input_values_dictionary[key_counter] = value + key_counter +=1 + else: input_values_dictionary[element.Key] = value - except: pass elif element.Type == ELEM_TYPE_INPUT_CHECKBOX: value=element.TKIntVar.get() results[row_num][col_num] = value input_values.append(value != 0) - try: + if element.Key is None: + input_values_dictionary[key_counter] = value + key_counter +=1 + else: input_values_dictionary[element.Key] = value - except: pass elif element.Type == ELEM_TYPE_INPUT_RADIO: RadVar=element.TKIntVar.get() this_rowcol = EncodeRadioRowCol(row_num,col_num) value = RadVar == this_rowcol results[row_num][col_num] = value input_values.append(value) - try: + if element.Key is None: + input_values_dictionary[key_counter] = value + key_counter +=1 + else: input_values_dictionary[element.Key] = value - except: pass elif element.Type == ELEM_TYPE_BUTTON: if results[row_num][col_num] is True: button_pressed_text = element.ButtonText @@ -1181,17 +1193,21 @@ def BuildResults(form): value=element.TKStringVar.get() results[row_num][col_num] = value input_values.append(value) - try: + if element.Key is None: + input_values_dictionary[key_counter] = value + key_counter +=1 + else: input_values_dictionary[element.Key] = value - except: pass elif element.Type == ELEM_TYPE_INPUT_LISTBOX: items=element.TKListbox.curselection() value = [element.Values[int(item)] for item in items] results[row_num][col_num] = value input_values.append(value) - try: + if element.Key is None: + input_values_dictionary[key_counter] = value + key_counter +=1 + else: input_values_dictionary[element.Key] = value - except: pass elif element.Type == ELEM_TYPE_INPUT_SPIN: try: value=element.TKStringVar.get() @@ -1199,9 +1215,11 @@ def BuildResults(form): value = 0 results[row_num][col_num] = value input_values.append(value) - try: + if element.Key is None: + input_values_dictionary[key_counter] = value + key_counter +=1 + else: input_values_dictionary[element.Key] = value - except: pass elif element.Type == ELEM_TYPE_INPUT_SLIDER: try: value=element.TKIntVar.get() @@ -1221,9 +1239,11 @@ def BuildResults(form): value = None results[row_num][col_num] = value input_values.append(value) - try: + if element.Key is None: + input_values_dictionary[key_counter] = value + key_counter +=1 + else: input_values_dictionary[element.Key] = value - except: pass try: input_values_dictionary.pop(None, None) # clean up dictionary include None was included From 4bb89514cb9b7f4e59358cfa00561bf3c43cb4f1 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 9 Aug 2018 11:53:42 -0400 Subject: [PATCH 121/209] Changed what gets executed when buttons pushed --- Demo_Script_Launcher.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/Demo_Script_Launcher.py b/Demo_Script_Launcher.py index bcc06b004..50370a42e 100644 --- a/Demo_Script_Launcher.py +++ b/Demo_Script_Launcher.py @@ -1,5 +1,5 @@ import PySimpleGUI as sg -import os +import subprocess def Launcher(): @@ -8,7 +8,8 @@ def Launcher(): layout = [ [sg.Text('Script output....', size=(40, 1))], [sg.Output(size=(88, 20))], - [sg.ReadFormButton('script1'), sg.ReadFormButton('script2'), sg.SimpleButton('EXIT')] + [sg.ReadFormButton('script1'), sg.ReadFormButton('script2'), sg.SimpleButton('EXIT')], + [sg.Text('Manual command', size=(15,1)), sg.InputText(focus=True), sg.ReadFormButton('Run', bind_return_key=True)] ] form.Layout(layout) @@ -19,16 +20,22 @@ def Launcher(): if button == 'EXIT' or button is None: break # exit button clicked if button == 'script1': - ExecuteCommandOS('python SimScript.py') + ExecuteCommandSubprocess('pip','list') elif button == 'script2': - ExecuteCommandOS('python SimScript.py') - elif button == 'Enter': - ExecuteCommandOS(value[0]) # send string without carriage return on end - - -def ExecuteCommandOS(command): - output = os.popen(command).read() - print(output) + ExecuteCommandSubprocess('python', '--version') + elif button == 'Run': + ExecuteCommandSubprocess(value[0]) # send string without carriage return on end + + +def ExecuteCommandSubprocess(command, *args): + try: + sp = subprocess.Popen([command,*args], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = sp.communicate() + if out: + print(out.decode("utf-8")) + if err: + print(err.decode("utf-8")) + except: pass if __name__ == '__main__': From 644c441fbebce5005a4d95a08e4a9abddfaf0972 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 9 Aug 2018 12:07:22 -0400 Subject: [PATCH 122/209] Updates for Version 2.8 --- docs/index.md | 70 +++++++++++++++++++++++++++++++++++++++++++-------- readme.md | 30 ++++++++++++++-------- 2 files changed, 79 insertions(+), 21 deletions(-) diff --git a/docs/index.md b/docs/index.md index f03d65375..785197977 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,15 +2,20 @@ ![pysimplegui_logo](https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png) -[![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 +[![Downloads](http://pepy.tech/badge/pysimplegui)](http://pepy.tech/project/pysimplegui) since Jul 11, 2018 + +![Documentation Status](https://readthedocs.org/projects/pysimplegui/badge/?version=latest) + + # PySimpleGUI - (Ver 2.7) + (Ver 2.8) +[Formatted ReadTheDocs Version of this Readme](http://pysimplegui.readthedocs.io/) Super-simple GUI to grasp... Powerfully customizable. -Note - *Python3* is required to run PySimpleGUI. It takes advantage of some Python3 features that do not translate well into Python2. +Note - ***Python3*** is required to run PySimpleGUI. It takes advantage of some Python3 features that do not translate well into Python2. -Looking to take your Python code from the world of command lines and into the convenience of a GUI? Have a Raspberry Pi with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK? Look no further, you've found your GUI package. +Looking to take your Python code from the world of command lines and into the convenience of a GUI? Have a Raspberry **Pi** with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK? Into Machine Learning and are sick of the command line? Look no further, **you've found your GUI package**. import PySimpleGUI as sg @@ -21,9 +26,11 @@ Looking to take your Python code from the world of command lines and into the co Build beautiful customized forms that fit your specific problem. Let PySimpleGUI solve your GUI problem while you solve the real problems. Do you really want to plod through the mountains of code required to program tkinter? +PySimpleGUI wraps tkinter so that you get all the same widgets as you would tkinter, but you interact with them in a **much** more friendly way. + ![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) -Perhaps you're looking for a way to interact with your Raspberry Pi in a more friendly way. The is the same form as above, except shown on a Pi. +Perhaps you're looking for a way to interact with your **Raspberry Pi** in a more friendly way. The is the same form as above, except shown on a Pi. ![raspberry pi](https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg) @@ -40,7 +47,7 @@ You can build an async media player GUI with custom buttons in 30 lines of code. I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? -There are a number of 'easy to use' Python GUIs, but they're **very** limiting. PySimpleGUI takes the best of packages like `EasyGUI`and `WxSimpleGUI` , both really handy but limited. The primary difference between these and PySimpleGUI is that in addition to getting the simple Message Boxes you also get the ability to make your own forms that are highly customizeable. Don't like the standard Message Box? Then make your own! +There are a number of 'easy to use' Python GUIs, but they're **very** limiting. PySimpleGUI takes the best of packages like `EasyGUI`and `WxSimpleGUI` , both really handy but limited. The primary difference between these and `PySimpleGUI` is that in addition to getting the simple Message Boxes you also get the ability to **make your own forms** that are highly customizeable. Don't like the standard Message Box? Then make your own! Every call has optional parameters so that you can change the look and feel. Don't like the button color? It's easy to change by adding a button_color parameter to your widget. @@ -73,9 +80,12 @@ The `PySimpleGUI` package is focused on the ***developer***. How can the desire Persistent Windows Redirect Python Output/Errors to scrolling window 'Higher level' APIs (e.g. MessageBox, YesNobox, ...) - Single-Line-Of-Coide Proress Bar & Debug Print + Single-Line-Of-Code Proress Bar & Debug Print Complete control of colors, look and feel Button images + Return values as dictionary + Set focus + Bind return key to buttons An example of many widgets used on a single form. A little further down you'll find the TWENTY lines of code required to create this complex form. Try it if you don't believe it. Start Python, copy and paste the code below into the >>> prompt and hit enter. This will pop up... @@ -480,6 +490,10 @@ This is the code that **displays** the form, collects the information and return ## Return values + As of version 2.8 there are 2 forms of return values, list and dictionary. +### Return values as a list + By default return values are a list of values, one entry for each input field. + Return information from FlexForm, SG's primary form builder interface, is in this format: button, (value1, value2, ...) @@ -498,14 +512,41 @@ If you have a SINGLE value being returned, it is written this way: button, (value1,) = form.LayoutAndRead(form_rows) - Another way of parsing the return values is to store the list of values into a variable representing the list of values. + Another way of parsing the return values is to store the list of values into a variable representing the list of values and then index each individual value. This is not the preferred way of doing it. button, value_list = form.LayoutAndRead(form_rows) value1 = value_list[0] value2 = value_list[1] ... +### Return values as a dictionary + +If you wish to receive the return values as a dictionary rather than a simple list, then you'll have to one thing... + * Mark each input element you wish to be in the dictionary with the keyword `key`. + +If **any** element in the form has a `key`, then **all** of the return values are returned via a dictionary. If some elements do not have a key, then they are numbered starting at zero. + +This sample program demonstrates these 2 steps as well as how to address the return values (e.g. `values['name']`) + + + import PySimpleGUI as sg + form = sg.FlexForm('Simple data entry form') + layout = [ + [sg.Text('Please enter your Name, Address, Phone')], + [sg.Text('Name', size=(15, 1)), sg.InputText('1')], + [sg.Text('Address', size=(15, 1)), sg.InputText('2', key='address')], + [sg.Text('Phone', size=(15, 1)), sg.InputText('3', key='phone')], + [sg.Submit(), sg.Cancel()] + ] + + button, values = form.LayoutAndRead(layout) + + sg.MsgBox(button, values, values[0], values['address'], values['phone']) + + --- + + ## All Widgets / Elements This code utilizes as many of the elements in one form as possible. @@ -588,7 +629,7 @@ Parameter Descriptions. You will find these same parameters specified for each auto_size_text - Bool. True if elements should size themselves according to contents auto_size_buttons - Bool. True if button elements should size themselves according to their text label scale - Set size of element to be a multiple of the Element size - location - Location to place window in pixels + location - (x,y) Location to place window in pixels button_color - Default color for buttons (foreground, background). Can be text or hex progress_bar_color - Foreground and background colors for progress bars is_tabbed_form - Bool. If True then form is a tabbed form @@ -598,6 +639,9 @@ Parameter Descriptions. You will find these same parameters specified for each icon - .ICO file that will appear on the Task Bar and end of Title Bar +#### Window Location +PySimpleGUI computes the exact center of your window and centers the window on the screen. If you want to locate your window elsewhere, such as the system default of (0,0), if you have 2 ways of doing this. The first is when the form is created. Use the `location` parameter to set where the window. The second way of doing this is to use the `SetOptions` call which will set the default window location for all windows in the future. + #### Sizes Note several variables that deal with "size". Element sizes are measured in characters. A Text Element with a size of 20,1 has a size of 20 characters wide by 1 character tall. @@ -892,7 +936,7 @@ Checkbox elements are like Radio Button elements. They return a bool indicating . text - Text to display next to checkbox - default- Bool. Initial state + default- Bool + None. Initial state. True = Checked, False = unchecked, None = Not available (grayed out) scale - Amount to scale size of element size - (width, height) size of element in characters auto_size_text- Bool. True if should size width to fit text @@ -1158,11 +1202,13 @@ Recall that values is a list as well. Multiple tabs in the form would return li Starting in version 2.5 you can change the background colors for the window and the Elements. Your forms can go from this: + ![snap0155](https://user-images.githubusercontent.com/13696193/43273879-a9fdc10a-90cb-11e8-8c20-4f6a244ebe2f.jpg) to this... with one function call... + ![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) @@ -1418,6 +1464,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. | 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ | 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting +| 2.8.0 | Aug 9, 2018 - New None default option for Checkbox element, text color option for all elements, return values as a dictionary, setting focus, binding return key ### Release Notes @@ -1432,6 +1479,7 @@ New debug printing capability. `sg.Print` Listboxes are still without scrollwheels. The mouse can drag to see more items. The mouse scrollwheel will also scroll the list and will `page up` and `page down` keys. 2.7 Is the "feature complete" release. Pretty much all features are done and in the code +2.8 More text color controls. The caller has more control over things like the focus and what buttons should be clicked when enter key is pressed. Return values as a dictionary! (NICE addition) ### Upcoming @@ -1497,7 +1545,7 @@ Here are the steps to run that application The pip command is all there is to the setup. -The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. +The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. ![snap0109](https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg) diff --git a/readme.md b/readme.md index b433cf533..785197977 100644 --- a/readme.md +++ b/readme.md @@ -8,13 +8,14 @@ # PySimpleGUI - (Ver 2.7) + (Ver 2.8) +[Formatted ReadTheDocs Version of this Readme](http://pysimplegui.readthedocs.io/) Super-simple GUI to grasp... Powerfully customizable. Note - ***Python3*** is required to run PySimpleGUI. It takes advantage of some Python3 features that do not translate well into Python2. -Looking to take your Python code from the world of command lines and into the convenience of a GUI? Have a Raspberry **Pi** with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK? Look no further, **you've found your GUI package**. +Looking to take your Python code from the world of command lines and into the convenience of a GUI? Have a Raspberry **Pi** with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK? Into Machine Learning and are sick of the command line? Look no further, **you've found your GUI package**. import PySimpleGUI as sg @@ -25,6 +26,8 @@ Looking to take your Python code from the world of command lines and into the co Build beautiful customized forms that fit your specific problem. Let PySimpleGUI solve your GUI problem while you solve the real problems. Do you really want to plod through the mountains of code required to program tkinter? +PySimpleGUI wraps tkinter so that you get all the same widgets as you would tkinter, but you interact with them in a **much** more friendly way. + ![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) Perhaps you're looking for a way to interact with your **Raspberry Pi** in a more friendly way. The is the same form as above, except shown on a Pi. @@ -80,6 +83,9 @@ The `PySimpleGUI` package is focused on the ***developer***. How can the desire Single-Line-Of-Code Proress Bar & Debug Print Complete control of colors, look and feel Button images + Return values as dictionary + Set focus + Bind return key to buttons An example of many widgets used on a single form. A little further down you'll find the TWENTY lines of code required to create this complex form. Try it if you don't believe it. Start Python, copy and paste the code below into the >>> prompt and hit enter. This will pop up... @@ -515,18 +521,19 @@ If you have a SINGLE value being returned, it is written this way: ### Return values as a dictionary -If you wish to receive the return values as a dictionary rather than a simple list, then you'll have to do 2 things: -1. Indicate in the form creation that the return should be a dictionary by setting `use_dictionary = True` -2. Mark each input element you wish to be in the dictionary with the keyword `key`. +If you wish to receive the return values as a dictionary rather than a simple list, then you'll have to one thing... + * Mark each input element you wish to be in the dictionary with the keyword `key`. + +If **any** element in the form has a `key`, then **all** of the return values are returned via a dictionary. If some elements do not have a key, then they are numbered starting at zero. This sample program demonstrates these 2 steps as well as how to address the return values (e.g. `values['name']`) import PySimpleGUI as sg - form = sg.FlexForm('Simple data entry form', use_dictionary=True) + form = sg.FlexForm('Simple data entry form') layout = [ [sg.Text('Please enter your Name, Address, Phone')], - [sg.Text('Name', size=(15, 1)), sg.InputText('1', key='name')], + [sg.Text('Name', size=(15, 1)), sg.InputText('1')], [sg.Text('Address', size=(15, 1)), sg.InputText('2', key='address')], [sg.Text('Phone', size=(15, 1)), sg.InputText('3', key='phone')], [sg.Submit(), sg.Cancel()] @@ -534,7 +541,7 @@ This sample program demonstrates these 2 steps as well as how to address the ret button, values = form.LayoutAndRead(layout) - sg.MsgBox(button, values, values['name'], values['address'], values['phone']) + sg.MsgBox(button, values, values[0], values['address'], values['phone']) --- @@ -1195,11 +1202,13 @@ Recall that values is a list as well. Multiple tabs in the form would return li Starting in version 2.5 you can change the background colors for the window and the Elements. Your forms can go from this: + ![snap0155](https://user-images.githubusercontent.com/13696193/43273879-a9fdc10a-90cb-11e8-8c20-4f6a244ebe2f.jpg) to this... with one function call... + ![snap0156](https://user-images.githubusercontent.com/13696193/43273880-aa1955e6-90cb-11e8-94b6-673ecdb2698c.jpg) @@ -1455,7 +1464,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.5.0 | July 26, 2018 - Colors. Listbox scrollbar. tkinter Progress Bar instead of homegrown. | 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ | 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting -| 2.8.0 | Aug xx, 2018 - PLANNED - New None default option for Checkbox element, text color option for all elements, return values as a dictionary +| 2.8.0 | Aug 9, 2018 - New None default option for Checkbox element, text color option for all elements, return values as a dictionary, setting focus, binding return key ### Release Notes @@ -1470,6 +1479,7 @@ New debug printing capability. `sg.Print` Listboxes are still without scrollwheels. The mouse can drag to see more items. The mouse scrollwheel will also scroll the list and will `page up` and `page down` keys. 2.7 Is the "feature complete" release. Pretty much all features are done and in the code +2.8 More text color controls. The caller has more control over things like the focus and what buttons should be clicked when enter key is pressed. Return values as a dictionary! (NICE addition) ### Upcoming @@ -1535,7 +1545,7 @@ Here are the steps to run that application The pip command is all there is to the setup. -The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. +The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. ![snap0109](https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg) From 7e1ff1d543c66630dcce60a8c5e0b6d9a14c101d Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 9 Aug 2018 13:00:50 -0400 Subject: [PATCH 123/209] New Multi-line update option --- PySimpleGUI.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 07bbc3afe..b36063675 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -404,6 +404,8 @@ def __init__(self, default_text='', enter_submits = False, scale=(None, None), s super().__init__(ELEM_TYPE_INPUT_MULTILINE, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=text_color, key=key) return + def Update(self, NewValue): + self.TKText.insert(1.0, NewValue) def __del__(self): super().__del__() @@ -1006,11 +1008,11 @@ def __del__(self): # ====================================================================== # # ------------------------- INPUT TEXT Element lazy functions ------------------------- # -def In(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, focus=False): - return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, focus=focus) +def In(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, focus=False, key=None): + return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, focus=focus, key=key) -def Input(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, focus=False): - return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, focus=focus) +def Input(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, focus=False, key=None): + return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, focus=focus, key=key) # ------------------------- INPUT COMBO Element lazy functions ------------------------- # def Combo(values, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None): From 8f220a7ac19696be5a88a3eaef12690ff39859f8 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 9 Aug 2018 13:18:04 -0400 Subject: [PATCH 124/209] Refresh of Demo applications --- Demo_Compare_Files.py | 2 +- Demo_GoodColors.py | 10 +++--- Demo_HowDoI.py | 31 ++++++++++-------- Demo_Machine_Learning.py | 50 ++++++++++++++++++++++++++++ Demo_Media_Player.py | 16 +++++---- Demo_NonBlocking_Form.py | 22 +++---------- Demo_Pi_Robotics.py | 2 +- Demo_Recipes.py | 69 +++++++++++++++++++++------------------ Demo_Super_Simple_Form.py | 18 ++++++---- 9 files changed, 136 insertions(+), 84 deletions(-) create mode 100644 Demo_Machine_Learning.py diff --git a/Demo_Compare_Files.py b/Demo_Compare_Files.py index 25077a9a3..c5ecf7f23 100644 --- a/Demo_Compare_Files.py +++ b/Demo_Compare_Files.py @@ -1,7 +1,7 @@ import PySimpleGUI as sg def GetFilesToCompare(): - with sg.FlexForm('File Compare', auto_size_text=True) as form: + with sg.FlexForm('File Compare') as form: form_rows = [[sg.Text('Enter 2 files to comare')], [sg.Text('File 1', size=(15, 1)), sg.InputText(), sg.FileBrowse()], [sg.Text('File 2', size=(15, 1)), sg.InputText(), sg.FileBrowse()], diff --git a/Demo_GoodColors.py b/Demo_GoodColors.py index 7d0402f8d..f1c0a09c3 100644 --- a/Demo_GoodColors.py +++ b/Demo_GoodColors.py @@ -9,33 +9,33 @@ def main(): #===== Show some nice BLUE colors with yellow text ===== ===== ===== ===== ===== ===== =====# text_color = gg.YELLOWS[0] - buttons = (gg.SimpleButton(f'BLUES[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.BLUES)) + buttons = (gg.SimpleButton('BLUES[{}]\n{}'.format(j, c), button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.BLUES)) form.AddRow(gg.T('Button Colors Using PySimpleGUI.BLUES')) form.AddRow(*buttons) form.AddRow(gg.Text('_' * 100, size=(65, 1))) #===== Show some nice PURPLE colors with yellow text ===== ===== ===== ===== ===== ===== =====# - buttons = (gg.SimpleButton(f'PURPLES[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.PURPLES)) + buttons = (gg.SimpleButton('PURPLES[{}]\n{}'.format(j, c), button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.PURPLES)) form.AddRow(gg.T('Button Colors Using PySimpleGUI.PURPLES')) form.AddRow(*buttons) form.AddRow(gg.Text('_' * 100, size=(65, 1))) #===== Show some nice GREEN colors with yellow text ===== ===== ===== ===== ===== ===== =====# - buttons = (gg.SimpleButton(f'GREENS[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.GREENS)) + buttons = (gg.SimpleButton('GREENS[{}]\n{}'.format(j, c), button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.GREENS)) form.AddRow(gg.T('Button Colors Using PySimpleGUI.GREENS')) form.AddRow(*buttons) form.AddRow(gg.Text('_' * 100, size=(65, 1))) #===== Show some nice TAN colors with yellow text ===== ===== ===== ===== ===== ===== =====# text_color = gg.GREENS[0] # let's use GREEN text on the tan - buttons = (gg.SimpleButton(f'TANS[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.TANS)) + buttons = (gg.SimpleButton('TANS[{}]\n{}'.format(j, c), button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.TANS)) form.AddRow(gg.T('Button Colors Using PySimpleGUI.TANS')) form.AddRow(*buttons) form.AddRow(gg.Text('_' * 100, size=(65, 1))) #===== Show some nice YELLOWS colors with black text ===== ===== ===== ===== ===== ===== =====# text_color = 'black' # let's use black text on the tan - buttons = (gg.SimpleButton(f'YELLOWS[{j}]\n{c}', button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.YELLOWS)) + buttons = (gg.SimpleButton('YELLOWS[{}]\n{}'.format(j, c), button_color=(text_color, c), size=(10,2)) for j, c in enumerate(gg.YELLOWS)) form.AddRow(gg.T('Button Colors Using PySimpleGUI.YELLOWS')) form.AddRow(*buttons) form.AddRow(gg.Text('_' * 100, size=(65, 1))) diff --git a/Demo_HowDoI.py b/Demo_HowDoI.py index 257a06561..2d260e8b6 100644 --- a/Demo_HowDoI.py +++ b/Demo_HowDoI.py @@ -1,9 +1,9 @@ -import PySimpleGUI as SG +import PySimpleGUI 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' +HOW_DO_I_COMMAND = 'python -m howdoi.howdoi -n 2' # 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' @@ -18,25 +18,29 @@ def HowDoI(): ''' # ------- Make a new FlexForm ------- # # Set system-wide options that will affect all future forms. Give our form a spiffy look and feel - SG.SetOptions(background_color='#9FB8AD', text_element_background_color='#9FB8AD', element_background_color='#9FB8AD', scrollbar_color=None, input_elements_background_color='#F7F3EC', button_color=('white','#475841')) - form = SG.FlexForm('How Do I ??', auto_size_text=True, default_element_size=(30, 2), icon=DEFAULT_ICON) - form.AddRow(SG.Text('Ask and your answer will appear here....', size=(40, 1))) - form.AddRow(SG.Output(size=(90, 20))) - form.AddRow(SG.Multiline(size=(85, 5), enter_submits=True), - SG.ReadFormButton('SEND', button_color=(SG.YELLOWS[0], SG.BLUES[0])), - SG.SimpleButton('EXIT', button_color=(SG.YELLOWS[0], SG.GREENS[0]))) - + sg.SetOptions(background_color='#9FB8AD', text_element_background_color='#9FB8AD', element_background_color='#9FB8AD', scrollbar_color=None, input_elements_background_color='#F7F3EC', button_color=('white', '#475841')) + form = sg.FlexForm('How Do I ??', auto_size_text=True, default_element_size=(30, 2), icon=DEFAULT_ICON) + layout = [ + [sg.Text('Ask and your answer will appear here....', size=(40, 1))], + [sg.Output(size=(88, 20))], + [ sg.Spin(values=(1, 2, 3, 4), initial_value=1, size=(2, 1), key='Num Answers'), sg.T('Num Answers'), sg.Checkbox('Display Full Text', key='full text')], + [sg.Multiline(size=(85, 5), enter_submits=True, key='query'), + sg.ReadFormButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0]), bind_return_key=True), + sg.SimpleButton('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))] + ] + form.Layout(layout) # ---===--- Loop taking in user input and using it to query HowDoI --- # while True: (button, value) = form.Read() + if button == 'SEND': - QueryHowDoI(value[0][:-1]) # send string without carriage return on end + QueryHowDoI(value['query'], value['Num Answers'], value['full text']) # send string without carriage return on end else: break # exit button clicked exit(69) -def QueryHowDoI(Query): +def QueryHowDoI(Query, num_answers, full_text): ''' Kicks off a subprocess to send the 'Query' to HowDoI Prints the result, which in this program will route to a gooeyGUI window @@ -44,7 +48,8 @@ def QueryHowDoI(Query): :return: nothing ''' howdoi_command = HOW_DO_I_COMMAND - t = subprocess.Popen(howdoi_command + ' '+ Query, stdout=subprocess.PIPE) + 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() print('You asked: '+ Query) print('_______________________________________') diff --git a/Demo_Machine_Learning.py b/Demo_Machine_Learning.py new file mode 100644 index 000000000..6de6283f9 --- /dev/null +++ b/Demo_Machine_Learning.py @@ -0,0 +1,50 @@ +import PySimpleGUI as sg + +def MachineLearningGUI(): + sg.SetOptions(text_justification='right') + form = sg.FlexForm('Machine Learning Front End', font=("Helvetica", 12)) # begin with a blank form + + layout = [[sg.Text('Machine Learning Command Line Parameters', font=('Helvetica', 16))], + [sg.Text('Passes', size=(15, 1)), sg.Spin(values=[i for i in range(1, 1000)], initial_value=20, size=(6, 1)), + sg.Text('Steps', size=(18, 1)), sg.Spin(values=[i for i in range(1, 1000)], initial_value=20, size=(6, 1))], + [sg.Text('ooa', size=(15, 1)), sg.In(default_text='6', size=(10, 1)), sg.Text('nn', size=(15, 1)), sg.In(default_text='10', size=(10, 1))], + [sg.Text('q', size=(15, 1)), sg.In(default_text='ff', size=(10, 1)), sg.Text('ngram', size=(15, 1)), sg.In(default_text='5', size=(10, 1))], + [sg.Text('l', size=(15, 1)), sg.In(default_text='0.4', size=(10, 1)), sg.Text('Layers', size=(15, 1)), sg.Drop(values=('BatchNorm', 'other'),auto_size_text=True)], + [sg.Text('_' * 100, size=(65, 1))], + [sg.Text('Flags', font=('Helvetica', 15), justification='left')], + [sg.Checkbox('Normalize', size=(12, 1), default=True), sg.Checkbox('Verbose', size=(20, 1))], + [sg.Checkbox('Cluster', size=(12, 1)), sg.Checkbox('Flush Output', size=(20, 1), default=True)], + [sg.Checkbox('Write Results', size=(12, 1)), sg.Checkbox('Keep Intermediate Data', size=(20, 1))], + [sg.Text('_' * 100, size=(65, 1))], + [sg.Text('Loss Functions', font=('Helvetica', 15), justification='left')], + [sg.Radio('Cross-Entropy', 'loss', size=(12, 1)), sg.Radio('Logistic', 'loss', default=True, size=(12, 1))], + [sg.Radio('Hinge', 'loss', size=(12, 1)), sg.Radio('Huber', 'loss', size=(12, 1))], + [sg.Radio('Kullerback', 'loss', size=(12, 1)), sg.Radio('MAE(L1)', 'loss', size=(12, 1))], + [sg.Radio('MSE(L2)', 'loss', size=(12, 1)), sg.Radio('MB(L0)', 'loss', size=(12, 1))], + [sg.Submit(), sg.Cancel()]] + button, values = form.LayoutAndRead(layout) + del(form) + sg.SetOptions(text_justification='left') + + return button, values + + +def CustomMeter(): + + progress_bar = sg.ProgressBar(10000, orientation='h', size=(20,20)) + + layout = [[sg.Text('A custom progress meter')], + [progress_bar], + [sg.Cancel()]] + + form = sg.FlexForm('Custom Progress Meter') + form.LayoutAndRead(layout, non_blocking=True) + + for i in range(10000): + button, values = form.ReadNonBlocking() + progress_bar.UpdateBar(i) + + +if __name__ == '__main__': + CustomMeter() + MachineLearningGUI() diff --git a/Demo_Media_Player.py b/Demo_Media_Player.py index fdc014346..87e5586e4 100644 --- a/Demo_Media_Player.py +++ b/Demo_Media_Player.py @@ -7,7 +7,9 @@ # https://user-images.githubusercontent.com/13696193/43159403-45c9726e-8f50-11e8-9da0-0d272e20c579.jpg # def MediaPlayerGUI(): - + background = '#F0F0F0' + # Set the backgrounds the same as the background on the buttons + sg.SetOptions(background_color=background, element_background_color=background) # Images are located in a subfolder in the Demo Media Player.py folder image_pause = './ButtonGraphics/Pause.png' image_restart = './ButtonGraphics/Restart.png' @@ -22,18 +24,18 @@ def MediaPlayerGUI(): font=("Helvetica", 25)) # define layout of the rows layout= [[sg.Text('Media File Player',size=(17,1), font=("Helvetica", 25))], - [TextElem], - [sg.ReadFormButton('Restart Song', button_color=sg.TRANSPARENT_BUTTON, + [TextElem], + [sg.ReadFormButton('Restart Song', button_color=(background,background), image_filename=image_restart, image_size=(50, 50), image_subsample=2, border_width=0), sg.Text(' ' * 2), - sg.ReadFormButton('Pause', button_color=sg.TRANSPARENT_BUTTON, + sg.ReadFormButton('Pause', button_color=(background,background), image_filename=image_pause, image_size=(50, 50), image_subsample=2, border_width=0), sg.Text(' ' * 2), - sg.ReadFormButton('Next', button_color=sg.TRANSPARENT_BUTTON, + sg.ReadFormButton('Next', button_color=(background,background), image_filename=image_next, image_size=(50, 50), image_subsample=2, border_width=0), sg.Text(' ' * 2), - sg.Text(' ' * 2), sg.SimpleButton('Exit', button_color=sg.TRANSPARENT_BUTTON, - image_filename=image_exit, image_size=(50, 50), image_subsample=2, border_width=0)], + sg.Text(' ' * 2), sg.SimpleButton('Exit', button_color=(background,background), + image_filename=image_exit, image_size=(50, 50), image_subsample=2, border_width=0)], [sg.Text('_'*30)], [sg.Text(' '*30)], [ diff --git a/Demo_NonBlocking_Form.py b/Demo_NonBlocking_Form.py index 6121e7254..79693a25f 100644 --- a/Demo_NonBlocking_Form.py +++ b/Demo_NonBlocking_Form.py @@ -44,18 +44,14 @@ def StatusOutputExample(): def RemoteControlExample(): # Make a form, but don't use context manager - form = sg.FlexForm('Running Timer', auto_size_text=True) - # Create a text element that will be updated with status information on the GUI itself - output_element = sg.Text('', size=(8, 2), font=('Helvetica', 20), justification='center') - + form = sg.FlexForm('Robotics Remote Control', auto_size_text=True) form_rows = [[sg.Text('Robotics Remote Control')], - [output_element], [sg.T(' '*10), sg.RealtimeButton('Forward')], [ sg.RealtimeButton('Left'), sg.T(' '*15), sg.RealtimeButton('Right')], [sg.T(' '*10), sg.RealtimeButton('Reverse')], [sg.T('')], - [sg.Quit()] + [sg.Quit(button_color=('black', 'orange'))] ] form.LayoutAndRead(form_rows, non_blocking=True) @@ -66,25 +62,15 @@ def RemoteControlExample(): # else it won't refresh. # # your program's main loop - i=0 while (True): # This is the code that reads and updates your window - output_element.Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100)) button, values = form.ReadNonBlocking() if button is not None: - print(button) + sg.Print(button) if button == 'Quit' or values is None: break - if button == 'LED On': - print('Turning on the LED') - elif button == 'LED Off': - print('Turning off the LED') - - i += 1 - # Your code begins here - time.sleep(.01) + # time.sleep(.01) - # Broke out of main loop. Close the window. form.CloseNonBlockingForm() diff --git a/Demo_Pi_Robotics.py b/Demo_Pi_Robotics.py index e04d5458a..607fa3661 100644 --- a/Demo_Pi_Robotics.py +++ b/Demo_Pi_Robotics.py @@ -88,7 +88,7 @@ def RemoteControlExample_NoGraphics(): def main(): RemoteControlExample_NoGraphics() # Uncomment to get the fancy graphics version. Be sure and download the button images! - # RemoteControlExample() + RemoteControlExample() sg.MsgBox('End of non-blocking demonstration') if __name__ == '__main__': diff --git a/Demo_Recipes.py b/Demo_Recipes.py index 9653247f7..d34fac495 100644 --- a/Demo_Recipes.py +++ b/Demo_Recipes.py @@ -5,10 +5,10 @@ # A simple blocking form. Your best starter-form def SourceDestFolders(): with sg.FlexForm('Demo Source / Destination Folders') as form: - form_rows = [[sg.Text('Enter the Source and Destination folders')], + form_rows = ([sg.Text('Enter the Source and Destination folders')], [sg.Text('Source Folder', size=(15, 1), justification='right'), sg.InputText('Source'), sg.FolderBrowse()], [sg.Text('Destination Folder', size=(15, 1), justification='right'), sg.InputText('Dest'), sg.FolderBrowse()], - [sg.Submit(), sg.Cancel()]] + [sg.Submit(), sg.Cancel()]) button, (source, dest) = form.LayoutAndRead(form_rows) if button == 'Submit': @@ -39,7 +39,7 @@ def MachineLearningGUI(): [sg.Radio('Kullerback', 'loss', size=(12, 1)), sg.Radio('MAE(L1)', 'loss', size=(12, 1))], [sg.Radio('MSE(L2)', 'loss', size=(12, 1)), sg.Radio('MB(L0)', 'loss', size=(12, 1))], [sg.Submit(), sg.Cancel()]] - button, values = form.LayoutAndShow(layout) + button, values = form.LayoutAndRead(layout) del(form) sg.SetOptions(text_justification='left') @@ -70,10 +70,8 @@ def Everything(): sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10), sg.Spin(values=('Spin Box 1', '2','3'), initial_value='Spin Box 1')], [sg.Text('_' * 80)], - [sg.Text('Choose A Folder', size=(35, 1))], [sg.Text('Your Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Default Folder'), sg.FolderBrowse()], - [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('black', '#EDE5B7'))] - ] + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('black', '#EDE5B7'))] ] button, values = form.LayoutAndRead(layout) @@ -113,8 +111,8 @@ def Everything_NoContextManager(): def ProgressMeter(): - for i in range(1,100): - if not sg.EasyProgressMeter('My Meter', i + 1, 100, orientation='v'): break + for i in range(1,1000): + if not sg.EasyProgressMeter('My Meter', i + 1, 1000, orientation='h'): break time.sleep(.01) # Blocking form that doesn't close @@ -122,7 +120,7 @@ def ChatBot(): with sg.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: layout = [[(sg.Text('This is where standard out is being routed', size=[40, 1]))], [sg.Output(size=(80, 20))], - [sg.Multiline(size=(70, 5), enter_submits=True), sg.ReadFormButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0])), sg.SimpleButton('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]] + [sg.Multiline(size=(70, 5), enter_submits=True), sg.ReadFormButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0]), bind_return_key=True), sg.SimpleButton('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))]] # notice this is NOT the usual LayoutAndRead call because you don't yet want to read the form # if you call LayoutAndRead from here, then you will miss the first button click form.Layout(layout) @@ -181,39 +179,46 @@ def NonBlockingPeriodicUpdateForm(): def DebugTest(): # SG.Print('How about we print a bunch of random numbers?', , size=(90,40)) for i in range (1,300): - sg.Print(i, randint(1, 1000), end='', sep='-') + sg.Print('Here are 300 random numbers', i, randint(1, 1000), sep='-') + +# Change the colors and set borders to 0 for a flat look +def ChangeLookAndFeel(colors): + sg.SetOptions(background_color=colors['BACKGROUND'], + text_element_background_color=colors['BACKGROUND'], + element_background_color=colors['BACKGROUND'], + text_color=colors['TEXT'], + input_elements_background_color=colors['INPUT'], + button_color=colors['BUTTON'], + progress_meter_color=colors['PROGRESS'], + border_width=0, + slider_border_width=0, + progress_meter_border_depth=0, + scrollbar_color=(colors['INPUT']), + element_text_color=colors['TEXT']) #=---------------------------------- main ------------------------------ def main(): - # sg.MsgBox('Changing look and feel.', 'Done by calling SetOptions') - SourceDestFolders() - - sg.SetOptions(background_color='#9FB8AD', text_element_background_color='#9FB8AD', element_background_color='#9FB8AD', scrollbar_color=None, input_elements_background_color='#F7F3EC', button_color=('white','#475841'), border_width=0, slider_border_width=0, progress_meter_border_depth=0) - - MachineLearningGUI() - - Everything_NoContextManager() - - # sg.SetOptions(background_color='#B89FB6', text_element_background_color='#B89FB6', element_background_color='#B89FB6', button_color=('white','#7E6C92'), text_color='#3F403F',border_width=0, slider_border_width=0, progress_meter_border_depth=0) - - sg.SetOptions(background_color='#A5CADD', input_elements_background_color='#E0F5FF', text_element_background_color='#A5CADD', element_background_color='#A5CADD', button_color=('white','#303952'), text_color='#822E45',border_width=0, progress_meter_color=('#3D8255','white'), slider_border_width=0, progress_meter_border_depth=0) + # Green & tan color scheme + colors1 = {'BACKGROUND' : '#9FB8AD', 'TEXT': sg.COLOR_SYSTEM_DEFAULT, 'INPUT':'#F7F3EC', 'BUTTON': ('white', '#475841'),'PROGRESS':sg.DEFAULT_PROGRESS_BAR_COLOR } + # light green with tan + colors2 = {'BACKGROUND' : '#B7CECE', 'TEXT': 'black', 'INPUT':'#FDFFF7', 'BUTTON': ('white', '#658268'), 'PROGRESS':('#247BA0','#F8FAF0')} + # blue with light blue color scheme + colors3 = {'BACKGROUND' : '#A5CADD', 'TEXT': '#6E266E', 'INPUT':'#E0F5FF', 'BUTTON': ('white', '#303952'),'PROGRESS':sg.DEFAULT_PROGRESS_BAR_COLOR} + ChatBot() Everything() + SourceDestFolders() + ChangeLookAndFeel(colors2) ProgressMeter() - - # Set system-wide options that will affect all future forms - - + ChangeLookAndFeel(colors3) + Everything() + ChangeLookAndFeel(colors2) + MachineLearningGUI() + Everything_NoContextManager() NonBlockingPeriodicUpdateForm_ContextManager() - - NonBlockingPeriodicUpdateForm() - - - ChatBot() - DebugTest() sg.MsgBox('Done with all recipes') diff --git a/Demo_Super_Simple_Form.py b/Demo_Super_Simple_Form.py index 0d13708e8..54726258a 100644 --- a/Demo_Super_Simple_Form.py +++ b/Demo_Super_Simple_Form.py @@ -2,12 +2,16 @@ form = sg.FlexForm('Simple data entry form') # begin with a blank form -layout = [[sg.Text('Please enter your Name, Address, Phone')], - [sg.Text('Name', size=(15, 1)), sg.InputText()], - [sg.Text('Address', size=(15, 1)), sg.InputText()], - [sg.Text('Phone', size=(15, 1)), sg.InputText()], - [sg.Submit(), sg.Cancel()]] +layout = [ + [sg.Text('Please enter your Name, Address, Phone')], + [sg.Text('Name', size=(15, 1)), sg.InputText('1', key='name')], + [sg.Text('Address', size=(15, 1)), sg.InputText('2', key='address')], + [sg.Text('Phone', size=(15, 1)), sg.InputText('3', key='phone')], + [sg.Submit(), sg.Cancel()] + ] -button, (name, address, phone) = form.LayoutAndRead(layout) +button, values = form.LayoutAndRead(layout) -print(name, address, phone) \ No newline at end of file +sg.MsgBox(button, values['name'], values['address'], values['phone']) + +print(values) From 2b98a234349e4271ed4e8f1af9f1ac0edf70cfe5 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 10 Aug 2018 09:15:19 -0400 Subject: [PATCH 125/209] NEW cookbook! New do_not_clear option for inputs, fix for window flash problem --- PySimpleGUI.py | 24 ++- docs/cookbook.md | 456 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 471 insertions(+), 9 deletions(-) create mode 100644 docs/cookbook.md diff --git a/PySimpleGUI.py b/PySimpleGUI.py index b36063675..9b54e9ca4 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -205,7 +205,7 @@ def __del__(self): # Input Class # # ---------------------------------------------------------------------- # class InputText(Element): - def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None, text_color=None, key=None, focus=False): + def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None, text_color=None, do_not_clear=False, key=None, focus=False): ''' Input a line of text Element :param default_text: Default value to display @@ -219,6 +219,7 @@ def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto self.PasswordCharacter = password_char bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR self.Focus = focus + self.do_not_clear = do_not_clear super().__init__(ELEM_TYPE_INPUT_TEXT, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=text_color, key=key) @@ -387,7 +388,7 @@ def __del__(self): # Multiline # # ---------------------------------------------------------------------- # class Multiline(Element): - def __init__(self, default_text='', enter_submits = False, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None, key=None, focus=False): + def __init__(self, default_text='', enter_submits = False, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None, do_not_clear=False, key=None, focus=False): ''' Input Multi-line Element :param default_text: @@ -401,6 +402,7 @@ def __init__(self, default_text='', enter_submits = False, scale=(None, None), s self.EnterSubmits = enter_submits bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR self.Focus = focus + self.do_not_clear = do_not_clear super().__init__(ELEM_TYPE_INPUT_MULTILINE, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=text_color, key=key) return @@ -913,6 +915,8 @@ def Read(self): def ReadNonBlocking(self, Message=''): if self.TKrootDestroyed: return None, None + if not self.Shown: + self.Show(non_blocking=True) if Message: print(Message) try: @@ -1008,11 +1012,11 @@ def __del__(self): # ====================================================================== # # ------------------------- INPUT TEXT Element lazy functions ------------------------- # -def In(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, focus=False, key=None): - return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, focus=focus, key=key) +def In(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, do_not_clear=False, focus=False, key=None): + return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, do_not_clear = do_not_clear, focus=focus, key=key) -def Input(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, focus=False, key=None): - return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, focus=focus, key=key) +def Input(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, do_not_clear = False, focus=False, key=None): + return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, do_not_clear=do_not_clear, focus=focus, key=key) # ------------------------- INPUT COMBO Element lazy functions ------------------------- # def Combo(values, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None): @@ -1159,7 +1163,7 @@ def BuildResults(form): value=element.TKStringVar.get() results[row_num][col_num] = value input_values.append(value) - if not form.NonBlocking: + if not form.NonBlocking and not element.do_not_clear: element.TKStringVar.set('') if element.Key is None: input_values_dictionary[key_counter] = value @@ -1235,7 +1239,7 @@ def BuildResults(form): elif element.Type == ELEM_TYPE_INPUT_MULTILINE: try: value=element.TKText.get(1.0, tk.END) - if not form.NonBlocking: + if not form.NonBlocking and not element.do_not_clear: element.TKText.delete('1.0', tk.END) except: value = None @@ -1593,7 +1597,8 @@ def CharWidthInPixels(): #....................................... DONE creating and laying out window ..........................# if MyFlexForm.IsTabbedForm: master = MyFlexForm.ParentWindow - screen_width = master.winfo_screenwidth() # get window info to move to middle of screen + master.attributes('-alpha', 0) # hide window while getting info and moving + screen_width = master.winfo_screenwidth() # get window info to move to middle of screen screen_height = master.winfo_screenheight() if MyFlexForm.Location != (None, None): x,y = MyFlexForm.Location @@ -1612,6 +1617,7 @@ def CharWidthInPixels(): move_string = '+%i+%i'%(int(x),int(y)) master.geometry(move_string) + master.attributes('-alpha', 255) # Make window visible again master.update_idletasks() # don't forget return diff --git a/docs/cookbook.md b/docs/cookbook.md new file mode 100644 index 000000000..b6f58c2f5 --- /dev/null +++ b/docs/cookbook.md @@ -0,0 +1,456 @@ + +# The PySimpleGUI Cookbook + +## Simple Data Entry - Return Values As List +Same GUI screen except the return values are in a list instead of a dictionary and doesn't have initial values. + +![super simple 2](https://user-images.githubusercontent.com/13696193/43934091-8100e29a-9c1b-11e8-8d0a-9bd2d13e6d8e.jpg) + + import PySimpleGUI as sg + + # Very basic form. Return values as a list + form = sg.FlexForm('Simple data entry form') # begin with a blank form + + layout = [ + [sg.Text('Please enter your Name, Address, Phone')], + [sg.Text('Name', size=(15, 1)), sg.InputText()], + [sg.Text('Address', size=(15, 1)), sg.InputText()], + [sg.Text('Phone', size=(15, 1)), sg.InputText()], + [sg.Submit(), sg.Cancel()] + ] + + button, values = form.LayoutAndRead(layout) + + print(button, values[0], values[1], values[2]) + +## Simple data entry - Return Values As Dictionary +A simple form with default values. Results returned in a dictionary. Does not use a context manager + +![super simple 2](https://user-images.githubusercontent.com/13696193/43934091-8100e29a-9c1b-11e8-8d0a-9bd2d13e6d8e.jpg) + + import PySimpleGUI as sg + + # Very basic form. Return values as a dictionary + form = sg.FlexForm('Simple data entry form') # begin with a blank form + + layout = [ + [sg.Text('Please enter your Name, Address, Phone')], + [sg.Text('Name', size=(15, 1)), sg.InputText('name', key='name')], + [sg.Text('Address', size=(15, 1)), sg.InputText('address', key='address')], + [sg.Text('Phone', size=(15, 1)), sg.InputText('phone', key='phone')], + [sg.Submit(), sg.Cancel()] + ] + + button, values = form.LayoutAndRead(layout) + + print(button, values['name'], values['address'], values['phone']) + +--------------------- + + + +----------- +## Simple File Browse +Browse for a filename that is populated into the input field. + +![simple file browse](https://user-images.githubusercontent.com/13696193/43934539-d8bd9490-9c1d-11e8-927f-98b523776fcb.jpg) + + import PySimpleGUI as sg + + with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: + form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], + [sg.InputText(), sg.FileBrowse()], + [sg.Submit(), sg.Cancel()]] + (button, (source_filename,)) = form.LayoutAndShow(form_rows) + + print(button, source_filename) + +-------------------------- +## Compare 2 Files + +Browse to get 2 file names that can be then compared. Uses a context manager + +![compare 2 files](https://user-images.githubusercontent.com/13696193/43934659-60dc5fbe-9c1e-11e8-8d2b-07c0e3b61892.jpg) + + import PySimpleGUI as sg + + with sg.FlexForm('File Compare') as form: + form_rows = [[sg.Text('Enter 2 files to comare')], + [sg.Text('File 1', size=(8, 1)), sg.InputText(), sg.FileBrowse()], + [sg.Text('File 2', size=(8, 1)), sg.InputText(), sg.FileBrowse()], + [sg.Submit(), sg.Cancel()]] + + button, values = form.LayoutAndShow(form_rows) + + print(button, values) + +--------------- +## Nearly All Widgets with Green Color Theme with Context Manager +Example of nearly all of the widgets in a single form. Uses a customized color scheme. This recipe uses a context manager, the preferred method. + +![green everything](https://user-images.githubusercontent.com/13696193/43937043-7d0794be-9c29-11e8-8591-31373ddd5c34.jpg) + + # Green & tan color scheme + sg.SetOptions(background_color='#9FB8AD', + text_element_background_color='#9FB8AD', + element_background_color='#9FB8AD', + input_elements_background_color='#F7F3EC', + button_color=('white', '#475841'), + border_width=0, + slider_border_width=0, + progress_meter_border_depth=0, + scrollbar_color='#F7F3EC') + + with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25))], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText()], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text should you decide not to type anything', size=(35, 3)), + sg.Multiline(default_text='A second multi-line', size=(35, 3))], + [sg.InputCombo(('Combobox 1', 'Combobox 2'), size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85)], + [sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3', 'Listbox 4'), size=(30, 3)), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10), + sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 1')], + [sg.Text('_' * 80)], + [sg.Text('Your Folder', size=(15, 1), auto_size_text=False, justification='right'), + sg.InputText('Default Folder'), sg.FolderBrowse()], + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('black', '#EDE5B7'))]] + + button, values = form.LayoutAndRead(layout) +------------- +### All Widgets No Context Manager + +![green everything](https://user-images.githubusercontent.com/13696193/43937043-7d0794be-9c29-11e8-8591-31373ddd5c34.jpg) + + import PySimpleGUI as sg + + # Green & tan color scheme + sg.SetOptions(background_color='#9FB8AD', + text_element_background_color='#9FB8AD', + element_background_color='#9FB8AD', + input_elements_background_color='#F7F3EC', + button_color=('white', '#475841'), + border_width=0, + slider_border_width=0, + progress_meter_border_depth=0, + scrollbar_color='#F7F3EC') + + form = sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) + layout = [ + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25))], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText('This is my text')], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text should you decide not to type anything', size=(35, 3)), + sg.Multiline(default_text='A second multi-line', size=(35, 3))], + [sg.InputCombo(('Combobox 1', 'Combobox 2'), size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85)], + [sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(30, 3)), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10), + sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 1')], + [sg.Text('_' * 80)], + [sg.Text('Choose A Folder', size=(35, 1))], + [sg.Text('Your Folder', size=(15, 1), auto_size_text=False, justification='right'), + sg.InputText('Default Folder'), sg.FolderBrowse()], + [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', '#7E6C92'))] + ] + + button, values = form.LayoutAndRead(layout) + +---- +## Non-Blocking Form With Periodic Update +An async form that has a button read loop. A Text Element is updated periodically with a running timer. There is no context manager for this recipe because the loop that reads the form is likely to be some distance away from where the form was initialized. + +![non-blocking](https://user-images.githubusercontent.com/13696193/43955295-70f6ac48-9c6d-11e8-8ea2-e6729ba9330c.jpg) + + import PySimpleGUI as sg + import time + + form = sg.FlexForm('Running Timer', auto_size_text=True) + # create a text element that will be updated periodically + text_element = sg.Text('', size=(10, 2), font=('Helvetica', 20), justification='center') + + form_rows = [[sg.Text('Stopwatch', size=(20,2), justification='center')], + [text_element], + [sg.T(' ' * 5), sg.ReadFormButton('Start/Stop', focus=True), sg.Quit()]] + + form.LayoutAndRead(form_rows, non_blocking=True) + + timer_running = True + i = 0 + # loop to process user clicks + while True: + i += 1 * (timer_running is True) + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': # if user closed the window using X or clicked Quit button + break + elif button == 'Start/Stop': + timer_running = not timer_running + text_element.Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100)) + + time.sleep(.01) + # if the loop finished then need to close the form for the user + form.CloseNonBlockingForm() + del (form) +---- +## Async Form (Non-Blocking) with Context Manager +Like the previous recipe, this form is an async form. The difference is that this form uses a context manager. + +![non-blocking 2](https://user-images.githubusercontent.com/13696193/43955456-4d5d9ef8-9c6e-11e8-8598-80dddf8eba6f.jpg) + + import PySimpleGUI as sg + import time + + with sg.FlexForm('Running Timer', auto_size_text=True) as form: + text_element = sg.Text('', size=(10, 2), font=('Helvetica', 20), text_color='red', justification='center') + layout = [[sg.Text('Non blocking GUI with updates', justification='center')], + [text_element], + [sg.T(' ' * 15), sg.Quit()]] + form.LayoutAndRead(layout, non_blocking=True) + + for i in range(1, 500): + text_element.Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100)) + button, values = form.ReadNonBlocking() + if values is None or button == 'Quit': # if user closed the window using X + break + time.sleep(.01) + else: + # if the loop finished then need to close the form for the user + form.CloseNonBlockingForm() +---- +## Callback Function Simulation +The architecture of some programs works better with button callbacks instead of handling in-line. While button callbacks are part of the PySimpleGUI implementation, they are not directly exposed to the caller. The way to get the same result as callbacks is to simulate them with a recipe like this one. + +![button callback 2](https://user-images.githubusercontent.com/13696193/43955588-e139ddc6-9c6e-11e8-8c78-c1c226b8d9b1.jpg) + + import PySimpleGUI as sg + + # This design pattern simulates button callbacks + # Note that callbacks are NOT a part of the package's interface to the + # caller intentionally. The underlying implementation actually does use + # tkinter callbacks. They are simply hidden from the user. + + # The callback functions + def button1(): + print('Button 1 callback') + + def button2(): + print('Button 2 callback') + + # Create a standard form + form = sg.FlexForm('Button callback example') + # Layout the design of the GUI + layout = [[sg.Text('Please click a button', auto_size_text=True)], + [sg.ReadFormButton('1'), sg.ReadFormButton('2'), sg.Quit()]] + # Show the form to the user + form.Layout(layout) + + # Event loop. Read buttons, make callbacks + while True: + # Read the form + button, value = form.Read() + # Take appropriate action based on button + if button == '1': + button1() + elif button == '2': + button2() + elif button =='Quit' or button is None: + break + + # All done! + sg.MsgBoxOK('Done') + +----- +## Realtime Buttons (Good For Raspberry Pi) +This recipe implements a remote control interface for a robot. There are 4 directions, forward, reverse, left, right. When a button is clicked, PySimpleGUI immediately returns button events for as long as the buttons is held down. When released, the button events stop. This is an async/non-blocking form. + + + import PySimpleGUI as sg + + # Make a form, but don't use context manager + form = sg.FlexForm('Robotics Remote Control', auto_size_text=True) + + form_rows = [[sg.Text('Robotics Remote Control')], + [sg.T(' ' * 10), sg.RealtimeButton('Forward')], + [sg.RealtimeButton('Left'), sg.T(' ' * 15), sg.RealtimeButton('Right')], + [sg.T(' ' * 10), sg.RealtimeButton('Reverse')], + [sg.T('')], + [sg.Quit(button_color=('black', 'orange'))] + ] + + form.LayoutAndRead(form_rows, non_blocking=True) + + # + # Some place later in your code... + # You need to perform a ReadNonBlocking on your form every now and then or + # else it won't refresh. + # + # your program's main loop + while (True): + # This is the code that reads and updates your window + button, values = form.ReadNonBlocking() + if button is not None: + print(button) + if button == 'Quit' or values is None: + break + + form.CloseNonBlockingForm() + +--------- + +## Easy Progress Meter +This recipe shows just how easy it is to add a progress meter to your code. + + import PySimpleGUI as sg + + for i in range(1000): + sg.EasyProgressMeter('Easy Meter Example', i+1, 1000) + +![progress meter 6](https://user-images.githubusercontent.com/13696193/43955982-73b33b38-9c70-11e8-8b07-cc1473a58a73.jpg) +----- +## Tabbed Form +Tabbed forms are **easy** to make and use in PySimpleGUI. You simple may your layouts for each tab and then instead of `LayoutAndRead` you call `ShowTabbedForm`. Results are returned as a list of form results. Each tab acts like a single form. + + +![tabbed form](https://user-images.githubusercontent.com/13696193/43956352-cffa6564-9c71-11e8-971b-2b395a668bf3.jpg) + + import PySimpleGUI as sg + + with sg.FlexForm('', auto_size_text=True) as form: + with sg.FlexForm('', auto_size_text=True) as form2: + + layout_tab_1 = [[sg.Text('First tab', size=(20, 1), font=('helvetica', 15))], + [sg.InputText(), sg.Text('Enter some info')], + [sg.Submit(button_color=('red', 'yellow')), sg.Cancel(button_color=('white', 'blue'))]] + + layout_tab_2 = [[sg.Text('Second Tab', size=(20, 1), font=('helvetica', 15))], + [sg.InputText(), sg.Text('Enter some info')], + [sg.Submit(button_color=('red', 'yellow')), sg.Cancel(button_color=('white', 'blue'))]] + + results = sg.ShowTabbedForm('Tabbed form example', (form, layout_tab_1, 'First Tab'), + (form2, layout_tab_2,'Second Tab')) + + sg.MsgBox(results) +----- +## Button Graphics (Media Player) +Buttons can have PNG of GIF images on them. This Media Player recipe requires 4 images in order to function correctly. The background is set to the same color as the button background so that they blend together. + +![media player](https://user-images.githubusercontent.com/13696193/43958418-5dd133f2-9c79-11e8-9432-0a67007e85ac.jpg) + + import PySimpleGUI as sg + + background = '#F0F0F0' + # Set the backgrounds the same as the background on the buttons + sg.SetOptions(background_color=background, element_background_color=background) + # Images are located in a subfolder in the Demo Media Player.py folder + image_pause = './ButtonGraphics/Pause.png' + image_restart = './ButtonGraphics/Restart.png' + image_next = './ButtonGraphics/Next.png' + image_exit = './ButtonGraphics/Exit.png' + + # A text element that will be changed to display messages in the GUI + TextElem = sg.Text('', size=(15, 2), font=("Helvetica", 14)) + + # Open a form, note that context manager can't be used generally speaking for async forms + form = sg.FlexForm('Media File Player', auto_size_text=True, default_element_size=(20, 1), + font=("Helvetica", 25)) + # define layout of the rows + layout = [[sg.Text('Media File Player', size=(17, 1), font=("Helvetica", 25))], + [TextElem], + [sg.ReadFormButton('Restart Song', button_color=(background, background), + image_filename=image_restart, image_size=(50, 50), image_subsample=2, border_width=0), + sg.Text(' ' * 2), + sg.ReadFormButton('Pause', button_color=(background, background), + image_filename=image_pause, image_size=(50, 50), image_subsample=2, border_width=0), + sg.Text(' ' * 2), + sg.ReadFormButton('Next', button_color=(background, background), + image_filename=image_next, image_size=(50, 50), image_subsample=2, border_width=0), + sg.Text(' ' * 2), + sg.Text(' ' * 2), sg.SimpleButton('Exit', button_color=(background, background), + image_filename=image_exit, image_size=(50, 50), image_subsample=2, + border_width=0)], + [sg.Text('_' * 30)], + [sg.Text(' ' * 30)], + [ + sg.Slider(range=(-10, 10), default_value=0, size=(10, 20), orientation='vertical', + font=("Helvetica", 15)), + sg.Text(' ' * 2), + sg.Slider(range=(-10, 10), default_value=0, size=(10, 20), orientation='vertical', + font=("Helvetica", 15)), + sg.Text(' ' * 8), + sg.Slider(range=(-10, 10), default_value=0, size=(10, 20), orientation='vertical', + font=("Helvetica", 15))], + [sg.Text('Bass', font=("Helvetica", 15), size=(6, 1)), + sg.Text('Treble', font=("Helvetica", 15), size=(10, 1)), + sg.Text('Volume', font=("Helvetica", 15), size=(7, 1))] + + ] + + # Call the same LayoutAndRead but indicate the form is non-blocking + form.LayoutAndRead(layout, non_blocking=True) + # Our event loop + while (True): + # Read the form (this call will not block) + button, values = form.ReadNonBlocking() + if button == 'Exit' or values is None: + break + # If a button was pressed, display it on the GUI by updating the text element + if button: + TextElem.Update(button) +---- +## Script Launcher - Persistent Form +This form doesn't close after button clicks. To achieve this the buttons are specified as `sg.ReadFormButton` instead of `sg.SimpleButton`. The exception to this is the EXIT button. Clicking it will close the form. This program will run commands and display the output in the scrollable window. + +![launcher 2](https://user-images.githubusercontent.com/13696193/43958519-b30af218-9c79-11e8-88da-fadc69da818c.jpg) + + import PySimpleGUI as sg + import subprocess + + def Launcher(): + + form = sg.FlexForm('Script launcher') + + layout = [ + [sg.Text('Script output....', size=(40, 1))], + [sg.Output(size=(88, 20))], + [sg.ReadFormButton('script1'), sg.ReadFormButton('script2'), sg.SimpleButton('EXIT')], + [sg.Text('Manual command', size=(15,1)), sg.InputText(focus=True), sg.ReadFormButton('Run', bind_return_key=True)] + ] + + form.Layout(layout) + + # ---===--- Loop taking in user input and using it to query HowDoI --- # + while True: + (button, value) = form.Read() + if button == 'EXIT' or button is None: + break # exit button clicked + if button == 'script1': + ExecuteCommandSubprocess('pip','list') + elif button == 'script2': + ExecuteCommandSubprocess('python', '--version') + elif button == 'Run': + ExecuteCommandSubprocess(value[0]) # send string without carriage return on end + + + def ExecuteCommandSubprocess(command, *args): + try: + sp = subprocess.Popen([command,*args], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = sp.communicate() + if out: + print(out.decode("utf-8")) + if err: + print(err.decode("utf-8")) + except: pass + + + if __name__ == '__main__': + Launcher() From 800f929e6b869e9bd4847c9cd44c1c8d50a2f303 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 10 Aug 2018 09:20:30 -0400 Subject: [PATCH 126/209] Readme changes --- readme.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 785197977..d8438d555 100644 --- a/readme.md +++ b/readme.md @@ -9,7 +9,9 @@ # PySimpleGUI (Ver 2.8) + [Formatted ReadTheDocs Version of this Readme](http://pysimplegui.readthedocs.io/) +[COOKBOOK documentation now online!](https://pysimplegui.readthedocs.io/en/latest/cookbook/) Super-simple GUI to grasp... Powerfully customizable. @@ -138,6 +140,7 @@ You will see a number of different styles of buttons, data entry fields, etc, in - A form is a list of rows - A row is a list of elements - Return values are a list of button presses and input values. +- Return values can also be represented as a dictionary It's stunning that after so many years Python still hasn't put forth a GUI framework that truly fits the language's basic data structures, especially lists. It's hard to argue with the success to be had in quickly building GUI applications using this package's syntax. @@ -409,7 +412,7 @@ You will use these design patterns or code templates for all of your "normal" (b ### How GUI Programming in Python Should Look -GUI programming in Python is a mess. tkinter kinda sucks. Why is Python such a great teaching language and yet no GUI framework exists that lends itself to the basic building blocks of Python, the list? +GUI programming in Python is a mess. tkinter kinda sucks. Why is Python such a great teaching language and yet no GUI framework exists that lends itself to the basic building blocks of Python, the list or dictionary? The key to custom forms in PySimpleGUI is to view forms as ROWS of Widgets (Elements). Each row is specified as a list of these widgets. Put the rows together and you've got a form. @@ -1465,6 +1468,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ | 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting | 2.8.0 | Aug 9, 2018 - New None default option for Checkbox element, text color option for all elements, return values as a dictionary, setting focus, binding return key +| 2.9.0 | Aug XX,2018 - Screen flash fix, do_not_clear input field option, ### Release Notes @@ -1545,7 +1549,7 @@ Here are the steps to run that application The pip command is all there is to the setup. -The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. +The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. ![snap0109](https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg) From 0d202246d364d3b90d8606982bdea5911f6d6bc8 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 10 Aug 2018 09:21:26 -0400 Subject: [PATCH 127/209] Readme formatting --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index d8438d555..0d55aa851 100644 --- a/readme.md +++ b/readme.md @@ -11,6 +11,7 @@ (Ver 2.8) [Formatted ReadTheDocs Version of this Readme](http://pysimplegui.readthedocs.io/) + [COOKBOOK documentation now online!](https://pysimplegui.readthedocs.io/en/latest/cookbook/) Super-simple GUI to grasp... Powerfully customizable. From 9d3d3f4bc1daf7b715e2dc7cd7f920f68ab8c570 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 10 Aug 2018 16:10:07 -0400 Subject: [PATCH 128/209] Machine Learning Recipe added --- docs/cookbook.md | 49 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/docs/cookbook.md b/docs/cookbook.md index b6f58c2f5..8052b7d48 100644 --- a/docs/cookbook.md +++ b/docs/cookbook.md @@ -432,13 +432,13 @@ This form doesn't close after button clicks. To achieve this the buttons are sp while True: (button, value) = form.Read() if button == 'EXIT' or button is None: - break # exit button clicked - if button == 'script1': + break # exit button clicked + if button == 'script1': ExecuteCommandSubprocess('pip','list') elif button == 'script2': ExecuteCommandSubprocess('python', '--version') elif button == 'Run': - ExecuteCommandSubprocess(value[0]) # send string without carriage return on end + ExecuteCommandSubprocess(value[0]) def ExecuteCommandSubprocess(command, *args): @@ -454,3 +454,46 @@ This form doesn't close after button clicks. To achieve this the buttons are sp if __name__ == '__main__': Launcher() +---- +## Machine Learning GUI +A standard non-blocking GUI with lots of inputs. + +![machine learning green](https://user-images.githubusercontent.com/13696193/43979000-408b77ba-9cb7-11e8-9ffd-24c156767532.jpg) + + import PySimpleGUI as sg + + # Green & tan color scheme + sg.SetOptions(background_color='#9FB8AD', + text_element_background_color='#9FB8AD', + element_background_color='#9FB8AD', + input_elements_background_color='#F7F3EC', + button_color=('white', '#475841'), + border_width=0, + slider_border_width=0, + progress_meter_border_depth=0, + scrollbar_color='#F7F3EC') + + sg.SetOptions(text_justification='right') + + form = sg.FlexForm('Machine Learning Front End', font=("Helvetica", 12)) # begin with a blank form + + layout = [[sg.Text('Machine Learning Command Line Parameters', font=('Helvetica', 16))], + [sg.Text('Passes', size=(15, 1)), sg.Spin(values=[i for i in range(1, 1000)], initial_value=20, size=(6, 1)), + sg.Text('Steps', size=(18, 1)), sg.Spin(values=[i for i in range(1, 1000)], initial_value=20, size=(6, 1))], + [sg.Text('ooa', size=(15, 1)), sg.In(default_text='6', size=(10, 1)), sg.Text('nn', size=(15, 1)), sg.In(default_text='10', size=(10, 1))], + [sg.Text('q', size=(15, 1)), sg.In(default_text='ff', size=(10, 1)), sg.Text('ngram', size=(15, 1)), sg.In(default_text='5', size=(10, 1))], + [sg.Text('l', size=(15, 1)), sg.In(default_text='0.4', size=(10, 1)), sg.Text('Layers', size=(15, 1)), sg.Drop(values=('BatchNorm', 'other'),auto_size_text=True)], + [sg.Text('_' * 100, size=(65, 1))], + [sg.Text('Flags', font=('Helvetica', 15), justification='left')], + [sg.Checkbox('Normalize', size=(12, 1), default=True), sg.Checkbox('Verbose', size=(20, 1))], + [sg.Checkbox('Cluster', size=(12, 1)), sg.Checkbox('Flush Output', size=(20, 1), default=True)], + [sg.Checkbox('Write Results', size=(12, 1)), sg.Checkbox('Keep Intermediate Data', size=(20, 1))], + [sg.Text('_' * 100, size=(65, 1))], + [sg.Text('Loss Functions', font=('Helvetica', 15), justification='left')], + [sg.Radio('Cross-Entropy', 'loss', size=(12, 1)), sg.Radio('Logistic', 'loss', default=True, size=(12, 1))], + [sg.Radio('Hinge', 'loss', size=(12, 1)), sg.Radio('Huber', 'loss', size=(12, 1))], + [sg.Radio('Kullerback', 'loss', size=(12, 1)), sg.Radio('MAE(L1)', 'loss', size=(12, 1))], + [sg.Radio('MSE(L2)', 'loss', size=(12, 1)), sg.Radio('MB(L0)', 'loss', size=(12, 1))], + [sg.Submit(), sg.Cancel()]] + + button, values = form.LayoutAndRead(layout) From 5abcd7c54624e046def8ec41f3faa9c3dad1624d Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 10 Aug 2018 16:16:16 -0400 Subject: [PATCH 129/209] ListDict always returned now.... hybrid list & dictionary Now all return values are through a new class called ListDict. It's an ordered dictionary that allows access like a dictionary and a list. --- PySimpleGUI.py | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 9b54e9ca4..2933ef0d9 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -4,6 +4,7 @@ from tkinter import ttk import tkinter.scrolledtext as tkst import tkinter.font +from collections import OrderedDict import datetime import sys import textwrap @@ -1142,6 +1143,27 @@ def EncodeRadioRowCol(row, col): RadValue = row * 1000 + col return RadValue +#===== ListDict - New data type for returning values ===== +class ListDict(OrderedDict): + def __iter__(self): + for v in self.values(): + yield v + + def __getitem__(self, item): + if isinstance(item, slice): + return list(self.values())[item] + else: + return super().__getitem__(item) + + def __str__(self): + return str(self.ToList()) + + def ToList(self): + output = [] + for item in self.values(): + output.append(item) + return output + # ------- FUNCTION BuildResults. Form exiting so build the results to pass back ------- # # format of return values is # (Button Pressed, input_values) @@ -1155,7 +1177,8 @@ def BuildResults(form): results=form.Results button_pressed_text = None input_values = [] - input_values_dictionary = {} + # input_values_dictionary = {} + input_values_dictionary = ListDict() key_counter = 0 for row_num,row in enumerate(form.Rows): for col_num, element in enumerate(row): @@ -1255,10 +1278,9 @@ def BuildResults(form): input_values_dictionary.pop(None, None) # clean up dictionary include None was included except: pass - if not form.UseDictionary: - form.ReturnValues = button_pressed_text, input_values - else: - form.ReturnValues = button_pressed_text, input_values_dictionary + # return values are always a list dictionary now (ordered dict with added features) + form.ReturnValues = button_pressed_text, input_values_dictionary + form.ReturnValuesDictionary = button_pressed_text, input_values_dictionary form.ResultsBuilt = True return form.ReturnValues From d6ff296d9f5ac12ba2348cda2fbc2d0b48a18ed8 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 10 Aug 2018 17:38:31 -0400 Subject: [PATCH 130/209] Better results printing --- PySimpleGUI.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 2933ef0d9..4a898e839 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1156,7 +1156,17 @@ def __getitem__(self, item): return super().__getitem__(item) def __str__(self): - return str(self.ToList()) + listlike = True + for i, key in enumerate(self.keys()): + if i != key: + listlike = False + + if listlike: + return str(list(self.values())) + else: + output = [("'" + k + "'" if isinstance(k, str) else str(k)) + ': ' + ( + "'" + v + "'" if isinstance(v, str) else str(v)) for k, v in self.items()] + return '{' + ', '.join(output) + '}' def ToList(self): output = [] From 14ca11a795d132c223c50baf2328344ec2277544 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 11 Aug 2018 05:33:14 -0400 Subject: [PATCH 131/209] Autosize text now defaults to True! --- PySimpleGUI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 4a898e839..eb51663fa 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -14,7 +14,7 @@ DEFAULT_ELEMENT_SIZE = (45,1) # In CHARACTERS DEFAULT_MARGINS = (10,5) # Margins for each LEFT/RIGHT margin is first term DEFAULT_ELEMENT_PADDING = (5,3) # Padding between elements (row, col) in pixels -DEFAULT_AUTOSIZE_TEXT = False +DEFAULT_AUTOSIZE_TEXT = True DEFAULT_AUTOSIZE_BUTTONS = True DEFAULT_FONT = ("Helvetica", 10) DEFAULT_TEXT_JUSTIFICATION = 'left' From a4e345741507bb13fbeb83ac259450836c543cc5 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 11 Aug 2018 08:15:18 -0400 Subject: [PATCH 132/209] Updated Readme file --- docs/index.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index 785197977..0d55aa851 100644 --- a/docs/index.md +++ b/docs/index.md @@ -9,8 +9,11 @@ # PySimpleGUI (Ver 2.8) + [Formatted ReadTheDocs Version of this Readme](http://pysimplegui.readthedocs.io/) +[COOKBOOK documentation now online!](https://pysimplegui.readthedocs.io/en/latest/cookbook/) + Super-simple GUI to grasp... Powerfully customizable. Note - ***Python3*** is required to run PySimpleGUI. It takes advantage of some Python3 features that do not translate well into Python2. @@ -138,6 +141,7 @@ You will see a number of different styles of buttons, data entry fields, etc, in - A form is a list of rows - A row is a list of elements - Return values are a list of button presses and input values. +- Return values can also be represented as a dictionary It's stunning that after so many years Python still hasn't put forth a GUI framework that truly fits the language's basic data structures, especially lists. It's hard to argue with the success to be had in quickly building GUI applications using this package's syntax. @@ -409,7 +413,7 @@ You will use these design patterns or code templates for all of your "normal" (b ### How GUI Programming in Python Should Look -GUI programming in Python is a mess. tkinter kinda sucks. Why is Python such a great teaching language and yet no GUI framework exists that lends itself to the basic building blocks of Python, the list? +GUI programming in Python is a mess. tkinter kinda sucks. Why is Python such a great teaching language and yet no GUI framework exists that lends itself to the basic building blocks of Python, the list or dictionary? The key to custom forms in PySimpleGUI is to view forms as ROWS of Widgets (Elements). Each row is specified as a list of these widgets. Put the rows together and you've got a form. @@ -1465,6 +1469,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ | 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting | 2.8.0 | Aug 9, 2018 - New None default option for Checkbox element, text color option for all elements, return values as a dictionary, setting focus, binding return key +| 2.9.0 | Aug XX,2018 - Screen flash fix, do_not_clear input field option, ### Release Notes @@ -1545,7 +1550,7 @@ Here are the steps to run that application The pip command is all there is to the setup. -The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. +The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. ![snap0109](https://user-images.githubusercontent.com/13696193/42916444-4199b16c-8ad3-11e8-8423-d12e61a58d3d.jpg) From 86f2f601205b997ce2ef657f63b889754e53c604 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 11 Aug 2018 19:29:38 -0400 Subject: [PATCH 133/209] Fix for missing slider results, ChangeLookAndFeel feature --- PySimpleGUI.py | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index eb51663fa..094ef19b2 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1266,9 +1266,11 @@ def BuildResults(form): value = 0 results[row_num][col_num] = value input_values.append(value) - try: + if element.Key is None: + input_values_dictionary[key_counter] = value + key_counter +=1 + else: input_values_dictionary[element.Key] = value - except: pass elif element.Type == ELEM_TYPE_INPUT_MULTILINE: try: value=element.TKText.get(1.0, tk.END) @@ -2451,6 +2453,40 @@ def SetOptions(icon=None, button_color=None, element_size=(None,None), margins=( return True +#################### ChangeLookAndFeel ####################### +# Predefined settings that will change the colors and styles # +# of the elements. # +############################################################## +def ChangeLookAndFeel(index): + # look and feel table + look_and_feel = {'GreenTan': {'BACKGROUND' : '#9FB8AD', 'TEXT': COLOR_SYSTEM_DEFAULT, 'INPUT':'#F7F3EC', 'BUTTON': ('white', '#475841'), + 'PROGRESS':DEFAULT_PROGRESS_BAR_COLOR}, + + 'LightGreen' :{'BACKGROUND' : '#B7CECE', 'TEXT': 'black', 'INPUT':'#FDFFF7', 'BUTTON': ('white', '#658268'), 'PROGRESS':('#247BA0','#F8FAF0')}, + + 'BluePurple': {'BACKGROUND' : '#A5CADD', 'TEXT': '#6E266E', 'INPUT':'#E0F5FF', 'BUTTON': ('white', '#303952'),'PROGRESS':DEFAULT_PROGRESS_BAR_COLOR}} + + + try: + colors = look_and_feel[index] + + SetOptions(background_color=colors['BACKGROUND'], + text_element_background_color=colors['BACKGROUND'], + element_background_color=colors['BACKGROUND'], + text_color=colors['TEXT'], + input_elements_background_color=colors['INPUT'], + button_color=colors['BUTTON'], + progress_meter_color=colors['PROGRESS'], + border_width=0, + slider_border_width=0, + progress_meter_border_depth=0, + scrollbar_color=(colors['INPUT']), + element_text_color=colors['TEXT']) + except: # most likely an index out of range + pass + + + # ============================== sprint ======# # Is identical to the Scrolled Text Box # # Provides a crude 'print' mechanism but in a # @@ -2472,12 +2508,12 @@ def ObjToString(obj, extra=' '): def main(): - with FlexForm('Demo form..', auto_size_text=True) as form: + with FlexForm('Demo form..') as form: form_rows = [[Text('You are running the PySimpleGUI.py file itself')], [Text('You should be importing it rather than running it\n')], [Text('Here is your sample input form....')], - [Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), InputText('Source', focus=True),FolderBrowse()], - [Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), InputText('Dest'), FolderBrowse()], + [Text('Source Folder', size=(15, 1), justification='right'), InputText('Source', focus=True),FolderBrowse()], + [Text('Destination Folder', size=(15, 1), justification='right'), InputText('Dest'), FolderBrowse()], [Submit(bind_return_key=True), Cancel()]] button, (source, dest) = form.LayoutAndRead(form_rows) From 1e9a052f27ed71f66eca2a4bf1589e0096b08fbc Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 11 Aug 2018 19:36:07 -0400 Subject: [PATCH 134/209] Commented and fixed progress bar --- Demo_Machine_Learning.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Demo_Machine_Learning.py b/Demo_Machine_Learning.py index 6de6283f9..3d2eeb0b5 100644 --- a/Demo_Machine_Learning.py +++ b/Demo_Machine_Learning.py @@ -30,20 +30,27 @@ def MachineLearningGUI(): def CustomMeter(): - + # create the progress bar element progress_bar = sg.ProgressBar(10000, orientation='h', size=(20,20)) - + # layout the form layout = [[sg.Text('A custom progress meter')], [progress_bar], [sg.Cancel()]] + # create the form form = sg.FlexForm('Custom Progress Meter') + # display the form as a non-blocking form form.LayoutAndRead(layout, non_blocking=True) - + # loop that would normally do something useful for i in range(10000): + # check to see if the cancel button was clicked and exit loop if clicked button, values = form.ReadNonBlocking() - progress_bar.UpdateBar(i) - + if button == 'Cancel' or values == None: + break + # update bar with loop value +1 so that bar eventually reaches the maximum + progress_bar.UpdateBar(i+1) + # done with loop... need to destroy the window as it's still open + form.CloseNonBlockingForm() if __name__ == '__main__': CustomMeter() From b104c97a1ee3572141588b8d9f14bff9c6fd0e07 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 11 Aug 2018 19:48:49 -0400 Subject: [PATCH 135/209] Readme updates --- readme.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index 0d55aa851..32008eb50 100644 --- a/readme.md +++ b/readme.md @@ -116,13 +116,14 @@ Here is the code that produced the above screenshot. sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], [sg.Text('_' * 100, size=(70, 1))], [sg.Text('Choose Source and Destination Folders', size=(35, 1))], - [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], + [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), + sg.FolderBrowse()], [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), sg.FolderBrowse()], [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] - ] + ] - button, values = form.LayoutAndRead(layout) + button, values = form.LayoutAndRead(layout) **A note on screen shots** You will see a number of different styles of buttons, data entry fields, etc, in this readme. They were all made with the same SDK, the only difference is in the settings that are specified on a per-element, row, form, or global basis. One setting in particular, border_width, can make a big difference on the look of the form. Some of the screenshots had a border_width of 6, others a value of 1. @@ -1469,7 +1470,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ | 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting | 2.8.0 | Aug 9, 2018 - New None default option for Checkbox element, text color option for all elements, return values as a dictionary, setting focus, binding return key -| 2.9.0 | Aug XX,2018 - Screen flash fix, do_not_clear input field option, +| 2.9.0 | Aug XX,2018 - Screen flash fix, `do_not_clear` input field option, `autosize_text` defaults to `True` now, return values as ordered dict, ### Release Notes @@ -1533,6 +1534,7 @@ GNU Lesser General Public License (LGPL 3) + * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence * [Fredrik Lundh](https://wiki.python.org/moin/FredrikLundh) for his work on `tkinter` +* [Ruud van der Ham](https://forum.pythonistacafe.com/u/Ruud) for all the help he's provided as a Python-mentor. Quite a few tricky bits of logic was supplied by Ruud. The dual-purpose return values scheme is Ruud's for example ## How Do I From 36b12763a6b349255b8e5a2fc99b3266d29f00b6 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 11 Aug 2018 22:31:42 -0400 Subject: [PATCH 136/209] ROLLING BACK to Aug 10 before ListDict --- PySimpleGUI.py | 93 +++++++------------------------------------------- 1 file changed, 13 insertions(+), 80 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 094ef19b2..e4cacc309 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1,10 +1,10 @@ + #!/usr/bin/env Python3 import tkinter as tk from tkinter import filedialog from tkinter import ttk import tkinter.scrolledtext as tkst import tkinter.font -from collections import OrderedDict import datetime import sys import textwrap @@ -14,7 +14,7 @@ DEFAULT_ELEMENT_SIZE = (45,1) # In CHARACTERS DEFAULT_MARGINS = (10,5) # Margins for each LEFT/RIGHT margin is first term DEFAULT_ELEMENT_PADDING = (5,3) # Padding between elements (row, col) in pixels -DEFAULT_AUTOSIZE_TEXT = True +DEFAULT_AUTOSIZE_TEXT = False DEFAULT_AUTOSIZE_BUTTONS = True DEFAULT_FONT = ("Helvetica", 10) DEFAULT_TEXT_JUSTIFICATION = 'left' @@ -1143,37 +1143,6 @@ def EncodeRadioRowCol(row, col): RadValue = row * 1000 + col return RadValue -#===== ListDict - New data type for returning values ===== -class ListDict(OrderedDict): - def __iter__(self): - for v in self.values(): - yield v - - def __getitem__(self, item): - if isinstance(item, slice): - return list(self.values())[item] - else: - return super().__getitem__(item) - - def __str__(self): - listlike = True - for i, key in enumerate(self.keys()): - if i != key: - listlike = False - - if listlike: - return str(list(self.values())) - else: - output = [("'" + k + "'" if isinstance(k, str) else str(k)) + ': ' + ( - "'" + v + "'" if isinstance(v, str) else str(v)) for k, v in self.items()] - return '{' + ', '.join(output) + '}' - - def ToList(self): - output = [] - for item in self.values(): - output.append(item) - return output - # ------- FUNCTION BuildResults. Form exiting so build the results to pass back ------- # # format of return values is # (Button Pressed, input_values) @@ -1187,8 +1156,7 @@ def BuildResults(form): results=form.Results button_pressed_text = None input_values = [] - # input_values_dictionary = {} - input_values_dictionary = ListDict() + input_values_dictionary = {} key_counter = 0 for row_num,row in enumerate(form.Rows): for col_num, element in enumerate(row): @@ -1266,11 +1234,9 @@ def BuildResults(form): value = 0 results[row_num][col_num] = value input_values.append(value) - if element.Key is None: - input_values_dictionary[key_counter] = value - key_counter +=1 - else: + try: input_values_dictionary[element.Key] = value + except: pass elif element.Type == ELEM_TYPE_INPUT_MULTILINE: try: value=element.TKText.get(1.0, tk.END) @@ -1290,9 +1256,10 @@ def BuildResults(form): input_values_dictionary.pop(None, None) # clean up dictionary include None was included except: pass - # return values are always a list dictionary now (ordered dict with added features) - form.ReturnValues = button_pressed_text, input_values_dictionary - + if not form.UseDictionary: + form.ReturnValues = button_pressed_text, input_values + else: + form.ReturnValues = button_pressed_text, input_values_dictionary form.ReturnValuesDictionary = button_pressed_text, input_values_dictionary form.ResultsBuilt = True return form.ReturnValues @@ -2453,40 +2420,6 @@ def SetOptions(icon=None, button_color=None, element_size=(None,None), margins=( return True -#################### ChangeLookAndFeel ####################### -# Predefined settings that will change the colors and styles # -# of the elements. # -############################################################## -def ChangeLookAndFeel(index): - # look and feel table - look_and_feel = {'GreenTan': {'BACKGROUND' : '#9FB8AD', 'TEXT': COLOR_SYSTEM_DEFAULT, 'INPUT':'#F7F3EC', 'BUTTON': ('white', '#475841'), - 'PROGRESS':DEFAULT_PROGRESS_BAR_COLOR}, - - 'LightGreen' :{'BACKGROUND' : '#B7CECE', 'TEXT': 'black', 'INPUT':'#FDFFF7', 'BUTTON': ('white', '#658268'), 'PROGRESS':('#247BA0','#F8FAF0')}, - - 'BluePurple': {'BACKGROUND' : '#A5CADD', 'TEXT': '#6E266E', 'INPUT':'#E0F5FF', 'BUTTON': ('white', '#303952'),'PROGRESS':DEFAULT_PROGRESS_BAR_COLOR}} - - - try: - colors = look_and_feel[index] - - SetOptions(background_color=colors['BACKGROUND'], - text_element_background_color=colors['BACKGROUND'], - element_background_color=colors['BACKGROUND'], - text_color=colors['TEXT'], - input_elements_background_color=colors['INPUT'], - button_color=colors['BUTTON'], - progress_meter_color=colors['PROGRESS'], - border_width=0, - slider_border_width=0, - progress_meter_border_depth=0, - scrollbar_color=(colors['INPUT']), - element_text_color=colors['TEXT']) - except: # most likely an index out of range - pass - - - # ============================== sprint ======# # Is identical to the Scrolled Text Box # # Provides a crude 'print' mechanism but in a # @@ -2508,16 +2441,16 @@ def ObjToString(obj, extra=' '): def main(): - with FlexForm('Demo form..') as form: + with FlexForm('Demo form..', auto_size_text=True) as form: form_rows = [[Text('You are running the PySimpleGUI.py file itself')], [Text('You should be importing it rather than running it\n')], [Text('Here is your sample input form....')], - [Text('Source Folder', size=(15, 1), justification='right'), InputText('Source', focus=True),FolderBrowse()], - [Text('Destination Folder', size=(15, 1), justification='right'), InputText('Dest'), FolderBrowse()], + [Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), InputText('Source', focus=True),FolderBrowse()], + [Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), InputText('Dest'), FolderBrowse()], [Submit(bind_return_key=True), Cancel()]] button, (source, dest) = form.LayoutAndRead(form_rows) if __name__ == '__main__': main() - exit(69) + exit(69) \ No newline at end of file From 148a1049baea736f26b4ce527b0ea6f7c5538441 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 11 Aug 2018 22:43:09 -0400 Subject: [PATCH 137/209] Fix for sliders (again) --- PySimpleGUI.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index e4cacc309..948c557f2 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1234,9 +1234,11 @@ def BuildResults(form): value = 0 results[row_num][col_num] = value input_values.append(value) - try: + if element.Key is None: + input_values_dictionary[key_counter] = value + key_counter +=1 + else: input_values_dictionary[element.Key] = value - except: pass elif element.Type == ELEM_TYPE_INPUT_MULTILINE: try: value=element.TKText.get(1.0, tk.END) From 72e9c2246ee9bbe0aa1172a090c901a60e8dea86 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sun, 12 Aug 2018 17:43:19 -0400 Subject: [PATCH 138/209] Custom Progress Bar --- docs/cookbook.md | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/docs/cookbook.md b/docs/cookbook.md index 8052b7d48..821d5065a 100644 --- a/docs/cookbook.md +++ b/docs/cookbook.md @@ -273,6 +273,7 @@ The architecture of some programs works better with button callbacks instead of ## Realtime Buttons (Good For Raspberry Pi) This recipe implements a remote control interface for a robot. There are 4 directions, forward, reverse, left, right. When a button is clicked, PySimpleGUI immediately returns button events for as long as the buttons is held down. When released, the button events stop. This is an async/non-blocking form. +![robot control](https://user-images.githubusercontent.com/13696193/44006710-d227f23e-9e56-11e8-89a3-2be5b2726199.jpg) import PySimpleGUI as sg @@ -310,12 +311,14 @@ This recipe implements a remote control interface for a robot. There are 4 dire ## Easy Progress Meter This recipe shows just how easy it is to add a progress meter to your code. +![progress meter 6](https://user-images.githubusercontent.com/13696193/43955982-73b33b38-9c70-11e8-8b07-cc1473a58a73.jpg) + import PySimpleGUI as sg for i in range(1000): sg.EasyProgressMeter('Easy Meter Example', i+1, 1000) -![progress meter 6](https://user-images.githubusercontent.com/13696193/43955982-73b33b38-9c70-11e8-8b07-cc1473a58a73.jpg) + ----- ## Tabbed Form Tabbed forms are **easy** to make and use in PySimpleGUI. You simple may your layouts for each tab and then instead of `LayoutAndRead` you call `ShowTabbedForm`. Results are returned as a list of form results. Each tab acts like a single form. @@ -497,3 +500,40 @@ A standard non-blocking GUI with lots of inputs. [sg.Submit(), sg.Cancel()]] button, values = form.LayoutAndRead(layout) + +------- +## Custom Progress Meter / Progress Bar +Perhaps you don't want all the statistics that the EasyProgressMeter provides and want to create your own progress bar. Use this recipe to do just that. + +![custom progress meter](https://user-images.githubusercontent.com/13696193/43982958-3393b23e-9cc6-11e8-8b49-e7f4890cbc4b.jpg) + + + import PySimpleGUI as sg + + def CustomMeter(): + # create the progress bar element + progress_bar = sg.ProgressBar(10000, orientation='h', size=(20,20)) + # layout the form + layout = [[sg.Text('A custom progress meter')], + [progress_bar], + [sg.Cancel()]] + + # create the form + form = sg.FlexForm('Custom Progress Meter') + # display the form as a non-blocking form + form.LayoutAndRead(layout, non_blocking=True) + # loop that would normally do something useful + for i in range(10000): + # check to see if the cancel button was clicked and exit loop if clicked + button, values = form.ReadNonBlocking() + if button == 'Cancel' or values == None: + break + # update bar with loop value +1 so that bar eventually reaches the maximum + progress_bar.UpdateBar(i+1) + # done with loop... need to destroy the window as it's still open + form.CloseNonBlockingForm() + + ---- + + + From d0ab0c42c5f47ac56cac2213f29d029c28557213 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sun, 12 Aug 2018 17:45:12 -0400 Subject: [PATCH 139/209] Autosize text now TRUE by default, Remove progress bar target, cleanup how return values made, ChangeLookAndFeel func --- PySimpleGUI.py | 311 +++++++++++++++++++++---------------------------- 1 file changed, 132 insertions(+), 179 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 948c557f2..7e277293c 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -14,7 +14,7 @@ DEFAULT_ELEMENT_SIZE = (45,1) # In CHARACTERS DEFAULT_MARGINS = (10,5) # Margins for each LEFT/RIGHT margin is first term DEFAULT_ELEMENT_PADDING = (5,3) # Padding between elements (row, col) in pixels -DEFAULT_AUTOSIZE_TEXT = False +DEFAULT_AUTOSIZE_TEXT = True DEFAULT_AUTOSIZE_BUTTONS = True DEFAULT_FONT = ("Helvetica", 10) DEFAULT_TEXT_JUSTIFICATION = 'left' @@ -603,11 +603,11 @@ def __init__(self, button_type=BUTTON_TYPE_CLOSES_WIN, target=(None, None), butt def ButtonReleaseCallBack(self, parm): r, c = self.Position - self.ParentForm.Results[r][c] = False # mark this button's location in results + self.ParentForm.LastButtonClicked = None def ButtonPressCallBack(self, parm): r, c = self.Position - self.ParentForm.Results[r][c] = True # mark this button's location in results + self.ParentForm.LastButtonClicked = self.ButtonText # ------- Button Callback ------- # def ButtonCallBack(self): @@ -642,7 +642,7 @@ def ButtonCallBack(self): # first, get the results table built # modify the Results table in the parent FlexForm object r,c = self.Position - self.ParentForm.Results[r][c] = True # mark this button's location in results + self.ParentForm.LastButtonClicked = self.ButtonText # if the form is tabbed, must collect all form's results and destroy all forms if self.ParentForm.IsTabbedForm: self.ParentForm.UberParent._Close() @@ -656,7 +656,7 @@ def ButtonCallBack(self): # first, get the results table built # modify the Results table in the parent FlexForm object r,c = self.Position - self.ParentForm.Results[r][c] = True # mark this button's location in results + self.ParentForm.LastButtonClicked = self.ButtonText self.ParentForm.TKroot.quit() # kick the users out of the mainloop return @@ -671,12 +671,11 @@ def __del__(self): # ProgreessBar # # ---------------------------------------------------------------------- # class ProgressBar(Element): - def __init__(self, max_value, orientation=None, target=(None, None), scale=(None, None), size=(None, None), auto_size_text=None, bar_color=(None, None), style=None, border_width=None, relief=None): + def __init__(self, max_value, orientation=None, scale=(None, None), size=(None, None), auto_size_text=None, bar_color=(None, None), style=None, border_width=None, relief=None): ''' Progress Bar Element :param max_value: :param orientation: - :param target: :param scale: Adds multiplier to size (w,h) :param size: Size of field in characters :param auto_size_text: True if should shrink field to fit the default text @@ -692,7 +691,6 @@ def __init__(self, max_value, orientation=None, target=(None, None), scale=(None self.Orientation = orientation if orientation else DEFAULT_METER_ORIENTATION self.BarColor = bar_color self.BarStyle = style if style else DEFAULT_PROGRESS_BAR_STYLE - self.Target = target self.BorderWidth = border_width if border_width else DEFAULT_PROGRESS_BAR_BORDER_WIDTH self.Relief = relief if relief else DEFAULT_PROGRESS_BAR_RELIEF self.BarExpired = False @@ -702,12 +700,6 @@ def __init__(self, max_value, orientation=None, target=(None, None), scale=(None def UpdateBar(self, current_count): if self.ParentForm.TKrootDestroyed: return False - target = self.Target - if target[0] != None: # if there's a target, get it and update the strvar - target_element = self.ParentForm.GetElementAtLocation(target) - strvar = target_element.TKStringVar - rc = strvar.set(self.TextToDisplay) - self.TKProgressBar.Update(current_count) try: self.ParentForm.TKroot.update() @@ -806,8 +798,10 @@ def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT self.RootNeedsDestroying = False self.Shown = False self.ReturnValues = None - self.ReturnValuesDictionary = None - self.ResultsBuilt = False + self.ReturnValuesList = [] + self.ReturnValuesDictionary = {} + self.DictionaryKeyCounter = 0 + self.LastButtonClicked = None self.UseDictionary = False self.UseDefaultFocus = False @@ -911,7 +905,7 @@ def Read(self): if self.RootNeedsDestroying: self.TKroot.destroy() _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 - return BuildResults(self) + return BuildResults(self, False) def ReadNonBlocking(self, Message=''): if self.TKrootDestroyed: @@ -925,7 +919,7 @@ def ReadNonBlocking(self, Message=''): except: self.TKrootDestroyed = True _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 - return BuildResults(self) + return BuildResults(self, False) # LEGACY version of ReadNonBlocking def Refresh(self, Message=''): @@ -938,14 +932,14 @@ def Refresh(self, Message=''): except: self.TKrootDestroyed = True _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 - return BuildResults(self) + return BuildResults(self, False) def _Close(self): try: self.TKroot.update() except: pass if not self.NonBlocking: - results = BuildResults(self) + results = BuildResults(self, False) if self.TKrootDestroyed: return None self.TKrootDestroyed = True @@ -1083,53 +1077,23 @@ def ReadFormButton(button_text, image_filename=None, image_size=(None, None),ima def RealtimeButton(button_text, image_filename=None, image_size=(None, None),image_subsample=None,border_width=None,scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False): return Button(BUTTON_TYPE_REALTIME, image_filename=image_filename, image_size=image_size, image_subsample=image_subsample, border_width=border_width, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus) -#------------------------------------------------------------------------------------------------------# -# ------- FUNCTION InitializeResults. Sets up form results matrix ------- # +##################################### ----- RESULTS ------ ################################################## + +def AddToReturnDictionary(form, element, value): + if element.Key is None: + form.ReturnValuesDictionary[form.DictionaryKeyCounter] = value + form.DictionaryKeyCounter += 1 + else: + form.ReturnValuesDictionary[element.Key] = value + +def AddToReturnList(form, value): + form.ReturnValuesList.append(value) + + +#----------------------------------------------------------------------------# +# ------- FUNCTION InitializeResults. Sets up form results matrix --------# def InitializeResults(form): - # initial results for elements are: - # TEXT - None - # INPUT - Initial value - # Button - False - results = [] - return_vals = [] - for row_num,row in enumerate(form.Rows): - r = [] - for element in row: - if element.Type == ELEM_TYPE_TEXT: - r.append(None) - if element.Type == ELEM_TYPE_IMAGE: - r.append(None) - elif element.Type == ELEM_TYPE_INPUT_TEXT: - r.append(element.TextInputDefault) - return_vals.append(None) - elif element.Type == ELEM_TYPE_INPUT_MULTILINE: - r.append(element.TextInputDefault) - return_vals.append(None) - elif element.Type == ELEM_TYPE_BUTTON: - r.append(False) - elif element.Type == ELEM_TYPE_PROGRESS_BAR: - r.append(None) - elif element.Type == ELEM_TYPE_INPUT_CHECKBOX: - r.append(element.InitialState) - return_vals.append(element.InitialState) - elif element.Type == ELEM_TYPE_INPUT_RADIO: - r.append(element.InitialState) - return_vals.append(element.InitialState) - elif element.Type == ELEM_TYPE_INPUT_COMBO: - r.append(element.TextInputDefault) - return_vals.append(None) - elif element.Type == ELEM_TYPE_INPUT_LISTBOX: - r.append(None) - return_vals.append(None) - elif element.Type == ELEM_TYPE_INPUT_SPIN: - r.append(element.DefaultValue) - return_vals.append(None) - elif element.Type == ELEM_TYPE_INPUT_SLIDER: - r.append(element.DefaultValue) - return_vals.append(None) - results.append(r) - form.Results=results - form.ReturnValues = (None, return_vals) + BuildResults(form, True) return #===== Radio Button RadVar encoding and decoding =====# @@ -1146,124 +1110,76 @@ def EncodeRadioRowCol(row, col): # ------- FUNCTION BuildResults. Form exiting so build the results to pass back ------- # # format of return values is # (Button Pressed, input_values) -def BuildResults(form): +def BuildResults(form, initialize_only): # Results for elements are: # TEXT - Nothing # INPUT - Read value from TK # Button - Button Text and position as a Tuple # Get the initialized results so we don't have to rebuild - results=form.Results button_pressed_text = None input_values = [] - input_values_dictionary = {} + form.DictionaryKeyCounter = 0 + form.ReturnValuesDictionary = {} + form.ReturnValuesList = [] key_counter = 0 for row_num,row in enumerate(form.Rows): for col_num, element in enumerate(row): - if element.Type == ELEM_TYPE_INPUT_TEXT: - value=element.TKStringVar.get() - results[row_num][col_num] = value - input_values.append(value) - if not form.NonBlocking and not element.do_not_clear: - element.TKStringVar.set('') - if element.Key is None: - input_values_dictionary[key_counter] = value - key_counter +=1 - else: - input_values_dictionary[element.Key] = value - elif element.Type == ELEM_TYPE_INPUT_CHECKBOX: - value=element.TKIntVar.get() - results[row_num][col_num] = value - input_values.append(value != 0) - if element.Key is None: - input_values_dictionary[key_counter] = value - key_counter +=1 - else: - input_values_dictionary[element.Key] = value - elif element.Type == ELEM_TYPE_INPUT_RADIO: - RadVar=element.TKIntVar.get() - this_rowcol = EncodeRadioRowCol(row_num,col_num) - value = RadVar == this_rowcol - results[row_num][col_num] = value - input_values.append(value) - if element.Key is None: - input_values_dictionary[key_counter] = value - key_counter +=1 - else: - input_values_dictionary[element.Key] = value - elif element.Type == ELEM_TYPE_BUTTON: - if results[row_num][col_num] is True: - button_pressed_text = element.ButtonText - if element.BType != BUTTON_TYPE_REALTIME: # Do not clear realtime buttons - results[row_num][col_num] = False - elif element.Type == ELEM_TYPE_INPUT_COMBO: - value=element.TKStringVar.get() - results[row_num][col_num] = value - input_values.append(value) - if element.Key is None: - input_values_dictionary[key_counter] = value - key_counter +=1 - else: - input_values_dictionary[element.Key] = value - elif element.Type == ELEM_TYPE_INPUT_LISTBOX: - items=element.TKListbox.curselection() - value = [element.Values[int(item)] for item in items] - results[row_num][col_num] = value - input_values.append(value) - if element.Key is None: - input_values_dictionary[key_counter] = value - key_counter +=1 - else: - input_values_dictionary[element.Key] = value - elif element.Type == ELEM_TYPE_INPUT_SPIN: - try: + if not initialize_only: + if element.Type == ELEM_TYPE_INPUT_TEXT: value=element.TKStringVar.get() - except: - value = 0 - results[row_num][col_num] = value - input_values.append(value) - if element.Key is None: - input_values_dictionary[key_counter] = value - key_counter +=1 - else: - input_values_dictionary[element.Key] = value - elif element.Type == ELEM_TYPE_INPUT_SLIDER: - try: - value=element.TKIntVar.get() - except: - value = 0 - results[row_num][col_num] = value - input_values.append(value) - if element.Key is None: - input_values_dictionary[key_counter] = value - key_counter +=1 - else: - input_values_dictionary[element.Key] = value - elif element.Type == ELEM_TYPE_INPUT_MULTILINE: - try: - value=element.TKText.get(1.0, tk.END) if not form.NonBlocking and not element.do_not_clear: - element.TKText.delete('1.0', tk.END) - except: - value = None - results[row_num][col_num] = value - input_values.append(value) - if element.Key is None: - input_values_dictionary[key_counter] = value - key_counter +=1 - else: - input_values_dictionary[element.Key] = value + element.TKStringVar.set('') + elif element.Type == ELEM_TYPE_INPUT_CHECKBOX: + value=element.TKIntVar.get() + elif element.Type == ELEM_TYPE_INPUT_RADIO: + RadVar=element.TKIntVar.get() + this_rowcol = EncodeRadioRowCol(row_num,col_num) + value = RadVar == this_rowcol + elif element.Type == ELEM_TYPE_BUTTON: + if form.LastButtonClicked == element.ButtonText: + button_pressed_text = form.LastButtonClicked + if element.BType != BUTTON_TYPE_REALTIME: # Do not clear realtime buttons + form.LastButtonClicked = None + elif element.Type == ELEM_TYPE_INPUT_COMBO: + value=element.TKStringVar.get() + elif element.Type == ELEM_TYPE_INPUT_LISTBOX: + items=element.TKListbox.curselection() + value = [element.Values[int(item)] for item in items] + elif element.Type == ELEM_TYPE_INPUT_SPIN: + try: + value=element.TKStringVar.get() + except: + value = 0 + elif element.Type == ELEM_TYPE_INPUT_SLIDER: + try: + value=element.TKIntVar.get() + except: + value = 0 + elif element.Type == ELEM_TYPE_INPUT_MULTILINE: + try: + value=element.TKText.get(1.0, tk.END) + if not form.NonBlocking and not element.do_not_clear: + element.TKText.delete('1.0', tk.END) + except: + value = None + else: + value = None + # if an input type element, update the results + if element.Type != ELEM_TYPE_BUTTON and element.Type != ELEM_TYPE_TEXT and element.Type != ELEM_TYPE_IMAGE and\ + element.Type != ELEM_TYPE_OUTPUT and element.Type != ELEM_TYPE_PROGRESS_BAR: + AddToReturnList(form, value) + AddToReturnDictionary(form, element, value) try: - input_values_dictionary.pop(None, None) # clean up dictionary include None was included + form.ReturnValuesDictionary.pop(None, None) # clean up dictionary include None was included except: pass if not form.UseDictionary: - form.ReturnValues = button_pressed_text, input_values + form.ReturnValues = button_pressed_text, form.ReturnValuesList else: - form.ReturnValues = button_pressed_text, input_values_dictionary - form.ReturnValuesDictionary = button_pressed_text, input_values_dictionary - form.ResultsBuilt = True + form.ReturnValues = button_pressed_text, form.ReturnValuesDictionary + return form.ReturnValues @@ -1916,7 +1832,7 @@ def ConvertArgsToSingleString(*args): # ============================== ProgressMeter =====# # ===================================================# -def ProgressMeter(title, max_value, *args, orientation=None, bar_color=(None,None), button_color=None, size=DEFAULT_PROGRESS_BAR_SIZE, scale=(None, None), border_width=None): +def _ProgressMeter(title, max_value, *args, orientation=None, bar_color=(None,None), button_color=None, size=DEFAULT_PROGRESS_BAR_SIZE, scale=(None, None), border_width=None): ''' Create and show a form on tbe caller's behalf. :param title: @@ -1932,8 +1848,7 @@ def ProgressMeter(title, max_value, *args, orientation=None, bar_color=(None,Non ''' local_orientation = DEFAULT_METER_ORIENTATION if orientation is None else orientation local_border_width = DEFAULT_PROGRESS_BAR_BORDER_WIDTH if border_width is None else border_width - target = (0,0) if local_orientation[0].lower() == 'h' else (0,1) - bar2 = ProgressBar(max_value, orientation=local_orientation, size=size, bar_color=bar_color, scale=scale, target=target, border_width=local_border_width, relief=DEFAULT_PROGRESS_BAR_RELIEF) + bar2 = ProgressBar(max_value, orientation=local_orientation, size=size, bar_color=bar_color, scale=scale, border_width=local_border_width, relief=DEFAULT_PROGRESS_BAR_RELIEF) form = FlexForm(title, auto_size_text=True) # Form using a horizontal bar @@ -1942,7 +1857,8 @@ def ProgressMeter(title, max_value, *args, orientation=None, bar_color=(None,Non bar2.TextToDisplay = single_line_message bar2.MaxValue = max_value bar2.CurrentValue = 0 - form.AddRow(Text(single_line_message, size=(width, height + 3), auto_size_text=True)) + bar_text = Text(single_line_message, size=(width, height + 3), auto_size_text=True) + form.AddRow(bar_text) form.AddRow((bar2)) form.AddRow((Cancel(button_color=button_color))) else: @@ -1950,15 +1866,16 @@ def ProgressMeter(title, max_value, *args, orientation=None, bar_color=(None,Non bar2.TextToDisplay = single_line_message bar2.MaxValue = max_value bar2.CurrentValue = 0 - form.AddRow(bar2, Text(single_line_message, size=(width, height + 3), auto_size_text=True)) + bar_text = Text(single_line_message, size=(width, height + 3), auto_size_text=True) + form.AddRow(bar2, bar_text) form.AddRow((Cancel(button_color=button_color))) form.NonBlocking = True form.Show(non_blocking= True) - return bar2 + return bar2, bar_text # ============================== ProgressMeterUpdate =====# -def ProgressMeterUpdate(bar, value, *args): +def _ProgressMeterUpdate(bar, value, text_elem, *args): ''' Update the progress meter for a form :param form: class ProgressBar @@ -1969,8 +1886,8 @@ def ProgressMeterUpdate(bar, value, *args): if bar == None: return False if bar.BarExpired: return False message, w, h = ConvertArgsToSingleString(*args) - - bar.TextToDisplay = message + text_elem.Update(message) + # bar.TextToDisplay = message bar.CurrentValue = value rc = bar.UpdateBar(value) if value >= bar.MaxValue or not rc: @@ -1998,6 +1915,7 @@ def __init__(self, title='', current_value=1, max_value=10, start_time=None, sta self.StatMessages = stat_messages self.ParentForm = None self.MeterID = None + self.MeterText = None # =========================== COMPUTE PROGRESS STATS ======================# def ComputeProgressStats(self): @@ -2059,7 +1977,7 @@ def EasyProgressMeter(title, current_value, max_value, *args, orientation=None, EasyProgressMeter.EasyProgressMeterData = EasyProgressMeterDataClass(title, 1, int(max_value), datetime.datetime.utcnow(), []) EasyProgressMeter.EasyProgressMeterData.ComputeProgressStats() message = "\n".join([line for line in EasyProgressMeter.EasyProgressMeterData.StatMessages]) - EasyProgressMeter.EasyProgressMeterData.MeterID = ProgressMeter(title, int(max_value), message, *args, orientation=orientation, bar_color=bar_color, size=size, scale=scale, button_color=button_color, border_width=local_border_width) + EasyProgressMeter.EasyProgressMeterData.MeterID, EasyProgressMeter.EasyProgressMeterData.MeterText= _ProgressMeter(title, int(max_value), message, *args, orientation=orientation, bar_color=bar_color, size=size, scale=scale, button_color=button_color, border_width=local_border_width) EasyProgressMeter.EasyProgressMeterData.ParentForm = EasyProgressMeter.EasyProgressMeterData.MeterID.ParentForm return True # if exactly the same values as before, then ignore. @@ -2079,7 +1997,8 @@ def EasyProgressMeter(title, current_value, max_value, *args, orientation=None, message = message + str(line) + '\n' message = "\n".join(EasyProgressMeter.EasyProgressMeterData.StatMessages) args= args + (message,) - rc = ProgressMeterUpdate(EasyProgressMeter.EasyProgressMeterData.MeterID, current_value, *args) + rc = _ProgressMeterUpdate(EasyProgressMeter.EasyProgressMeterData.MeterID, current_value, + EasyProgressMeter.EasyProgressMeterData.MeterText, *args) # if counter >= max then the progress meter is all done. Indicate none running if current_value >= EasyProgressMeter.EasyProgressMeterData.MaxValue or not rc: EasyProgressMeter.EasyProgressMeterData.MeterID = None @@ -2422,6 +2341,40 @@ def SetOptions(icon=None, button_color=None, element_size=(None,None), margins=( return True + +#################### ChangeLookAndFeel ####################### +# Predefined settings that will change the colors and styles # +# of the elements. # +############################################################## +def ChangeLookAndFeel(index): + # look and feel table + look_and_feel = {'GreenTan': {'BACKGROUND' : '#9FB8AD', 'TEXT': COLOR_SYSTEM_DEFAULT, 'INPUT':'#F7F3EC', 'BUTTON': ('white', '#475841'), + 'PROGRESS':DEFAULT_PROGRESS_BAR_COLOR}, + + 'LightGreen' :{'BACKGROUND' : '#B7CECE', 'TEXT': 'black', 'INPUT':'#FDFFF7', 'BUTTON': ('white', '#658268'), 'PROGRESS':('#247BA0','#F8FAF0')}, + + 'BluePurple': {'BACKGROUND' : '#A5CADD', 'TEXT': '#6E266E', 'INPUT':'#E0F5FF', 'BUTTON': ('white', '#303952'),'PROGRESS':DEFAULT_PROGRESS_BAR_COLOR}} + try: + colors = look_and_feel[index] + + SetOptions(background_color=colors['BACKGROUND'], + text_element_background_color=colors['BACKGROUND'], + element_background_color=colors['BACKGROUND'], + text_color=colors['TEXT'], + input_elements_background_color=colors['INPUT'], + button_color=colors['BUTTON'], + progress_meter_color=colors['PROGRESS'], + border_width=0, + slider_border_width=0, + progress_meter_border_depth=0, + scrollbar_color=(colors['INPUT']), + element_text_color=colors['TEXT']) + except: # most likely an index out of range + pass + + + + # ============================== sprint ======# # Is identical to the Scrolled Text Box # # Provides a crude 'print' mechanism but in a # @@ -2443,12 +2396,12 @@ def ObjToString(obj, extra=' '): def main(): - with FlexForm('Demo form..', auto_size_text=True) as form: + with FlexForm('Demo form..') as form: form_rows = [[Text('You are running the PySimpleGUI.py file itself')], [Text('You should be importing it rather than running it\n')], [Text('Here is your sample input form....')], - [Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), InputText('Source', focus=True),FolderBrowse()], - [Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), InputText('Dest'), FolderBrowse()], + [Text('Source Folder', size=(15, 1), justification='right'), InputText('Source', focus=True),FolderBrowse()], + [Text('Destination Folder', size=(15, 1), justification='right'), InputText('Dest'), FolderBrowse()], [Submit(bind_return_key=True), Cancel()]] button, (source, dest) = form.LayoutAndRead(form_rows) From b757caa18d34068fb93719eaa94934a591a8efc2 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 14 Aug 2018 16:49:36 -0400 Subject: [PATCH 140/209] Columns!! Columns feature, fix for opening multiple windows. --- PySimpleGUI.py | 515 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 476 insertions(+), 39 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 7e277293c..64753abbb 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -133,6 +133,7 @@ def RGB(red,green,blue): return '#%02x%02x%02x' % (red,green,blue) ELEM_TYPE_INPUT_SLIDER = 10 ELEM_TYPE_INPUT_LISTBOX = 11 ELEM_TYPE_OUTPUT = 300 +ELEM_TYPE_COLUMN = 555 ELEM_TYPE_PROGRESS_BAR = 200 ELEM_TYPE_BLANK = 100 @@ -643,6 +644,7 @@ def ButtonCallBack(self): # modify the Results table in the parent FlexForm object r,c = self.Position self.ParentForm.LastButtonClicked = self.ButtonText + self.ParentForm.FormRemainedOpen = False # if the form is tabbed, must collect all form's results and destroy all forms if self.ParentForm.IsTabbedForm: self.ParentForm.UberParent._Close() @@ -651,12 +653,13 @@ def ButtonCallBack(self): self.ParentForm.TKroot.quit() if self.ParentForm.NonBlocking: self.ParentForm.TKroot.destroy() - _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 + # _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 elif self.BType == BUTTON_TYPE_READ_FORM: # LEAVE THE WINDOW OPEN!! DO NOT CLOSE # first, get the results table built # modify the Results table in the parent FlexForm object r,c = self.Position self.ParentForm.LastButtonClicked = self.ButtonText + self.ParentForm.FormRemainedOpen = True self.ParentForm.TKroot.quit() # kick the users out of the mainloop return @@ -763,6 +766,54 @@ def __del__(self): super().__del__() +# ---------------------------------------------------------------------- # +# Column # +# ---------------------------------------------------------------------- # +class Column(Element): + def __init__(self, layout, background_color = None): + self.UseDictionary = False + self.ReturnValues = None + self.ReturnValuesList = [] + self.ReturnValuesDictionary = {} + self.DictionaryKeyCounter = 0 + self.ParentWindow = None + self.Rows = [] + self.ParentForm = None + self.TKFrame = None + + self.Layout(layout) + + super().__init__(ELEM_TYPE_COLUMN, background_color=background_color) + return + + def AddRow(self, *args): + ''' Parms are a variable number of Elements ''' + NumRows = len(self.Rows) # number of existing rows is our row number + CurrentRowNumber = NumRows # this row's number + CurrentRow = [] # start with a blank row and build up + # ------------------------- Add the elements to a row ------------------------- # + for i, element in enumerate(args): # Loop through list of elements and add them to the row + element.Position = (CurrentRowNumber, i) + CurrentRow.append(element) + if element.Key is not None: + self.UseDictionary = True + # ------------------------- Append the row to list of Rows ------------------------- # + self.Rows.append(CurrentRow) + + def Layout(self, rows): + for row in rows: + self.AddRow(*row) + + def __del__(self): + for row in self.Rows: + for element in row: + element.__del__() + try: + del(self.TKroot) + except: + pass + super().__del__() + # ------------------------------------------------------------------------- # # FlexForm CLASS # @@ -791,6 +842,7 @@ def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT self.NonBlocking = False self.TKroot = None self.TKrootDestroyed = False + self.FormRemainedOpen = False self.TKAfterID = None self.ProgressBarColor = progress_bar_color self.AutoCloseDuration = auto_close_duration @@ -905,7 +957,7 @@ def Read(self): if self.RootNeedsDestroying: self.TKroot.destroy() _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 - return BuildResults(self, False) + return BuildResults(self, False, self) def ReadNonBlocking(self, Message=''): if self.TKrootDestroyed: @@ -919,27 +971,15 @@ def ReadNonBlocking(self, Message=''): except: self.TKrootDestroyed = True _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 - return BuildResults(self, False) + return BuildResults(self, False, self) - # LEGACY version of ReadNonBlocking - def Refresh(self, Message=''): - if self.TKrootDestroyed: - return None, None - if Message: - print(Message) - try: - rc = self.TKroot.update() - except: - self.TKrootDestroyed = True - _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 - return BuildResults(self, False) def _Close(self): try: self.TKroot.update() except: pass if not self.NonBlocking: - results = BuildResults(self, False) + results = BuildResults(self, False, self) if self.TKrootDestroyed: return None self.TKrootDestroyed = True @@ -966,10 +1006,10 @@ def __del__(self): for row in self.Rows: for element in row: element.__del__() - try: - del(self.TKroot) - except: - pass + # try: + # del(self.TKroot) + # except: + # pass # ------------------------------------------------------------------------- # # UberForm CLASS # @@ -1093,7 +1133,7 @@ def AddToReturnList(form, value): #----------------------------------------------------------------------------# # ------- FUNCTION InitializeResults. Sets up form results matrix --------# def InitializeResults(form): - BuildResults(form, True) + BuildResults(form, True, form) return #===== Radio Button RadVar encoding and decoding =====# @@ -1110,42 +1150,64 @@ def EncodeRadioRowCol(row, col): # ------- FUNCTION BuildResults. Form exiting so build the results to pass back ------- # # format of return values is # (Button Pressed, input_values) -def BuildResults(form, initialize_only): +def BuildResults(form, initialize_only, top_level_form): # Results for elements are: # TEXT - Nothing # INPUT - Read value from TK # Button - Button Text and position as a Tuple # Get the initialized results so we don't have to rebuild - button_pressed_text = None - input_values = [] form.DictionaryKeyCounter = 0 form.ReturnValuesDictionary = {} form.ReturnValuesList = [] - key_counter = 0 + BuildResultsForSubform(form, initialize_only, top_level_form) + return form.ReturnValues + +def BuildResultsForSubform(form, initialize_only, top_level_form): + button_pressed_text = None for row_num,row in enumerate(form.Rows): for col_num, element in enumerate(row): + value = None + if element.Type == ELEM_TYPE_COLUMN: + element.DictionaryKeyCounter = top_level_form.DictionaryKeyCounter + element.ReturnValuesList = [] + element.ReturnValuesDictionary = {} + BuildResultsForSubform(element, initialize_only, top_level_form) + for item in element.ReturnValuesList: + AddToReturnList(top_level_form, item) + # for key in element.ReturnValuesDictionary: + # top_level_form.ReturnValuesDictionary[key] = element.ReturnValuesDictionary[key] + # top_level_form.DictionaryKeyCounter += element.DictionaryKeyCounter + if element.UseDictionary: + top_level_form.UseDictionary = True + if element.ReturnValues[0] is not None: # if a button was clicked + button_pressed_text = element.ReturnValues[0] + if not initialize_only: if element.Type == ELEM_TYPE_INPUT_TEXT: value=element.TKStringVar.get() - if not form.NonBlocking and not element.do_not_clear: + if not top_level_form.NonBlocking and not element.do_not_clear: element.TKStringVar.set('') elif element.Type == ELEM_TYPE_INPUT_CHECKBOX: - value=element.TKIntVar.get() + value = element.TKIntVar.get() + value = (value != 0) elif element.Type == ELEM_TYPE_INPUT_RADIO: RadVar=element.TKIntVar.get() this_rowcol = EncodeRadioRowCol(row_num,col_num) value = RadVar == this_rowcol elif element.Type == ELEM_TYPE_BUTTON: - if form.LastButtonClicked == element.ButtonText: - button_pressed_text = form.LastButtonClicked + if top_level_form.LastButtonClicked == element.ButtonText: + button_pressed_text = top_level_form.LastButtonClicked if element.BType != BUTTON_TYPE_REALTIME: # Do not clear realtime buttons - form.LastButtonClicked = None + top_level_form.LastButtonClicked = None elif element.Type == ELEM_TYPE_INPUT_COMBO: value=element.TKStringVar.get() elif element.Type == ELEM_TYPE_INPUT_LISTBOX: - items=element.TKListbox.curselection() - value = [element.Values[int(item)] for item in items] + try: + items=element.TKListbox.curselection() + value = [element.Values[int(item)] for item in items] + except: + value = '' elif element.Type == ELEM_TYPE_INPUT_SPIN: try: value=element.TKStringVar.get() @@ -1159,17 +1221,18 @@ def BuildResults(form, initialize_only): elif element.Type == ELEM_TYPE_INPUT_MULTILINE: try: value=element.TKText.get(1.0, tk.END) - if not form.NonBlocking and not element.do_not_clear: + if not top_level_form.NonBlocking and not element.do_not_clear: element.TKText.delete('1.0', tk.END) except: value = None else: value = None + # if an input type element, update the results if element.Type != ELEM_TYPE_BUTTON and element.Type != ELEM_TYPE_TEXT and element.Type != ELEM_TYPE_IMAGE and\ - element.Type != ELEM_TYPE_OUTPUT and element.Type != ELEM_TYPE_PROGRESS_BAR: + element.Type != ELEM_TYPE_OUTPUT and element.Type != ELEM_TYPE_PROGRESS_BAR and element.Type!= ELEM_TYPE_COLUMN: AddToReturnList(form, value) - AddToReturnDictionary(form, element, value) + AddToReturnDictionary(top_level_form, element, value) try: form.ReturnValuesDictionary.pop(None, None) # clean up dictionary include None was included @@ -1186,7 +1249,379 @@ def BuildResults(form, initialize_only): # ------------------------------------------------------------------------------------------------------------------ # # ===================================== TK CODE STARTS HERE ====================================================== # # ------------------------------------------------------------------------------------------------------------------ # + +def PackFormIntoFrame(form, containing_frame, toplevel_form): + def CharWidthInPixels(): + return tkinter.font.Font().measure('A') # single character width + # only set title on non-tabbed forms + border_depth = toplevel_form.BorderDepth if toplevel_form.BorderDepth is not None else DEFAULT_BORDER_WIDTH + # --------------------------------------------------------------------------- # + # **************** Use FlexForm to build the tkinter window ********** ----- # + # Building is done row by row. # + # --------------------------------------------------------------------------- # + focus_set = False + ######################### LOOP THROUGH ROWS ######################### + # *********** ------- Loop through ROWS ------- ***********# + for row_num, flex_row in enumerate(form.Rows): + ######################### LOOP THROUGH ELEMENTS ON ROW ######################### + # *********** ------- Loop through ELEMENTS ------- ***********# + # *********** Make TK Row ***********# + tk_row_frame = tk.Frame(containing_frame) + for col_num, element in enumerate(flex_row): + element.ParentForm = toplevel_form # save the button's parent form object + if toplevel_form.Font and (element.Font == DEFAULT_FONT or not element.Font): + font = toplevel_form.Font + elif element.Font is not None: + font = element.Font + else: + font = DEFAULT_FONT + # ------- Determine Auto-Size setting on a cascading basis ------- # + if element.AutoSizeText is not None: # if element overide + auto_size_text = element.AutoSizeText + elif toplevel_form.AutoSizeText is not None: # if form override + auto_size_text = toplevel_form.AutoSizeText + else: + auto_size_text = DEFAULT_AUTOSIZE_TEXT + # Determine Element size + element_size = element.Size + if (element_size == (None, None)): # user did not specify a size + element_size = toplevel_form.DefaultElementSize + else: auto_size_text = False # if user has specified a size then it shouldn't autosize + # Apply scaling... Element scaling is higher priority than form level + if element.Scale != (None, None): + element_size = (int(element_size[0] * element.Scale[0]), int(element_size[1] * element.Scale[1])) + elif toplevel_form.Scale != (None, None): + element_size = (int(element_size[0] * toplevel_form.Scale[0]), int(element_size[1] * toplevel_form.Scale[1])) + # Set foreground color + text_color = element.TextColor + element_type = element.Type + # ------------------------- COLUMN element ------------------------- # + if element_type == ELEM_TYPE_COLUMN: + col_frame = tk.Frame(tk_row_frame) + PackFormIntoFrame(element, col_frame, toplevel_form) + col_frame.pack(side=tk.LEFT) + if element.BackgroundColor is not None: + col_frame.configure(background=element.BackgroundColor, highlightbackground=element.BackgroundColor, highlightcolor=element.BackgroundColor) + # ------------------------- TEXT element ------------------------- # + elif element_type == ELEM_TYPE_TEXT: + display_text = element.DisplayText # text to display + if auto_size_text is False: + width, height=element_size + else: + lines = display_text.split('\n') + max_line_len = max([len(l) for l in lines]) + num_lines = len(lines) + if max_line_len > element_size[0]: # if text exceeds element size, the will have to wrap + width = element_size[0] + else: + width=max_line_len + height=num_lines + # ---===--- LABEL widget create and place --- # + stringvar = tk.StringVar() + element.TKStringVar = stringvar + stringvar.set(display_text) + if auto_size_text: + width = 0 + justify = tk.LEFT if element.Justification == 'left' else tk.CENTER if element.Justification == 'center' else tk.RIGHT + anchor = tk.NW if element.Justification == 'left' else tk.N if element.Justification == 'center' else tk.NE + tktext_label = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height, justify=justify, bd=border_depth) + # tktext_label = tk.Label(tk_row_frame,anchor=tk.NW, text=display_text, width=width, height=height, justify=tk.LEFT, bd=border_depth) + # Set wrap-length for text (in PIXELS) == PAIN IN THE ASS + wraplen = tktext_label.winfo_reqwidth() # width of widget in Pixels + tktext_label.configure(anchor=anchor, font=font, wraplen=wraplen*2 ) # set wrap to width of widget + if element.BackgroundColor is not None: + tktext_label.configure(background=element.BackgroundColor) + if element.TextColor != COLOR_SYSTEM_DEFAULT and element.TextColor is not None: + tktext_label.configure(fg=element.TextColor) + tktext_label.pack(side=tk.LEFT) + # ------------------------- BUTTON element ------------------------- # + elif element_type == ELEM_TYPE_BUTTON: + element.Location = (row_num, col_num) + btext = element.ButtonText + btype = element.BType + if element.AutoSizeButton is not None: + auto_size = element.AutoSizeButton + else: auto_size = toplevel_form.AutoSizeButtons + if auto_size is False: width=element_size[0] + else: width = 0 + height=element_size[1] + lines = btext.split('\n') + max_line_len = max([len(l) for l in lines]) + num_lines = len(lines) + if element.ButtonColor != (None, None)and element.ButtonColor != DEFAULT_BUTTON_COLOR: + bc = element.ButtonColor + elif toplevel_form.ButtonColor != (None, None) and toplevel_form.ButtonColor != DEFAULT_BUTTON_COLOR: + bc = toplevel_form.ButtonColor + else: + bc = DEFAULT_BUTTON_COLOR + border_depth = element.BorderWidth + if btype != BUTTON_TYPE_REALTIME: + tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height,command=element.ButtonCallBack, justify=tk.LEFT, bd=border_depth) + else: + tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height, justify=tk.LEFT, bd=border_depth) + tkbutton.bind('', element.ButtonReleaseCallBack) + tkbutton.bind('', element.ButtonPressCallBack) + if bc != (None, None) and bc != COLOR_SYSTEM_DEFAULT: + tkbutton.config(foreground=bc[0], background=bc[1]) + element.TKButton = tkbutton # not used yet but save the TK button in case + wraplen = tkbutton.winfo_reqwidth() # width of widget in Pixels + if element.ImageFilename: # if button has an image on it + print('Button Image Filename being placed', element.ImageFilename) + photo = tk.PhotoImage(file=element.ImageFilename) + print('PhotoImage object', ObjToString(photo)) + if element.ImageSize != (None, None): + width, height = element.ImageSize + if element.ImageSubsample: + photo = photo.subsample(element.ImageSubsample) + else: + width, height = photo.width(), photo.height() + tkbutton.config(image=photo, width=width, height=height) + tkbutton.image = photo + tkbutton.configure(wraplength=wraplen+10, font=font) # set wrap to width of widget + tkbutton.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) + if element.Focus is True or (toplevel_form.UseDefaultFocus and not focus_set): + focus_set = True + element.TKButton.bind('', element.ReturnKeyHandler) + element.TKButton.focus_set() + toplevel_form.TKroot.focus_force() + # ------------------------- INPUT (Single Line) element ------------------------- # + elif element_type == ELEM_TYPE_INPUT_TEXT: + default_text = element.DefaultText + element.TKStringVar = tk.StringVar() + element.TKStringVar.set(default_text) + show = element.PasswordCharacter if element.PasswordCharacter else "" + element.TKEntry = tk.Entry(tk_row_frame, width=element_size[0], textvariable=element.TKStringVar, bd=border_depth, font=font, show=show) + element.TKEntry.bind('', element.ReturnKeyHandler) + if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: + element.TKEntry.configure(background=element.BackgroundColor) + if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: + element.TKEntry.configure(fg=text_color) + element.TKEntry.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) + if element.Focus is True or (toplevel_form.UseDefaultFocus and not focus_set): + focus_set = True + element.TKEntry.focus_set() + # ------------------------- COMBO BOX (Drop Down) element ------------------------- # + elif element_type == ELEM_TYPE_INPUT_COMBO: + max_line_len = max([len(str(l)) for l in element.Values]) + if auto_size_text is False: width=element_size[0] + else: width = max_line_len + element.TKStringVar = tk.StringVar() + if element.BackgroundColor and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: + combostyle = ttk.Style() + try: + combostyle.theme_create('combostyle', + settings={'TCombobox': + {'configure': + {'selectbackground': element.BackgroundColor, + 'fieldbackground': element.BackgroundColor, + 'foreground': text_color, + 'background': element.BackgroundColor} + }}) + except: + try: + combostyle.theme_settings('combostyle', + settings={'TCombobox': + {'configure': + {'selectbackground': element.BackgroundColor, + 'fieldbackground': element.BackgroundColor, + 'foreground': text_color, + 'background': element.BackgroundColor} + }}) + except: pass + # ATTENTION: this applies the new style 'combostyle' to all ttk.Combobox + combostyle.theme_use('combostyle') + element.TKCombo = ttk.Combobox(tk_row_frame, width=width, textvariable=element.TKStringVar,font=font ) + # element.TKCombo['state']='readonly' + element.TKCombo['values'] = element.Values + # if element.BackgroundColor is not None: + # element.TKCombo.configure(background=element.BackgroundColor) + element.TKCombo.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) + element.TKCombo.current(0) + # ------------------------- LISTBOX element ------------------------- # + elif element_type == ELEM_TYPE_INPUT_LISTBOX: + max_line_len = max([len(str(l)) for l in element.Values]) + if auto_size_text is False: width=element_size[0] + else: width = max_line_len + + element.TKStringVar = tk.StringVar() + element.TKListbox= tk.Listbox(tk_row_frame, height=element_size[1], width=width, selectmode=element.SelectMode, font=font) + for item in element.Values: + element.TKListbox.insert(tk.END, item) + element.TKListbox.selection_set(0,0) + if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: + element.TKListbox.configure(background=element.BackgroundColor) + if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: + element.TKListbox.configure(fg=text_color) + # vsb = tk.Scrollbar(tk_row_frame, orient="vertical", command=element.TKListbox.yview) + # element.TKListbox.configure(yscrollcommand=vsb.set) + element.TKListbox.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) + # vsb.pack(side=tk.LEFT, fill='y') + # ------------------------- INPUT MULTI LINE element ------------------------- # + elif element_type == ELEM_TYPE_INPUT_MULTILINE: + default_text = element.DefaultText + width, height = element_size + element.TKText = tk.scrolledtext.ScrolledText(tk_row_frame, width=width, height=height, wrap='word', bd=border_depth,font=font) + element.TKText.insert(1.0, default_text) # set the default text + if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: + element.TKText.configure(background=element.BackgroundColor) + element.TKText.vbar.config(troughcolor=DEFAULT_SCROLLBAR_COLOR) + element.TKText.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) + if element.EnterSubmits: + element.TKText.bind('', element.ReturnKeyHandler) + if element.Focus is True or (toplevel_form.UseDefaultFocus and not focus_set): + focus_set = True + element.TKText.focus_set() + if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: + element.TKText.configure(fg=text_color) + # ------------------------- INPUT CHECKBOX element ------------------------- # + elif element_type == ELEM_TYPE_INPUT_CHECKBOX: + width = 0 if auto_size_text else element_size[0] + default_value = element.InitialState + element.TKIntVar = tk.IntVar() + element.TKIntVar.set(default_value if default_value is not None else 0) + element.TKCheckbutton = tk.Checkbutton(tk_row_frame, anchor=tk.NW, text=element.Text, width=width, variable=element.TKIntVar, bd=border_depth, font=font) + if default_value is None: + element.TKCheckbutton.configure(state='disable') + if element.BackgroundColor is not None: + element.TKCheckbutton.configure(background=element.BackgroundColor) + if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: + element.TKCheckbutton.configure(fg=text_color) + element.TKCheckbutton.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) + # ------------------------- PROGRESS BAR element ------------------------- # + elif element_type == ELEM_TYPE_PROGRESS_BAR: + # save this form because it must be 'updated' (refreshed) solely for the purpose of updating bar + width = element_size[0] + fnt = tkinter.font.Font() + char_width = fnt.measure('A') # single character width + progress_length = width*char_width + progress_width = element_size[1] + direction = element.Orientation + if element.BarColor != (None, None): # if element has a bar color, use it + bar_color = element.BarColor + else: + bar_color = DEFAULT_PROGRESS_BAR_COLOR + element.TKProgressBar = TKProgressBar(tk_row_frame, element.MaxValue, progress_length, progress_width, orientation=direction, BarColor=bar_color, border_width=element.BorderWidth, relief=element.Relief, style=element.BarStyle ) + # element.TKProgressBar = TKProgressBar(tk_row_frame, element.MaxValue, progress_length, progress_width, orientation=direction, BarColor=bar_color, border_width=element.BorderWidth, relief=element.Relief) + element.TKProgressBar.TKProgressBarForReal.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) + # ------------------------- INPUT RADIO BUTTON element ------------------------- # + elif element_type == ELEM_TYPE_INPUT_RADIO: + width = 0 if auto_size_text else element_size[0] + default_value = element.InitialState + ID = element.GroupID + # see if ID has already been placed + value = EncodeRadioRowCol(row_num, col_num) # value to set intvar to if this radio is selected + if ID in toplevel_form.RadioDict: + RadVar = toplevel_form.RadioDict[ID] + else: + RadVar = tk.IntVar() + toplevel_form.RadioDict[ID] = RadVar + element.TKIntVar = RadVar # store the RadVar in Radio object + if default_value: # if this radio is the one selected, set RadVar to match + element.TKIntVar.set(value) + element.TKRadio = tk.Radiobutton(tk_row_frame, anchor=tk.NW, text=element.Text, width=width, + variable=element.TKIntVar, value=value, bd=border_depth, font=font) + if element.BackgroundColor is not None: + element.TKRadio.configure(background=element.BackgroundColor) + if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: + element.TKRadio.configure(fg=text_color) + element.TKRadio.pack(side=tk.LEFT, padx=element.Pad[0],pady=element.Pad[1]) + # ------------------------- INPUT SPIN Box element ------------------------- # + elif element_type == ELEM_TYPE_INPUT_SPIN: + width, height = element_size + width = 0 if auto_size_text else element_size[0] + element.TKStringVar = tk.StringVar() + element.TKSpinBox = tk.Spinbox(tk_row_frame, values=element.Values, textvariable=element.TKStringVar, width=width, bd=border_depth) + element.TKStringVar.set(element.DefaultValue) + element.TKSpinBox.configure(font=font) # set wrap to width of widget + if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: + element.TKSpinBox.configure(background=element.BackgroundColor) + element.TKSpinBox.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) + if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: + element.TKSpinBox.configure(fg=text_color) + # ------------------------- OUTPUT element ------------------------- # + elif element_type == ELEM_TYPE_OUTPUT: + width, height = element_size + element.TKOut = TKOutput(tk_row_frame, width=width, height=height, bd=border_depth, background_color=element.BackgroundColor, text_color=text_color) + element.TKOut.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) + # ------------------------- IMAGE Box element ------------------------- # + elif element_type == ELEM_TYPE_IMAGE: + photo = tk.PhotoImage(file=element.Filename) + if element_size == (None, None) or element_size == None or element_size == toplevel_form.DefaultElementSize: + width, height = photo.width(), photo.height() + else: + width, height = element_size + tktext_label = tk.Label(tk_row_frame, image=photo, width=width, height=height, bd=border_depth) + tktext_label.image = photo + # tktext_label.configure(anchor=tk.NW, image=photo) + tktext_label.pack(side=tk.LEFT) + # ------------------------- SLIDER Box element ------------------------- # + elif element_type == ELEM_TYPE_INPUT_SLIDER: + slider_length = element_size[0] * CharWidthInPixels() + slider_width = element_size[1] + element.TKIntVar = tk.IntVar() + element.TKIntVar.set(element.DefaultValue) + if element.Orientation[0] == 'v': + range_from = element.Range[1] + range_to = element.Range[0] + slider_length += DEFAULT_MARGINS[1]*(element_size[0]*2) # add in the padding + else: + range_from = element.Range[0] + range_to = element.Range[1] + tkscale = tk.Scale(tk_row_frame, orient=element.Orientation, variable=element.TKIntVar, from_=range_from, to_=range_to, length=slider_length, width=slider_width , bd=element.BorderWidth, relief=element.Relief, font=font) + # tktext_label.configure(anchor=tk.NW, image=photo) + if element.BackgroundColor is not None: + tkscale.configure(background=element.BackgroundColor) + tkscale.config(troughcolor=DEFAULT_SCROLLBAR_COLOR) + if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: + tkscale.configure(fg=text_color) + tkscale.pack(side=tk.LEFT) + #............................DONE WITH ROW pack the row of widgets ..........................# + # done with row, pack the row of widgets + tk_row_frame.grid(row=row_num+2, sticky=tk.NW, padx=DEFAULT_MARGINS[0]) + + if form.BackgroundColor is not None: + tk_row_frame.configure(background=form.BackgroundColor) + if not toplevel_form.IsTabbedForm: + toplevel_form.TKroot.configure(padx=DEFAULT_MARGINS[0], pady=DEFAULT_MARGINS[1]) + else: toplevel_form.ParentWindow.configure(padx=DEFAULT_MARGINS[0], pady=DEFAULT_MARGINS[1]) + return + + def ConvertFlexToTK(MyFlexForm): + master = MyFlexForm.TKroot + # only set title on non-tabbed forms + if not MyFlexForm.IsTabbedForm: + master.title(MyFlexForm.Title) + InitializeResults(MyFlexForm) + PackFormIntoFrame(MyFlexForm, master, MyFlexForm) + #....................................... DONE creating and laying out window ..........................# + if MyFlexForm.IsTabbedForm: + master = MyFlexForm.ParentWindow + master.attributes('-alpha', 0) # hide window while getting info and moving + screen_width = master.winfo_screenwidth() # get window info to move to middle of screen + screen_height = master.winfo_screenheight() + if MyFlexForm.Location != (None, None): + x,y = MyFlexForm.Location + elif DEFAULT_WINDOW_LOCATION != (None, None): + x,y = DEFAULT_WINDOW_LOCATION + else: + master.update_idletasks() # don't forget + win_width = master.winfo_width() + win_height = master.winfo_height() + x = screen_width/2 -win_width/2 + y = screen_height/2 - win_height/2 + if y+win_height > screen_height: + y = screen_height-win_height + if x+win_width > screen_width: + x = screen_width-win_width + + move_string = '+%i+%i'%(int(x),int(y)) + master.geometry(move_string) + master.attributes('-alpha', 255) # Make window visible again + master.update_idletasks() # don't forget + return + +def ConvertFlexToTKOld(MyFlexForm): def CharWidthInPixels(): return tkinter.font.Font().measure('A') # single character width master = MyFlexForm.TKroot @@ -1542,6 +1977,7 @@ def CharWidthInPixels(): # ----====----====----====----====----==== STARTUP TK ====----====----====----====----====----# def ShowTabbedForm(title, *args, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, fav_icon=DEFAULT_WINDOW_ICON): + # takes as input (form, rows, tab name) for each tab global _my_windows uber = UberForm() @@ -1617,10 +2053,10 @@ def StartupTK(my_flex_form): my_flex_form.TKAfterID = root.after(duration * 1000, my_flex_form._AutoCloseAlarmCallback) if my_flex_form.NonBlocking: my_flex_form.TKroot.protocol("WM_WINDOW_DESTROYED", my_flex_form.OnClosingCallback()) - pass else: # it's a blocking form my_flex_form.TKroot.mainloop() - _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 + if not my_flex_form.FormRemainedOpen: + _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 if my_flex_form.RootNeedsDestroying: my_flex_form.TKroot.destroy() my_flex_form.RootNeedsDestroying = False @@ -1673,7 +2109,8 @@ def MsgBox(*args, button_color=None, button_type=MSG_BOX_OK, auto_close=False, a local_line_width = line_width else: local_line_width = MESSAGE_BOX_LINE_WIDTH - with FlexForm(args_to_print[0], auto_size_text=True, button_color=button_color, auto_close=auto_close, auto_close_duration=auto_close_duration, icon=icon, font=font) as form: + title = args_to_print[0] if args_to_print[0] is not None else 'None' + with FlexForm(title, auto_size_text=True, button_color=button_color, auto_close=auto_close, auto_close_duration=auto_close_duration, icon=icon, font=font) as form: max_line_total, total_lines = 0,0 for message in args_to_print: # fancy code to check if string and convert if not is not need. Just always convert to string :-) @@ -2060,7 +2497,7 @@ def Print(self, *args, end=None, sep=None): # print(1, 2, 3, sep='-') # if end is None: # print("") - self.form.Refresh() + self.form.ReadNonBlocking() def Close(self): self.form.CloseNonBlockingForm() From 6a6ed02a02181fb691601a49d01b693287e82375 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 16 Aug 2018 09:21:30 -0400 Subject: [PATCH 141/209] Look and feel calls, text colors New values in Look and Feel table. Recipes call the new look and feel func. --- Demo_Recipes.py | 54 ++++++++++++++++++++++------------------ PySimpleGUI.py | 65 +++++++++++++++++++++++++++++++++++++------------ 2 files changed, 79 insertions(+), 40 deletions(-) diff --git a/Demo_Recipes.py b/Demo_Recipes.py index d34fac495..529b2480a 100644 --- a/Demo_Recipes.py +++ b/Demo_Recipes.py @@ -6,13 +6,13 @@ def SourceDestFolders(): with sg.FlexForm('Demo Source / Destination Folders') as form: form_rows = ([sg.Text('Enter the Source and Destination folders')], - [sg.Text('Source Folder', size=(15, 1), justification='right'), sg.InputText('Source'), sg.FolderBrowse()], - [sg.Text('Destination Folder', size=(15, 1), justification='right'), sg.InputText('Dest'), sg.FolderBrowse()], + [sg.Text('Source Folder', size=(15, 1), justification='right'), sg.InputText('Source', key='source'), sg.FolderBrowse()], + [sg.Text('Destination Folder', size=(15, 1), justification='right'), sg.InputText('Dest', key='dest'), sg.FolderBrowse()], [sg.Submit(), sg.Cancel()]) - button, (source, dest) = form.LayoutAndRead(form_rows) + button, values = form.LayoutAndRead(form_rows) if button == 'Submit': - sg.MsgBox('Submitted', 'The user entered source:', source, 'Destination folder:', dest, 'Using button', button) + sg.MsgBox('Submitted', values, 'The user entered source:', values['source'], 'Destination folder:', values['dest'], 'Using button', button) else: sg.MsgBoxError('Cancelled', 'User Cancelled') @@ -160,20 +160,26 @@ def NonBlockingPeriodicUpdateForm(): # Show a form that's a running counter form = sg.FlexForm('Running Timer', auto_size_text=True) text_element = sg.Text('', size=(10, 2), font=('Helvetica', 20), justification='center') - form_rows = [[sg.Text('Non blocking GUI with updates')], + form_rows = [[sg.Text('Stopwatch')], [text_element], - [sg.T(' ' * 15), sg.Quit()]] + [sg.T(' ' * 5), sg.ReadFormButton('Start/Stop', focus=True), sg.Quit()]] + form.LayoutAndRead(form_rows, non_blocking=True) - for i in range(1,50000): - text_element.Update('{:02d}:{:02d}.{:02d}'.format((i//100)//60, (i//100)%60, i%100)) + timer_running = True + i = 0 + while True: + i += 1 * (timer_running is True) button, values = form.ReadNonBlocking() if values is None or button == 'Quit': # if user closed the window using X or clicked Quit button break + elif button == 'Start/Stop': + timer_running = not timer_running + text_element.Update('{:02d}:{:02d}.{:02d}'.format((i//100)//60, (i//100)%60, i%100)) + time.sleep(.01) - else: # if the loop finished then need to close the form for the user - form.CloseNonBlockingForm() + form.CloseNonBlockingForm() del(form) def DebugTest(): @@ -199,29 +205,29 @@ def ChangeLookAndFeel(colors): #=---------------------------------- main ------------------------------ def main(): - # Green & tan color scheme - colors1 = {'BACKGROUND' : '#9FB8AD', 'TEXT': sg.COLOR_SYSTEM_DEFAULT, 'INPUT':'#F7F3EC', 'BUTTON': ('white', '#475841'),'PROGRESS':sg.DEFAULT_PROGRESS_BAR_COLOR } - # light green with tan - colors2 = {'BACKGROUND' : '#B7CECE', 'TEXT': 'black', 'INPUT':'#FDFFF7', 'BUTTON': ('white', '#658268'), 'PROGRESS':('#247BA0','#F8FAF0')} - # blue with light blue color scheme - colors3 = {'BACKGROUND' : '#A5CADD', 'TEXT': '#6E266E', 'INPUT':'#E0F5FF', 'BUTTON': ('white', '#303952'),'PROGRESS':sg.DEFAULT_PROGRESS_BAR_COLOR} - - ChatBot() Everything() + ChatBot() + sg.ChangeLookAndFeel('BrownBlue') SourceDestFolders() - ChangeLookAndFeel(colors2) - ProgressMeter() - ChangeLookAndFeel(colors3) + sg.ChangeLookAndFeel('BlueMono') Everything() - ChangeLookAndFeel(colors2) + sg.ChangeLookAndFeel('BluePurple') + Everything() + sg.ChangeLookAndFeel('LightGreen') + Everything() + sg.ChangeLookAndFeel('GreenMono') MachineLearningGUI() + sg.ChangeLookAndFeel('TealMono') + NonBlockingPeriodicUpdateForm() + ChatBot() + ProgressMeter() + sg.ChangeLookAndFeel('Purple') Everything_NoContextManager() NonBlockingPeriodicUpdateForm_ContextManager() - NonBlockingPeriodicUpdateForm() - DebugTest() sg.MsgBox('Done with all recipes') + DebugTest() if __name__ == '__main__': main() diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 64753abbb..dda7640a9 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -42,6 +42,7 @@ DEFAULT_TEXT_ELEMENT_BACKGROUND_COLOR = None DEFAULT_TEXT_COLOR = COLOR_SYSTEM_DEFAULT DEFAULT_INPUT_ELEMENTS_COLOR = COLOR_SYSTEM_DEFAULT +DEFAULT_INPUT_TEXT_COLOR = COLOR_SYSTEM_DEFAULT DEFAULT_SCROLLBAR_COLOR = None # DEFAULT_BUTTON_COLOR = (YELLOWS[0], PURPLES[0]) # (Text, Background) or (Color "on", Color) as a way to remember # DEFAULT_BUTTON_COLOR = (GREENS[3], TANS[0]) # Foreground, Background (None, None) == System Default @@ -219,10 +220,11 @@ def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto ''' self.DefaultText = default_text self.PasswordCharacter = password_char - bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR + bg = background_color if background_color is not None else DEFAULT_INPUT_ELEMENTS_COLOR + fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR self.Focus = focus self.do_not_clear = do_not_clear - super().__init__(ELEM_TYPE_INPUT_TEXT, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=text_color, key=key) + super().__init__(ELEM_TYPE_INPUT_TEXT, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=fg, key=key) @@ -246,7 +248,9 @@ def __init__(self, values, scale=(None, None), size=(None, None), auto_size_text self.Values = values self.TKComboBox = None bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR - super().__init__(ELEM_TYPE_INPUT_COMBO, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=text_color, key=key) + fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR + + super().__init__(ELEM_TYPE_INPUT_COMBO, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=fg, key=key) def __del__(self): try: @@ -284,7 +288,8 @@ def __init__(self, values, select_mode=None, scale=(None, None), size=(None, Non else: self.SelectMode = DEFAULT_LISTBOX_SELECT_MODE bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR - super().__init__(ELEM_TYPE_INPUT_LISTBOX, scale=scale, size=size, auto_size_text=auto_size_text, font=font, background_color=bg, text_color=text_color, key=key) + fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR + super().__init__(ELEM_TYPE_INPUT_LISTBOX, scale=scale, size=size, auto_size_text=auto_size_text, font=font, background_color=bg, text_color=fg, key=key) def __del__(self): try: @@ -376,7 +381,9 @@ def __init__(self, values, initial_value=None, scale=(None, None), size=(None, N self.DefaultValue = initial_value self.TKSpinBox = None bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR - super().__init__(ELEM_TYPE_INPUT_SPIN, scale, size, auto_size_text, font=font,background_color=bg, text_color=text_color, key=key) + fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR + + super().__init__(ELEM_TYPE_INPUT_SPIN, scale, size, auto_size_text, font=font,background_color=bg, text_color=fg, key=key) return def __del__(self): @@ -405,7 +412,9 @@ def __init__(self, default_text='', enter_submits = False, scale=(None, None), s bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR self.Focus = focus self.do_not_clear = do_not_clear - super().__init__(ELEM_TYPE_INPUT_MULTILINE, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=text_color, key=key) + fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR + + super().__init__(ELEM_TYPE_INPUT_MULTILINE, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=fg, key=key) return def Update(self, NewValue): @@ -555,7 +564,9 @@ def __init__(self, scale=(None, None), size=(None, None), background_color=None, ''' self.TKOut = None bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR - super().__init__(ELEM_TYPE_OUTPUT, scale=scale, size=size, background_color=bg, text_color=text_color) + fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR + + super().__init__(ELEM_TYPE_OUTPUT, scale=scale, size=size, background_color=bg, text_color=fg) def __del__(self): try: @@ -1366,9 +1377,7 @@ def CharWidthInPixels(): element.TKButton = tkbutton # not used yet but save the TK button in case wraplen = tkbutton.winfo_reqwidth() # width of widget in Pixels if element.ImageFilename: # if button has an image on it - print('Button Image Filename being placed', element.ImageFilename) photo = tk.PhotoImage(file=element.ImageFilename) - print('PhotoImage object', ObjToString(photo)) if element.ImageSize != (None, None): width, height = element.ImageSize if element.ImageSubsample: @@ -2037,6 +2046,7 @@ def StartupTK(my_flex_form): global _my_windows ow = _my_windows.NumOpenWindows + # print('Starting TK open Windows = {}'.format(ow)) root = tk.Tk() if not ow else tk.Toplevel() if my_flex_form.BackgroundColor is not None: root.configure(background=my_flex_form.BackgroundColor) @@ -2054,7 +2064,9 @@ def StartupTK(my_flex_form): if my_flex_form.NonBlocking: my_flex_form.TKroot.protocol("WM_WINDOW_DESTROYED", my_flex_form.OnClosingCallback()) else: # it's a blocking form + # print('..... CALLING MainLoop') my_flex_form.TKroot.mainloop() + # print('..... BACK from MainLoop') if not my_flex_form.FormRemainedOpen: _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 if my_flex_form.RootNeedsDestroying: @@ -2651,7 +2663,7 @@ def SetOptions(icon=None, button_color=None, element_size=(None,None), margins=( progress_meter_border_depth=None, progress_meter_style=None, progress_meter_relief=None, progress_meter_color=None, progress_meter_size=None, text_justification=None, background_color=None, element_background_color=None, - text_element_background_color=None, input_elements_background_color=None, + text_element_background_color=None, input_elements_background_color=None, input_text_color=None, scrollbar_color=None, text_color=None, element_text_color = None, debug_win_size=(None,None), window_location=(None,None)): global DEFAULT_ELEMENT_SIZE @@ -2682,6 +2694,7 @@ def SetOptions(icon=None, button_color=None, element_size=(None,None), margins=( global DEFAULT_TEXT_COLOR global DEFAULT_WINDOW_LOCATION global DEFAULT_ELEMENT_TEXT_COLOR + global DEFAULT_INPUT_TEXT_COLOR global _my_windows if icon: @@ -2776,6 +2789,8 @@ def SetOptions(icon=None, button_color=None, element_size=(None,None), margins=( if element_text_color != None: DEFAULT_ELEMENT_TEXT_COLOR = element_text_color + if input_text_color is not None: + DEFAULT_INPUT_TEXT_COLOR = input_text_color return True @@ -2785,12 +2800,29 @@ def SetOptions(icon=None, button_color=None, element_size=(None,None), margins=( ############################################################## def ChangeLookAndFeel(index): # look and feel table - look_and_feel = {'GreenTan': {'BACKGROUND' : '#9FB8AD', 'TEXT': COLOR_SYSTEM_DEFAULT, 'INPUT':'#F7F3EC', 'BUTTON': ('white', '#475841'), - 'PROGRESS':DEFAULT_PROGRESS_BAR_COLOR}, + look_and_feel = {'GreenTan': {'BACKGROUND' : '#9FB8AD', 'TEXT': COLOR_SYSTEM_DEFAULT, 'INPUT':'#F7F3EC','TEXT_INPUT' : 'black','SCROLL': '#F7F3EC', 'BUTTON': ('white', '#475841'), 'PROGRESS':DEFAULT_PROGRESS_BAR_COLOR}, + + 'LightGreen' :{'BACKGROUND' : '#B7CECE', 'TEXT': 'black', 'INPUT':'#FDFFF7','TEXT_INPUT' : 'black', 'SCROLL': '#FDFFF7','BUTTON': ('white', '#658268'), 'PROGRESS':('#247BA0','#F8FAF0')}, + + 'BluePurple': {'BACKGROUND' : '#A5CADD', 'TEXT': '#6E266E', 'INPUT':'#E0F5FF','TEXT_INPUT' : 'black', 'SCROLL': '#E0F5FF','BUTTON': ('white', '#303952'),'PROGRESS':DEFAULT_PROGRESS_BAR_COLOR}, + + 'Purple': {'BACKGROUND': '#B0AAC2', 'TEXT': 'black', 'INPUT': '#F2EFE8','SCROLL': '#F2EFE8','TEXT_INPUT' : 'black', + 'BUTTON': ('black', '#C2D4D8'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, + + 'BlueMono': {'BACKGROUND': '#AAB6D3', 'TEXT': 'black', 'INPUT': '#F1F4FC','SCROLL': '#F1F4FC','TEXT_INPUT' : 'black', + 'BUTTON': ('white', '#7186C7'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, + + 'GreenMono': {'BACKGROUND': '#A8C1B4', 'TEXT': 'black', 'INPUT': '#DDE0DE', 'SCROLL': '#E3E3E3','TEXT_INPUT' : 'black', + 'BUTTON': ('white', '#6D9F85'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, + + 'BrownBlue': {'BACKGROUND': '#64778d', 'TEXT': 'white', 'INPUT': '#f0f3f7', 'SCROLL': '#A6B2BE','TEXT_INPUT' : 'black', + 'BUTTON': ('white', '#283b5b'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, - 'LightGreen' :{'BACKGROUND' : '#B7CECE', 'TEXT': 'black', 'INPUT':'#FDFFF7', 'BUTTON': ('white', '#658268'), 'PROGRESS':('#247BA0','#F8FAF0')}, + 'BrightColors': {'BACKGROUND': '#b4ffb4', 'TEXT': 'black', 'INPUT': '#ffff64','SCROLL': '#ffb482','TEXT_INPUT' : 'black', + 'BUTTON': ('black', '#ffa0dc'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, - 'BluePurple': {'BACKGROUND' : '#A5CADD', 'TEXT': '#6E266E', 'INPUT':'#E0F5FF', 'BUTTON': ('white', '#303952'),'PROGRESS':DEFAULT_PROGRESS_BAR_COLOR}} + 'TealMono': {'BACKGROUND': '#a8cfdd', 'TEXT': 'black', 'INPUT': '#dfedf2','SCROLL': '#dfedf2', 'TEXT_INPUT' : 'black', 'BUTTON': ('white', '#3b7f97'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR} + } try: colors = look_and_feel[index] @@ -2804,8 +2836,9 @@ def ChangeLookAndFeel(index): border_width=0, slider_border_width=0, progress_meter_border_depth=0, - scrollbar_color=(colors['INPUT']), - element_text_color=colors['TEXT']) + scrollbar_color=(colors['SCROLL']), + element_text_color=colors['TEXT'], + input_text_color=colors['TEXT_INPUT']) except: # most likely an index out of range pass From 15cd0ed7f3795fc455426f8a0f144bfa03a05db4 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 16 Aug 2018 10:03:53 -0400 Subject: [PATCH 142/209] Form Designer, auto packer, new color options, new predefined look and feel Some really cool features for changing how things look. Directions on how to use the new PySimpleGUI Form Designer --- readme.md | 183 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 156 insertions(+), 27 deletions(-) diff --git a/readme.md b/readme.md index 32008eb50..50e12dac2 100644 --- a/readme.md +++ b/readme.md @@ -144,7 +144,6 @@ You will see a number of different styles of buttons, data entry fields, etc, in - Return values are a list of button presses and input values. - Return values can also be represented as a dictionary -It's stunning that after so many years Python still hasn't put forth a GUI framework that truly fits the language's basic data structures, especially lists. It's hard to argue with the success to be had in quickly building GUI applications using this package's syntax. ----- ## Getting Started with PySimpleGUI @@ -380,7 +379,89 @@ Two other types of forms exist. 1. Persistent form - rather than closing on button clicks, the show form function returns and the form continues to be visible. This is good for applications like a chat window. 2. Asynchronous form - the trickiest of the lot. Great care must be exercised. Examples are an MP3 player or status dashboard. Async forms are updated (refreshed) on a periodic basis. -It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. Let's start with a basic Browse for a file and do something with it. +It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. + +## The Form Designer +The good news to newcomers to GUI programming is that PySimpleGUI has a form designer. Better yet, the form designer requires no training and everyone knows how to use it. + +![gui0_1](https://user-images.githubusercontent.com/13696193/44159598-e2257400-a085-11e8-9b02-343e72cc75c3.JPG) + +It's a manual process, but if you follow the instructions, it will take only a minute to do and the result will be a nice looking GUI. The steps you'll take are: +1. Sketch your GUI on paper +2. Divide your GUI up into rows +3. Label each Element with the Element name +4. Write your Python code using the labels as pseudo-code + +Let's take a couple of examples. + +**Enter a number**.... Popular beginner programs are often based on a game or logic puzzle that requires the user to enter something, like a number. The "high-low" answer game comes to mind where you try to guess the number based on high or low tips. + +**Step 1- Sketch the GUI** +![gui1_1](https://user-images.githubusercontent.com/13696193/44160127-6a584900-a087-11e8-8fec-09099a8e16f6.JPG) + +**Step 2 - Divide into rows** + +![gui2_1](https://user-images.githubusercontent.com/13696193/44160128-6a584900-a087-11e8-9973-af866fb94c56.JPG) + +Step 3 - Label elements + +![gui6_1](https://user-images.githubusercontent.com/13696193/44160116-64626800-a087-11e8-8b57-671c0461b508.JPG) + +Step 4 - Write the code +The code we're writing is the layout of the GUI itself. This tutorial only focuses on getting the window code written, not the stuff to display it, get results. + +We have only 1 element on the first row, some text. Rows are written as a "list of elements", so we'll need [ ] to make a list. Here's the code for row 1 + + [ sg.Text('Enter a number') ] + +Row 2 has 1 elements, an input field. + + [ sg.Input() ] +Row 3 has an OK button + + [ sg.OK() ] + +Now that we've got the 3 rows defined, they are put into a list that represents the entire window. + + layout = [ [sg.Text('Enter a Number')], + [sg.Input()], + [sg.OK()] ] + +Finally we can put it all together into a program that will display our window. + + import PySimpleGUI as sg + + layout = [[sg.Text('Enter a Number')], + [sg.Input()], + [sg.OK()] ] + + button, (number,) = sg.FlexForm('Enter a number example').LayoutAndRead(layout) + + sg.MsgBox(button, number) + +### Example 2 - Get a filename +Let's say you've got a utility you've written that operates on some input file and you're ready to use a GUI to enter than filename rather than the command line. Follow the same steps as the previous example - draw your form on paper, break it up into rows, label the elements. + +![gui4_1](https://user-images.githubusercontent.com/13696193/44160132-6a584900-a087-11e8-862f-7d791a67ee5d.JPG) +![gui5_1](https://user-images.githubusercontent.com/13696193/44160133-6af0df80-a087-11e8-9dec-bb4d4c59393d.JPG) + +Writing the code for this one is just as straightforward. There is one tricky thing, that browse for a file button. Thankfully PySimpleGUI takes care of associating it with the input field next to it. As a result, the code looks almost exactly like the form on the paper. + + import PySimpleGUI as sg + + layout = [[sg.Text('Filename')], + [sg.Input(), sg.FileBrowse()], + [sg.OK(), sg.Cancel()] ] + + button, (number,) = sg.FlexForm('Get filename example').LayoutAndRead(layout) + + sg.MsgBox(button, number) + + +Read on for detailed instructions on the calls that show the form and return your results. + + + # Copy these design patterns! ## Pattern 1 - With Context Manager @@ -451,6 +532,24 @@ In the statement that shows and reads the form, the two input fields are directl Isn't this what almost every Python programmer looking for a GUI wants?? Something easy to work with to get the values and move on to the rest of the program, where the real action is taking place. Why write pages of tkinter code when the same layout can be achieved with PySimpleGUI in 3 or 4 lines of code. 4 lines or 40? I chose 4. + + +### The Auto-Packer + +Once you've laid out your elements into, it's the job of the Auto-Packer to place your elements into a window frame. + +The layout of custom GUIs is made trivial by the use of the Auto-Packer. GUI frameworks often use a grid system and sometimes have a "pack" function that's used to place widgets into a window. It's almost always a confusing exercise to use them. + +PySimpleGUI uses a "row by row" approach to building GUIs. When you were to sketch your GUI out on a sheet of paper and then draw horizontal lines across the page under each widget then you would have a several "rows" of widgets. + +For each row in your GUI, you will have a list of elements. In Python this list is a simple Python list. An entire GUI window is a list of rows, one after another. + +This is how your GUI is created, one row at a time, with one row stacked on top of another. This visual form of coding makes GUI creation go so much quicker. + + layout = [ [ Row 1 Elements], + [ Row 2 Elements] ] + + ### Laying out your form Your form is a 2 dimensional list in Python. The first dimension are rows, the second is a list of Elements for each row. The first thing you want to do is layout your form on paper. @@ -1247,24 +1346,27 @@ Let's have some fun customizing! Make PySimpleGUI look the way you want it to l auto_size_buttons=None font=None border_width=None - slider_border_width=None - slider_relief=None - slider_orientation=None - autoclose_time=None - message_box_line_width=None - progress_meter_border_depth=None - progress_meter_style=None - progress_meter_relief=None - progress_meter_color=None - progress_meter_size=None - text_justification=None - background_color=None - element_background_color=None - text_element_background_color=None - input_elements_background_color=None - scrollbar_color=None, text_color=None - debug_win_size=(None,None) - window_location=(None,None) + slider_border_width=None + slider_relief=None + slider_orientation=None + autoclose_time=None + message_box_line_width=None + progress_meter_border_depth=None + progress_meter_style=None + progress_meter_relief=None + progress_meter_color=None + progress_meter_size=None + text_justification=None + text_color=None + background_color=None + element_background_color=None + text_element_background_color=None + input_elements_background_color=None + element_text_color=None + input_text_color=None + scrollbar_color=None, text_color=None + debug_win_size=(None,None) + window_location=(None,None) Explanation of parameters @@ -1291,6 +1393,8 @@ Explanation of parameters element_background_color - Background color of the elements text_element_background_color - Text element background color input_elements_background_color - Input fields background color + element_text_color - Text color of elements that have text, like Radio Buttons + input_text_color - Color of the text that you type in scrollbar_color - Color for scrollbars (may not always work) text_color - Text element default text color text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' @@ -1315,7 +1419,7 @@ When do you use a non-blocking form? A couple of examples are * Progress Meters - when you want to make your own progress meters * Output using print to a scrolled text element. Good for debugging. -Word of warning... version 2.2, the currently released, and upcoming version 2.3 differ in the return code for the `ReadNonBlocking` call. Previously the function returned 2 values, except when the form is closed using the "X" which returned a single value of `None`. The *new* way is that `ReadNonBlocking` always returns 2 values. If the user closed the form with the "X" then the return values will be None, None. You will want to key off the second value to catch this case. +Word of warning... starting with version 2.2 there is a change in the return values from the`ReadNonBlocking` call. Previously the function returned 2 values, except when the form is closed using the "X" which returned a single value of `None`. The *new* way is that `ReadNonBlocking` always returns 2 values. If the user closed the form with the "X" then the return values will be None, None. You will want to key off the second value to catch this case. The proper code to check if the user has exited the form will be a polling-loop that looks something like this: while True: @@ -1394,13 +1498,19 @@ That's it... this example follows the async design pattern well. ## Sample Applications Use the example programs as a starting basis for your GUI. Copy, paste, modify and run! The demo files are: -`Demo Recipes.py` - Sample forms for all major form types and situations. This is the place to get your code template from. Includes asynchronous forms, etc. +`Demo_Recipes.py` - Sample forms for all major form types and situations. This is the place to get your code template from. Includes asynchronous forms, etc. Start here! + +`Demo_Compare_Files` - Takes 2 filenames as input. Does a byte for byte compare and returns the results. + + `Demo_Dictionary` - Simple form demonstrating how return values in dictionary form work. -`Demo DisplayHash1and256.py` - Demonstrates using High Level API calls to get a filename + `Demo_DisplayHash1and256` - Presents 3 methods of gathering the same user input using both high-level APIs and lower-level. -`Demo DupliucateFileFinder.py` - Demonstrates High Level API to get a folder & Easy Progress Meter to show progress of the file scanning +Demo_Func_Callback_Simulation - Shows how callback functions can be simulated. This is particularly good for the Raspberry Pi and other embedded type applications. -`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. If anyone wants to help me package this application up, I could use a hand. +`Demo_DuplicateFileFinder.py` - Demonstrates High Level API to get a folder & Easy Progress Meter to show progress of the file scanning + +`Demo_HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program **could forever change how you code**. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. If anyone wants to help me package this application up and release as a standalone application, then speak up on the GitHub! ## Fun Stuff Here are some things to try if you're bored or want to further customize @@ -1417,6 +1527,22 @@ This will turn all of your print statements into prints that display in a window **Look and Feel** Dial in the look and feel that you like with the `SetOptions` function. You can change all of the defaults in one function call. One line of code to customize the entire GUI. +Or beginning in version 2.9 you can choose from a look and feel using pre-defined color schemes. Call ChangeLookAndFeel with a description string. + + sg.ChangeLookAndFeel('GreenTan') + +Valid values for the description string are: + + GreenTan + LightGreen + BluePurple + Purple + BlueMono + GreenMono + BrownBlue + BrightColors + TealMono + **ObjToString** Ever wanted to easily display an objects contents easily? Use ObjToString to get a nicely formatted recursive walk of your objects. @@ -1470,7 +1596,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ | 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting | 2.8.0 | Aug 9, 2018 - New None default option for Checkbox element, text color option for all elements, return values as a dictionary, setting focus, binding return key -| 2.9.0 | Aug XX,2018 - Screen flash fix, `do_not_clear` input field option, `autosize_text` defaults to `True` now, return values as ordered dict, +| 2.9.0 | Aug XX,2018 - Screen flash fix, `do_not_clear` input field option, `autosize_text` defaults to `True` now, return values as ordered dict, removed text target from progress bar, rework of return values and initial return values, removed legacy Form.Refresh() method (replaced by Form.ReadNonBlockingForm()), COLUMN elements!!, ### Release Notes @@ -1522,6 +1648,9 @@ In Python, functions behave just like object. When you're placing a Text Element **Lists** It seemed quite natural to use Python's powerful list constructs when possible. The form is specified as a series of lists. Each "row" of the GUI is represented as a list of Elements. When the form read returns the results to the user, all of the results are presented as a single list. This makes reading a form's values super-simple to do in a single line of Python code. +**Dictionaries** +Want to view your form's results as a dictionary instead of a list... no problem, just use the `key` keyword on your elements. For complex forms with a lot of values that need to be changed frequently, this is by far the best way of consuming the results. + ## Authors MikeTheWatchGuy @@ -1558,4 +1687,4 @@ For Python questions, I simply start my query with 'Python'. Let's say you forg In the hands of a competent programmer, this tool is **amazing**. It's a must-try kind of program that has completely changed my programming process. I'm not afraid of asking for help! You just have to be smart about using what you find. -The PySimpleGUI window that the results are shown in is an 'input' field which means you can copy and paste the results right into your code. \ No newline at end of file +The PySimpleGUI window that the results are shown in is an 'input' field which means you can copy and paste the results right into your code. From db4bb742ff3fde4a7602f1db2b4db14a3d14e875 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 16 Aug 2018 11:01:28 -0400 Subject: [PATCH 143/209] Columns, short form design pattern --- readme.md | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 6 deletions(-) diff --git a/readme.md b/readme.md index 50e12dac2..392287c2d 100644 --- a/readme.md +++ b/readme.md @@ -466,7 +466,7 @@ Read on for detailed instructions on the calls that show the form and return you ## Pattern 1 - With Context Manager - with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: + with sg.FlexForm('SHA-1 & 256 Hash') as form: form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], [sg.InputText(), sg.FileBrowse()], [sg.Submit(), sg.Cancel()]] @@ -475,22 +475,34 @@ Read on for detailed instructions on the calls that show the form and return you ## Pattern 2 - No Context Manager - form = sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) + form = sg.FlexForm('SHA-1 & 256 Hash') form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], [sg.InputText(), sg.FileBrowse()], [sg.Submit(), sg.Cancel()]] button, (source_filename,) = form.LayoutAndRead(form_rows) + ---- + +## Pattern 3 - Short Form + + + form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], + [sg.InputText(), sg.FileBrowse()], + [sg.Submit(), sg.Cancel()]] + button, (source_filename,) = sg.FlexForm('SHA-1 & 256 Hash').LayoutAndRead(form_rows) -These 2 design patters both produce this custom form: + +These 3 design patterns both produce this custom form: ![snap0134](https://user-images.githubusercontent.com/13696193/43162410-e7775466-8f58-11e8-8d6a-da4772c00dd8.jpg) -It's important to use the "with" context manager so that resources are freed as quickly as possible, using the currently executing thread. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. +When you're code leaves forms open or you show many forms, then it's important to use the "with" context manager so that resources are freed as quickly as possible. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. The second design pattern is not context manager based. If you are struggling with an unknown error, try modifying the code to run without a context manager. To do so, you simple remove the with, stick the form on the front of that statement, and un-indent the with-block code. +The third is the 'compact form'. It compacts down into 2 lines of code. One line is your form definition. The next is the call that shows the form and returns the values. You can use this pattern for simple, short programs where resource allocation isn't an issue. + You will use these design patterns or code templates for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. This is the most basic / normal of the design patterns. ### How GUI Programming in Python Should Look @@ -1202,7 +1214,7 @@ Somewhere later in your code will be your main event loop. This is where you do break time.sleep(.01) -This loop will read button values and print them. When one of the Realtime buttons is clicked, the call to `form.ReadNonBlocking` will return a button name matching the name on the button that was depressed. It will continue to return values as long as the button remains depressed. Once released, the ReadNonBlocking will return None for buttons ules anutton was clicked. +This loop will read button values and print them. When one of the Realtime buttons is clicked, the call to `form.ReadNonBlocking` will return a button name matching the name on the button that was depressed. It will continue to return values as long as the button remains depressed. Once released, the ReadNonBlocking will return None for buttons until a button is again clicked. **File Types** The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is @@ -1283,7 +1295,54 @@ Here's a complete solution for a chat-window using an Async form with an Output print(value) else: break +------------------- +## Columns +Starting in version 2.9 you'll be able to do more complex layouts by using the Column Element. Think of a Column as a form within a form. And, yes, you can have a Column within a Column if you want. + +Columns are specified in exactly the same way as a form is, as a list of lists. + +Columns are needed when you have an element that has a height > 1 line on the left, with single-line elements on the right. Here's an example of this kind of layout: + + +![column example](https://user-images.githubusercontent.com/13696193/44215113-b1097a00-a13f-11e8-96d0-f3511036494e.jpg) +This code produced the above window. + + + import PySimpleGUI as sg + + # Demo of how columns work + # Form has on row 1 a vertical slider followed by a COLUMN with 7 rows + # Prior to the Column element, this layout was not possible + # Columns layouts look identical to form layouts, they are a list of lists of elements. + + form = sg.FlexForm('Columns') # blank form + + # Column layout + col = [[sg.Text('col Row 1')], + [sg.Text('col Row 2'), sg.Input('col input 1')], + [sg.Text('col Row 3'), sg.Input('col input 2')], + [sg.Text('col Row 4'), sg.Input('col input 3')], + [sg.Text('col Row 5'), sg.Input('col input 4')], + [sg.Text('col Row 6'), sg.Input('col input 5')], + [sg.Text('col Row 7'), sg.Input('col input 6')]] + + layout = [[sg.Slider(range=(1,100), default_value=10, orientation='v', size=(8,20)), sg.Column(col)], + [sg.In('Last input')], + [sg.OK()]] + + # Display the form and get values + # If you're willing to not use the "context manager" design pattern, then it's possible + # to collapse the form display and read down to a single line of code. + button, values = sg.FlexForm('Compact 1-line form with column').LayoutAndRead(layout) + + sg.MsgBox(button, values, line_width=200) + +The Column Element has 1 required parameter and 1 optional (the layout and the background color). Setting the background color has the same effect as setting the form's background color, except it only affects the column rectangle. + + Column(layout, background_color=None) + +The default background color for Columns is the same as the default window background color. If you change the look and feel of the form, the column background will match the form background automatically. ## Tabbed Forms Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format @@ -1679,7 +1738,7 @@ Here are the steps to run that application To run it: Python HowDoI.py -The pip command is all there is to the setup. +The pip command is all there is to the setup. The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. @@ -1688,3 +1747,4 @@ For Python questions, I simply start my query with 'Python'. Let's say you forg In the hands of a competent programmer, this tool is **amazing**. It's a must-try kind of program that has completely changed my programming process. I'm not afraid of asking for help! You just have to be smart about using what you find. The PySimpleGUI window that the results are shown in is an 'input' field which means you can copy and paste the results right into your code. + From 79de9099e9537ca74243dc5aeae961f8e5ea2900 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 16 Aug 2018 12:39:51 -0400 Subject: [PATCH 144/209] Copying readme over --- docs/index.md | 263 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 227 insertions(+), 36 deletions(-) diff --git a/docs/index.md b/docs/index.md index 0d55aa851..392287c2d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -116,13 +116,14 @@ Here is the code that produced the above screenshot. sg.Slider(range=(1, 100), orientation='v', size=(10, 20), default_value=10)], [sg.Text('_' * 100, size=(70, 1))], [sg.Text('Choose Source and Destination Folders', size=(35, 1))], - [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), sg.FolderBrowse()], + [sg.Text('Source Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Source'), + sg.FolderBrowse()], [sg.Text('Destination Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Dest'), sg.FolderBrowse()], [sg.Submit(), sg.Cancel(), sg.SimpleButton('Customized', button_color=('white', 'green'))] - ] + ] - button, values = form.LayoutAndRead(layout) + button, values = form.LayoutAndRead(layout) **A note on screen shots** You will see a number of different styles of buttons, data entry fields, etc, in this readme. They were all made with the same SDK, the only difference is in the settings that are specified on a per-element, row, form, or global basis. One setting in particular, border_width, can make a big difference on the look of the form. Some of the screenshots had a border_width of 6, others a value of 1. @@ -143,7 +144,6 @@ You will see a number of different styles of buttons, data entry fields, etc, in - Return values are a list of button presses and input values. - Return values can also be represented as a dictionary -It's stunning that after so many years Python still hasn't put forth a GUI framework that truly fits the language's basic data structures, especially lists. It's hard to argue with the success to be had in quickly building GUI applications using this package's syntax. ----- ## Getting Started with PySimpleGUI @@ -379,12 +379,94 @@ Two other types of forms exist. 1. Persistent form - rather than closing on button clicks, the show form function returns and the form continues to be visible. This is good for applications like a chat window. 2. Asynchronous form - the trickiest of the lot. Great care must be exercised. Examples are an MP3 player or status dashboard. Async forms are updated (refreshed) on a periodic basis. -It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. Let's start with a basic Browse for a file and do something with it. +It's both not enjoyable nor helpful to immediately jump into tweaking each and every little thing available to you. + +## The Form Designer +The good news to newcomers to GUI programming is that PySimpleGUI has a form designer. Better yet, the form designer requires no training and everyone knows how to use it. + +![gui0_1](https://user-images.githubusercontent.com/13696193/44159598-e2257400-a085-11e8-9b02-343e72cc75c3.JPG) + +It's a manual process, but if you follow the instructions, it will take only a minute to do and the result will be a nice looking GUI. The steps you'll take are: +1. Sketch your GUI on paper +2. Divide your GUI up into rows +3. Label each Element with the Element name +4. Write your Python code using the labels as pseudo-code + +Let's take a couple of examples. + +**Enter a number**.... Popular beginner programs are often based on a game or logic puzzle that requires the user to enter something, like a number. The "high-low" answer game comes to mind where you try to guess the number based on high or low tips. + +**Step 1- Sketch the GUI** +![gui1_1](https://user-images.githubusercontent.com/13696193/44160127-6a584900-a087-11e8-8fec-09099a8e16f6.JPG) + +**Step 2 - Divide into rows** + +![gui2_1](https://user-images.githubusercontent.com/13696193/44160128-6a584900-a087-11e8-9973-af866fb94c56.JPG) + +Step 3 - Label elements + +![gui6_1](https://user-images.githubusercontent.com/13696193/44160116-64626800-a087-11e8-8b57-671c0461b508.JPG) + +Step 4 - Write the code +The code we're writing is the layout of the GUI itself. This tutorial only focuses on getting the window code written, not the stuff to display it, get results. + +We have only 1 element on the first row, some text. Rows are written as a "list of elements", so we'll need [ ] to make a list. Here's the code for row 1 + + [ sg.Text('Enter a number') ] + +Row 2 has 1 elements, an input field. + + [ sg.Input() ] +Row 3 has an OK button + + [ sg.OK() ] + +Now that we've got the 3 rows defined, they are put into a list that represents the entire window. + + layout = [ [sg.Text('Enter a Number')], + [sg.Input()], + [sg.OK()] ] + +Finally we can put it all together into a program that will display our window. + + import PySimpleGUI as sg + + layout = [[sg.Text('Enter a Number')], + [sg.Input()], + [sg.OK()] ] + + button, (number,) = sg.FlexForm('Enter a number example').LayoutAndRead(layout) + + sg.MsgBox(button, number) + +### Example 2 - Get a filename +Let's say you've got a utility you've written that operates on some input file and you're ready to use a GUI to enter than filename rather than the command line. Follow the same steps as the previous example - draw your form on paper, break it up into rows, label the elements. + +![gui4_1](https://user-images.githubusercontent.com/13696193/44160132-6a584900-a087-11e8-862f-7d791a67ee5d.JPG) +![gui5_1](https://user-images.githubusercontent.com/13696193/44160133-6af0df80-a087-11e8-9dec-bb4d4c59393d.JPG) + +Writing the code for this one is just as straightforward. There is one tricky thing, that browse for a file button. Thankfully PySimpleGUI takes care of associating it with the input field next to it. As a result, the code looks almost exactly like the form on the paper. + + import PySimpleGUI as sg + + layout = [[sg.Text('Filename')], + [sg.Input(), sg.FileBrowse()], + [sg.OK(), sg.Cancel()] ] + + button, (number,) = sg.FlexForm('Get filename example').LayoutAndRead(layout) + + sg.MsgBox(button, number) + + +Read on for detailed instructions on the calls that show the form and return your results. + + + # Copy these design patterns! ## Pattern 1 - With Context Manager - with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: + with sg.FlexForm('SHA-1 & 256 Hash') as form: form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], [sg.InputText(), sg.FileBrowse()], [sg.Submit(), sg.Cancel()]] @@ -393,22 +475,34 @@ It's both not enjoyable nor helpful to immediately jump into tweaking each and e ## Pattern 2 - No Context Manager - form = sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) + form = sg.FlexForm('SHA-1 & 256 Hash') form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], [sg.InputText(), sg.FileBrowse()], [sg.Submit(), sg.Cancel()]] button, (source_filename,) = form.LayoutAndRead(form_rows) + ---- +## Pattern 3 - Short Form -These 2 design patters both produce this custom form: + + form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], + [sg.InputText(), sg.FileBrowse()], + [sg.Submit(), sg.Cancel()]] + button, (source_filename,) = sg.FlexForm('SHA-1 & 256 Hash').LayoutAndRead(form_rows) + + + +These 3 design patterns both produce this custom form: ![snap0134](https://user-images.githubusercontent.com/13696193/43162410-e7775466-8f58-11e8-8d6a-da4772c00dd8.jpg) -It's important to use the "with" context manager so that resources are freed as quickly as possible, using the currently executing thread. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. +When you're code leaves forms open or you show many forms, then it's important to use the "with" context manager so that resources are freed as quickly as possible. PySimpleGUI uses `tkinter`. `tkinter` is very picky about who releases objects and when. The `with` takes care of disposing of everything properly for you. The second design pattern is not context manager based. If you are struggling with an unknown error, try modifying the code to run without a context manager. To do so, you simple remove the with, stick the form on the front of that statement, and un-indent the with-block code. +The third is the 'compact form'. It compacts down into 2 lines of code. One line is your form definition. The next is the call that shows the form and returns the values. You can use this pattern for simple, short programs where resource allocation isn't an issue. + You will use these design patterns or code templates for all of your "normal" (blocking) types of input forms. Copy it and modify it to suit your needs. This is the quickest way to get your code up and running with PySimpleGUI. This is the most basic / normal of the design patterns. ### How GUI Programming in Python Should Look @@ -450,6 +544,24 @@ In the statement that shows and reads the form, the two input fields are directl Isn't this what almost every Python programmer looking for a GUI wants?? Something easy to work with to get the values and move on to the rest of the program, where the real action is taking place. Why write pages of tkinter code when the same layout can be achieved with PySimpleGUI in 3 or 4 lines of code. 4 lines or 40? I chose 4. + + +### The Auto-Packer + +Once you've laid out your elements into, it's the job of the Auto-Packer to place your elements into a window frame. + +The layout of custom GUIs is made trivial by the use of the Auto-Packer. GUI frameworks often use a grid system and sometimes have a "pack" function that's used to place widgets into a window. It's almost always a confusing exercise to use them. + +PySimpleGUI uses a "row by row" approach to building GUIs. When you were to sketch your GUI out on a sheet of paper and then draw horizontal lines across the page under each widget then you would have a several "rows" of widgets. + +For each row in your GUI, you will have a list of elements. In Python this list is a simple Python list. An entire GUI window is a list of rows, one after another. + +This is how your GUI is created, one row at a time, with one row stacked on top of another. This visual form of coding makes GUI creation go so much quicker. + + layout = [ [ Row 1 Elements], + [ Row 2 Elements] ] + + ### Laying out your form Your form is a 2 dimensional list in Python. The first dimension are rows, the second is a list of Elements for each row. The first thing you want to do is layout your form on paper. @@ -1102,7 +1214,7 @@ Somewhere later in your code will be your main event loop. This is where you do break time.sleep(.01) -This loop will read button values and print them. When one of the Realtime buttons is clicked, the call to `form.ReadNonBlocking` will return a button name matching the name on the button that was depressed. It will continue to return values as long as the button remains depressed. Once released, the ReadNonBlocking will return None for buttons ules anutton was clicked. +This loop will read button values and print them. When one of the Realtime buttons is clicked, the call to `form.ReadNonBlocking` will return a button name matching the name on the button that was depressed. It will continue to return values as long as the button remains depressed. Once released, the ReadNonBlocking will return None for buttons until a button is again clicked. **File Types** The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is @@ -1183,7 +1295,54 @@ Here's a complete solution for a chat-window using an Async form with an Output print(value) else: break +------------------- +## Columns +Starting in version 2.9 you'll be able to do more complex layouts by using the Column Element. Think of a Column as a form within a form. And, yes, you can have a Column within a Column if you want. + +Columns are specified in exactly the same way as a form is, as a list of lists. + +Columns are needed when you have an element that has a height > 1 line on the left, with single-line elements on the right. Here's an example of this kind of layout: + + +![column example](https://user-images.githubusercontent.com/13696193/44215113-b1097a00-a13f-11e8-96d0-f3511036494e.jpg) +This code produced the above window. + + + import PySimpleGUI as sg + + # Demo of how columns work + # Form has on row 1 a vertical slider followed by a COLUMN with 7 rows + # Prior to the Column element, this layout was not possible + # Columns layouts look identical to form layouts, they are a list of lists of elements. + + form = sg.FlexForm('Columns') # blank form + + # Column layout + col = [[sg.Text('col Row 1')], + [sg.Text('col Row 2'), sg.Input('col input 1')], + [sg.Text('col Row 3'), sg.Input('col input 2')], + [sg.Text('col Row 4'), sg.Input('col input 3')], + [sg.Text('col Row 5'), sg.Input('col input 4')], + [sg.Text('col Row 6'), sg.Input('col input 5')], + [sg.Text('col Row 7'), sg.Input('col input 6')]] + + layout = [[sg.Slider(range=(1,100), default_value=10, orientation='v', size=(8,20)), sg.Column(col)], + [sg.In('Last input')], + [sg.OK()]] + + # Display the form and get values + # If you're willing to not use the "context manager" design pattern, then it's possible + # to collapse the form display and read down to a single line of code. + button, values = sg.FlexForm('Compact 1-line form with column').LayoutAndRead(layout) + + sg.MsgBox(button, values, line_width=200) + +The Column Element has 1 required parameter and 1 optional (the layout and the background color). Setting the background color has the same effect as setting the form's background color, except it only affects the column rectangle. + + Column(layout, background_color=None) + +The default background color for Columns is the same as the default window background color. If you change the look and feel of the form, the column background will match the form background automatically. ## Tabbed Forms Tabbed forms are shown using the `ShowTabbedForm` call. The call has the format @@ -1246,24 +1405,27 @@ Let's have some fun customizing! Make PySimpleGUI look the way you want it to l auto_size_buttons=None font=None border_width=None - slider_border_width=None - slider_relief=None - slider_orientation=None - autoclose_time=None - message_box_line_width=None - progress_meter_border_depth=None - progress_meter_style=None - progress_meter_relief=None - progress_meter_color=None - progress_meter_size=None - text_justification=None - background_color=None - element_background_color=None - text_element_background_color=None - input_elements_background_color=None - scrollbar_color=None, text_color=None - debug_win_size=(None,None) - window_location=(None,None) + slider_border_width=None + slider_relief=None + slider_orientation=None + autoclose_time=None + message_box_line_width=None + progress_meter_border_depth=None + progress_meter_style=None + progress_meter_relief=None + progress_meter_color=None + progress_meter_size=None + text_justification=None + text_color=None + background_color=None + element_background_color=None + text_element_background_color=None + input_elements_background_color=None + element_text_color=None + input_text_color=None + scrollbar_color=None, text_color=None + debug_win_size=(None,None) + window_location=(None,None) Explanation of parameters @@ -1290,6 +1452,8 @@ Explanation of parameters element_background_color - Background color of the elements text_element_background_color - Text element background color input_elements_background_color - Input fields background color + element_text_color - Text color of elements that have text, like Radio Buttons + input_text_color - Color of the text that you type in scrollbar_color - Color for scrollbars (may not always work) text_color - Text element default text color text_justification - justification to use on Text Elements. Values are strings - 'left', 'right', 'center' @@ -1314,7 +1478,7 @@ When do you use a non-blocking form? A couple of examples are * Progress Meters - when you want to make your own progress meters * Output using print to a scrolled text element. Good for debugging. -Word of warning... version 2.2, the currently released, and upcoming version 2.3 differ in the return code for the `ReadNonBlocking` call. Previously the function returned 2 values, except when the form is closed using the "X" which returned a single value of `None`. The *new* way is that `ReadNonBlocking` always returns 2 values. If the user closed the form with the "X" then the return values will be None, None. You will want to key off the second value to catch this case. +Word of warning... starting with version 2.2 there is a change in the return values from the`ReadNonBlocking` call. Previously the function returned 2 values, except when the form is closed using the "X" which returned a single value of `None`. The *new* way is that `ReadNonBlocking` always returns 2 values. If the user closed the form with the "X" then the return values will be None, None. You will want to key off the second value to catch this case. The proper code to check if the user has exited the form will be a polling-loop that looks something like this: while True: @@ -1393,13 +1557,19 @@ That's it... this example follows the async design pattern well. ## Sample Applications Use the example programs as a starting basis for your GUI. Copy, paste, modify and run! The demo files are: -`Demo Recipes.py` - Sample forms for all major form types and situations. This is the place to get your code template from. Includes asynchronous forms, etc. +`Demo_Recipes.py` - Sample forms for all major form types and situations. This is the place to get your code template from. Includes asynchronous forms, etc. Start here! + +`Demo_Compare_Files` - Takes 2 filenames as input. Does a byte for byte compare and returns the results. + + `Demo_Dictionary` - Simple form demonstrating how return values in dictionary form work. -`Demo DisplayHash1and256.py` - Demonstrates using High Level API calls to get a filename + `Demo_DisplayHash1and256` - Presents 3 methods of gathering the same user input using both high-level APIs and lower-level. -`Demo DupliucateFileFinder.py` - Demonstrates High Level API to get a folder & Easy Progress Meter to show progress of the file scanning +Demo_Func_Callback_Simulation - Shows how callback functions can be simulated. This is particularly good for the Raspberry Pi and other embedded type applications. -`Demo HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program could forever change how you code. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. If anyone wants to help me package this application up, I could use a hand. +`Demo_DuplicateFileFinder.py` - Demonstrates High Level API to get a folder & Easy Progress Meter to show progress of the file scanning + +`Demo_HowDoI.py` - An amazing little application. Acts as a front-end to HowDoI. This one program **could forever change how you code**. It does searches on Stack Overflow and returns the CODE found in the best answer for your query. If anyone wants to help me package this application up and release as a standalone application, then speak up on the GitHub! ## Fun Stuff Here are some things to try if you're bored or want to further customize @@ -1416,6 +1586,22 @@ This will turn all of your print statements into prints that display in a window **Look and Feel** Dial in the look and feel that you like with the `SetOptions` function. You can change all of the defaults in one function call. One line of code to customize the entire GUI. +Or beginning in version 2.9 you can choose from a look and feel using pre-defined color schemes. Call ChangeLookAndFeel with a description string. + + sg.ChangeLookAndFeel('GreenTan') + +Valid values for the description string are: + + GreenTan + LightGreen + BluePurple + Purple + BlueMono + GreenMono + BrownBlue + BrightColors + TealMono + **ObjToString** Ever wanted to easily display an objects contents easily? Use ObjToString to get a nicely formatted recursive walk of your objects. @@ -1469,7 +1655,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ | 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting | 2.8.0 | Aug 9, 2018 - New None default option for Checkbox element, text color option for all elements, return values as a dictionary, setting focus, binding return key -| 2.9.0 | Aug XX,2018 - Screen flash fix, do_not_clear input field option, +| 2.9.0 | Aug XX,2018 - Screen flash fix, `do_not_clear` input field option, `autosize_text` defaults to `True` now, return values as ordered dict, removed text target from progress bar, rework of return values and initial return values, removed legacy Form.Refresh() method (replaced by Form.ReadNonBlockingForm()), COLUMN elements!!, ### Release Notes @@ -1521,6 +1707,9 @@ In Python, functions behave just like object. When you're placing a Text Element **Lists** It seemed quite natural to use Python's powerful list constructs when possible. The form is specified as a series of lists. Each "row" of the GUI is represented as a list of Elements. When the form read returns the results to the user, all of the results are presented as a single list. This makes reading a form's values super-simple to do in a single line of Python code. +**Dictionaries** +Want to view your form's results as a dictionary instead of a list... no problem, just use the `key` keyword on your elements. For complex forms with a lot of values that need to be changed frequently, this is by far the best way of consuming the results. + ## Authors MikeTheWatchGuy @@ -1533,6 +1722,7 @@ GNU Lesser General Public License (LGPL 3) + * Jorj McKie was the motivator behind the entire project. His wxsimpleGUI concepts sparked PySimpleGUI into existence * [Fredrik Lundh](https://wiki.python.org/moin/FredrikLundh) for his work on `tkinter` +* [Ruud van der Ham](https://forum.pythonistacafe.com/u/Ruud) for all the help he's provided as a Python-mentor. Quite a few tricky bits of logic was supplied by Ruud. The dual-purpose return values scheme is Ruud's for example ## How Do I @@ -1548,7 +1738,7 @@ Here are the steps to run that application To run it: Python HowDoI.py -The pip command is all there is to the setup. +The pip command is all there is to the setup. The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. @@ -1556,4 +1746,5 @@ For Python questions, I simply start my query with 'Python'. Let's say you forg In the hands of a competent programmer, this tool is **amazing**. It's a must-try kind of program that has completely changed my programming process. I'm not afraid of asking for help! You just have to be smart about using what you find. -The PySimpleGUI window that the results are shown in is an 'input' field which means you can copy and paste the results right into your code. \ No newline at end of file +The PySimpleGUI window that the results are shown in is an 'input' field which means you can copy and paste the results right into your code. + From 7295d34df83a33d60b26c67274bf4dbb6946f34e Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 16 Aug 2018 14:16:06 -0400 Subject: [PATCH 145/209] Release of Column support --- Demo_Columns.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Demo_Columns.py diff --git a/Demo_Columns.py b/Demo_Columns.py new file mode 100644 index 000000000..ededa3f66 --- /dev/null +++ b/Demo_Columns.py @@ -0,0 +1,24 @@ +import PySimpleGUI as sg + +# Demo of how columns work +# Form has on row 1 a vertical slider followed by a COLUMN with 7 rows +# Prior to the Column element, this layout was not possible +# Columns layouts look identical to form layouts, they are a list of lists of elements. + +# sg.ChangeLookAndFeel('BlueMono') + +# Column layout +col = [[sg.Text('col Row 1', text_color='white', background_color='blue')], + [sg.Text('col Row 2', text_color='white', background_color='blue'), sg.Input('col input 1')], + [sg.Text('col Row 3', text_color='white', background_color='blue'), sg.Input('col input 2')]] + +layout = [[sg.Listbox(values=('Listbox Item 1', 'Listbox Item 2', 'Listbox Item 3'), select_mode=sg.LISTBOX_SELECT_MODE_MULTIPLE, size=(20,3)), sg.Column(col, background_color='blue')], + [sg.Input('Last input')], + [sg.OK()]] + +# Display the form and get values +# If you're willing to not use the "context manager" design pattern, then it's possible +# to collapse the form display and read down to a single line of code. +button, values = sg.FlexForm('Compact 1-line form with column').LayoutAndRead(layout) + +sg.MsgBox(button, values, line_width=200) From 523467f7899e29a2011f12f9dae43dfa74703784 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 16 Aug 2018 17:01:26 -0400 Subject: [PATCH 146/209] Columns, single-line GUI --- docs/cookbook.md | 98 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/docs/cookbook.md b/docs/cookbook.md index 8052b7d48..4b86c222c 100644 --- a/docs/cookbook.md +++ b/docs/cookbook.md @@ -273,6 +273,7 @@ The architecture of some programs works better with button callbacks instead of ## Realtime Buttons (Good For Raspberry Pi) This recipe implements a remote control interface for a robot. There are 4 directions, forward, reverse, left, right. When a button is clicked, PySimpleGUI immediately returns button events for as long as the buttons is held down. When released, the button events stop. This is an async/non-blocking form. +![robot control](https://user-images.githubusercontent.com/13696193/44006710-d227f23e-9e56-11e8-89a3-2be5b2726199.jpg) import PySimpleGUI as sg @@ -310,12 +311,14 @@ This recipe implements a remote control interface for a robot. There are 4 dire ## Easy Progress Meter This recipe shows just how easy it is to add a progress meter to your code. +![progress meter 6](https://user-images.githubusercontent.com/13696193/43955982-73b33b38-9c70-11e8-8b07-cc1473a58a73.jpg) + import PySimpleGUI as sg for i in range(1000): sg.EasyProgressMeter('Easy Meter Example', i+1, 1000) -![progress meter 6](https://user-images.githubusercontent.com/13696193/43955982-73b33b38-9c70-11e8-8b07-cc1473a58a73.jpg) + ----- ## Tabbed Form Tabbed forms are **easy** to make and use in PySimpleGUI. You simple may your layouts for each tab and then instead of `LayoutAndRead` you call `ShowTabbedForm`. Results are returned as a list of form results. Each tab acts like a single form. @@ -497,3 +500,96 @@ A standard non-blocking GUI with lots of inputs. [sg.Submit(), sg.Cancel()]] button, values = form.LayoutAndRead(layout) + +------- +## Custom Progress Meter / Progress Bar +Perhaps you don't want all the statistics that the EasyProgressMeter provides and want to create your own progress bar. Use this recipe to do just that. + +![custom progress meter](https://user-images.githubusercontent.com/13696193/43982958-3393b23e-9cc6-11e8-8b49-e7f4890cbc4b.jpg) + + + import PySimpleGUI as sg + + def CustomMeter(): + # create the progress bar element + progress_bar = sg.ProgressBar(10000, orientation='h', size=(20,20)) + # layout the form + layout = [[sg.Text('A custom progress meter')], + [progress_bar], + [sg.Cancel()]] + + # create the form + form = sg.FlexForm('Custom Progress Meter') + # display the form as a non-blocking form + form.LayoutAndRead(layout, non_blocking=True) + # loop that would normally do something useful + for i in range(10000): + # check to see if the cancel button was clicked and exit loop if clicked + button, values = form.ReadNonBlocking() + if button == 'Cancel' or values == None: + break + # update bar with loop value +1 so that bar eventually reaches the maximum + progress_bar.UpdateBar(i+1) + # done with loop... need to destroy the window as it's still open + form.CloseNonBlockingForm() + + ---- + + ## The One-Line GUI + +For those of you into super-compact code, a complete customized GUI can be specified, shown, and received the results using a single line of Python code. The way this is done is to combine the call to `FlexForm` and the call to `LayoutAndRead`. `FlexForm` returns a `FlexForm` object which has the `LayoutAndRead` method. + + +![simple](https://user-images.githubusercontent.com/13696193/44227935-ecb53b80-a161-11e8-968b-b3f963404dec.jpg) + + +Instead of + + import PySimpleGUI as sg + + layout = [[sg.Text('Filename')], + [sg.Input(), sg.FileBrowse()], + [sg.OK(), sg.Cancel()] ] + + button, (number,) = sg.FlexForm('Get filename example').LayoutAndRead(layout) + +you can write this line of code for the exact same result (OK, two lines with the import): + + import PySimpleGUI as sg + + button, (filename,) = sg.FlexForm('Get filename example'). LayoutAndRead([[sg.Text('Filename')], [sg.Input(), sg.FileBrowse()], [sg.OK(), sg.Cancel()] ]) +-------------------- +## Multiple Columns +Starting in version 2.9 (not yet released but you can get from current GitHub) you can use the Column Element. A Column is required when you have a tall element to the left of smaller elements. + +This example uses a Column. There is a Listbox on the left that is 3 rows high. To the right of it are 3 single rows of text and input. These 3 rows are in a Column Element. + +To make it easier to see the Column in the window, the Column background has been shaded blue. The code is wordier than normal due to the blue shading. Each element in the column needs to have the color set to match blue background. + +![snap0202](https://user-images.githubusercontent.com/13696193/44234671-27749f00-a175-11e8-9e66-a3fccf6c077e.jpg) + + + import PySimpleGUI as sg + + # Demo of how columns work + # Form has on row 1 a vertical slider followed by a COLUMN with 7 rows + # Prior to the Column element, this layout was not possible + # Columns layouts look identical to form layouts, they are a list of lists of elements. + + # sg.ChangeLookAndFeel('BlueMono') + + # Column layout + col = [[sg.Text('col Row 1', text_color='white', background_color='blue')], + [sg.Text('col Row 2', text_color='white', background_color='blue'), sg.Input('col input 1')], + [sg.Text('col Row 3', text_color='white', background_color='blue'), sg.Input('col input 2')]] + + layout = [[sg.Listbox(values=('Listbox Item 1', 'Listbox Item 2', 'Listbox Item 3'), select_mode=sg.LISTBOX_SELECT_MODE_MULTIPLE, size=(20,3)), sg.Column(col, background_color='blue')], + [sg.Input('Last input')], + [sg.OK()]] + + # Display the form and get values + # If you're willing to not use the "context manager" design pattern, then it's possible + # to collapse the form display and read down to a single line of code. + button, values = sg.FlexForm('Compact 1-line form with column').LayoutAndRead(layout) + + sg.MsgBox(button, values, line_width=200) From b0393723471358729a1bb225a8a6a0bd20fca2a9 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 16 Aug 2018 17:07:45 -0400 Subject: [PATCH 147/209] Columns, one-line GUI --- docs/cookbook.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/docs/cookbook.md b/docs/cookbook.md index 15cb14a30..4b86c222c 100644 --- a/docs/cookbook.md +++ b/docs/cookbook.md @@ -535,4 +535,61 @@ Perhaps you don't want all the statistics that the EasyProgressMeter provides an ---- + ## The One-Line GUI +For those of you into super-compact code, a complete customized GUI can be specified, shown, and received the results using a single line of Python code. The way this is done is to combine the call to `FlexForm` and the call to `LayoutAndRead`. `FlexForm` returns a `FlexForm` object which has the `LayoutAndRead` method. + + +![simple](https://user-images.githubusercontent.com/13696193/44227935-ecb53b80-a161-11e8-968b-b3f963404dec.jpg) + + +Instead of + + import PySimpleGUI as sg + + layout = [[sg.Text('Filename')], + [sg.Input(), sg.FileBrowse()], + [sg.OK(), sg.Cancel()] ] + + button, (number,) = sg.FlexForm('Get filename example').LayoutAndRead(layout) + +you can write this line of code for the exact same result (OK, two lines with the import): + + import PySimpleGUI as sg + + button, (filename,) = sg.FlexForm('Get filename example'). LayoutAndRead([[sg.Text('Filename')], [sg.Input(), sg.FileBrowse()], [sg.OK(), sg.Cancel()] ]) +-------------------- +## Multiple Columns +Starting in version 2.9 (not yet released but you can get from current GitHub) you can use the Column Element. A Column is required when you have a tall element to the left of smaller elements. + +This example uses a Column. There is a Listbox on the left that is 3 rows high. To the right of it are 3 single rows of text and input. These 3 rows are in a Column Element. + +To make it easier to see the Column in the window, the Column background has been shaded blue. The code is wordier than normal due to the blue shading. Each element in the column needs to have the color set to match blue background. + +![snap0202](https://user-images.githubusercontent.com/13696193/44234671-27749f00-a175-11e8-9e66-a3fccf6c077e.jpg) + + + import PySimpleGUI as sg + + # Demo of how columns work + # Form has on row 1 a vertical slider followed by a COLUMN with 7 rows + # Prior to the Column element, this layout was not possible + # Columns layouts look identical to form layouts, they are a list of lists of elements. + + # sg.ChangeLookAndFeel('BlueMono') + + # Column layout + col = [[sg.Text('col Row 1', text_color='white', background_color='blue')], + [sg.Text('col Row 2', text_color='white', background_color='blue'), sg.Input('col input 1')], + [sg.Text('col Row 3', text_color='white', background_color='blue'), sg.Input('col input 2')]] + + layout = [[sg.Listbox(values=('Listbox Item 1', 'Listbox Item 2', 'Listbox Item 3'), select_mode=sg.LISTBOX_SELECT_MODE_MULTIPLE, size=(20,3)), sg.Column(col, background_color='blue')], + [sg.Input('Last input')], + [sg.OK()]] + + # Display the form and get values + # If you're willing to not use the "context manager" design pattern, then it's possible + # to collapse the form display and read down to a single line of code. + button, values = sg.FlexForm('Compact 1-line form with column').LayoutAndRead(layout) + + sg.MsgBox(button, values, line_width=200) From 6b8729af4c230f299adaa6a1fab8a58e44e9167a Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 16 Aug 2018 17:12:25 -0400 Subject: [PATCH 148/209] Header typo --- docs/cookbook.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cookbook.md b/docs/cookbook.md index 4b86c222c..61e581c04 100644 --- a/docs/cookbook.md +++ b/docs/cookbook.md @@ -535,7 +535,7 @@ Perhaps you don't want all the statistics that the EasyProgressMeter provides an ---- - ## The One-Line GUI +## The One-Line GUI For those of you into super-compact code, a complete customized GUI can be specified, shown, and received the results using a single line of Python code. The way this is done is to combine the call to `FlexForm` and the call to `LayoutAndRead`. `FlexForm` returns a `FlexForm` object which has the `LayoutAndRead` method. From 5b78f655bfef921d967c181e59ccd633f5456d34 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 16 Aug 2018 18:17:13 -0400 Subject: [PATCH 149/209] Version 2.9 --- PySimpleGUI.py | 386 +++---------------------------------------------- docs/index.md | 11 +- readme.md | 11 +- 3 files changed, 34 insertions(+), 374 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index dda7640a9..925130a09 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -269,7 +269,7 @@ def __init__(self, values, select_mode=None, scale=(None, None), size=(None, Non ''' Listbox Element :param values: - :param select_mode: + :param select_mode: SELECT_MODE_BROWSE, SELECT_MODE_EXTENDED, SELECT_MODE_MULTIPLE, SELECT_MODE_SINGLE :param font: :param scale: Adds multiplier to size (w,h) :param size: Size of field in characters @@ -791,6 +791,7 @@ def __init__(self, layout, background_color = None): self.Rows = [] self.ParentForm = None self.TKFrame = None + bg = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR self.Layout(layout) @@ -1058,11 +1059,11 @@ def __del__(self): # ====================================================================== # # ------------------------- INPUT TEXT Element lazy functions ------------------------- # -def In(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, do_not_clear=False, focus=False, key=None): - return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, do_not_clear = do_not_clear, focus=focus, key=key) +def In(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None, text_color=None, do_not_clear=False, key=None, focus=False): + return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, password_char=password_char, background_color=background_color, text_color=text_color, do_not_clear=do_not_clear, focus=focus, key=key) -def Input(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, do_not_clear = False, focus=False, key=None): - return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, do_not_clear=do_not_clear, focus=focus, key=key) +def Input(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None, text_color=None, do_not_clear=False, key=None, focus=False): + return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, password_char=password_char, background_color=background_color, text_color=text_color, do_not_clear=do_not_clear, focus=focus, key=key) # ------------------------- INPUT COMBO Element lazy functions ------------------------- # def Combo(values, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None): @@ -1311,7 +1312,7 @@ def CharWidthInPixels(): col_frame = tk.Frame(tk_row_frame) PackFormIntoFrame(element, col_frame, toplevel_form) col_frame.pack(side=tk.LEFT) - if element.BackgroundColor is not None: + if element.BackgroundColor != COLOR_SYSTEM_DEFAULT and element.BackgroundColor is not None: col_frame.configure(background=element.BackgroundColor, highlightbackground=element.BackgroundColor, highlightcolor=element.BackgroundColor) # ------------------------- TEXT element ------------------------- # elif element_type == ELEM_TYPE_TEXT: @@ -1630,359 +1631,6 @@ def ConvertFlexToTK(MyFlexForm): master.update_idletasks() # don't forget return -def ConvertFlexToTKOld(MyFlexForm): - def CharWidthInPixels(): - return tkinter.font.Font().measure('A') # single character width - master = MyFlexForm.TKroot - # only set title on non-tabbed forms - if not MyFlexForm.IsTabbedForm: - master.title(MyFlexForm.Title) - font = MyFlexForm.Font - InitializeResults(MyFlexForm) - border_depth = MyFlexForm.BorderDepth if MyFlexForm.BorderDepth is not None else DEFAULT_BORDER_WIDTH - # --------------------------------------------------------------------------- # - # **************** Use FlexForm to build the tkinter window ********** ----- # - # Building is done row by row. # - # --------------------------------------------------------------------------- # - focus_set = False - ######################### LOOP THROUGH ROWS ######################### - # *********** ------- Loop through ROWS ------- ***********# - for row_num, flex_row in enumerate(MyFlexForm.Rows): - ######################### LOOP THROUGH ELEMENTS ON ROW ######################### - # *********** ------- Loop through ELEMENTS ------- ***********# - # *********** Make TK Row ***********# - tk_row_frame = tk.Frame(master) - for col_num, element in enumerate(flex_row): - element.ParentForm = MyFlexForm # save the button's parent form object - if MyFlexForm.Font and (element.Font == DEFAULT_FONT or not element.Font): - font = MyFlexForm.Font - elif element.Font is not None: - font = element.Font - # ------- Determine Auto-Size setting on a cascading basis ------- # - if element.AutoSizeText is not None: # if element overide - auto_size_text = element.AutoSizeText - elif MyFlexForm.AutoSizeText is not None: # if form override - auto_size_text = MyFlexForm.AutoSizeText - else: - auto_size_text = DEFAULT_AUTOSIZE_TEXT - # Determine Element size - element_size = element.Size - if (element_size == (None, None)): # user did not specify a size - element_size = MyFlexForm.DefaultElementSize - else: auto_size_text = False # if user has specified a size then it shouldn't autosize - # Apply scaling... Element scaling is higher priority than form level - if element.Scale != (None, None): - element_size = (int(element_size[0] * element.Scale[0]), int(element_size[1] * element.Scale[1])) - elif MyFlexForm.Scale != (None, None): - element_size = (int(element_size[0] * MyFlexForm.Scale[0]), int(element_size[1] * MyFlexForm.Scale[1])) - # Set foreground color - text_color = element.TextColor - # ------------------------- TEXT element ------------------------- # - element_type = element.Type - if element_type == ELEM_TYPE_TEXT: - display_text = element.DisplayText # text to display - if auto_size_text is False: - width, height=element_size - else: - lines = display_text.split('\n') - max_line_len = max([len(l) for l in lines]) - num_lines = len(lines) - if max_line_len > element_size[0]: # if text exceeds element size, the will have to wrap - width = element_size[0] - else: - width=max_line_len - height=num_lines - # ---===--- LABEL widget create and place --- # - stringvar = tk.StringVar() - element.TKStringVar = stringvar - stringvar.set(display_text) - if auto_size_text: - width = 0 - justify = tk.LEFT if element.Justification == 'left' else tk.CENTER if element.Justification == 'center' else tk.RIGHT - anchor = tk.NW if element.Justification == 'left' else tk.N if element.Justification == 'center' else tk.NE - tktext_label = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height, justify=justify, bd=border_depth) - # tktext_label = tk.Label(tk_row_frame,anchor=tk.NW, text=display_text, width=width, height=height, justify=tk.LEFT, bd=border_depth) - # Set wrap-length for text (in PIXELS) == PAIN IN THE ASS - wraplen = tktext_label.winfo_reqwidth() # width of widget in Pixels - tktext_label.configure(anchor=anchor, font=font, wraplen=wraplen*2 ) # set wrap to width of widget - if element.BackgroundColor is not None: - tktext_label.configure(background=element.BackgroundColor) - if element.TextColor != COLOR_SYSTEM_DEFAULT and element.TextColor is not None: - tktext_label.configure(fg=element.TextColor) - - tktext_label.pack(side=tk.LEFT) - # ------------------------- BUTTON element ------------------------- # - elif element_type == ELEM_TYPE_BUTTON: - element.Location = (row_num, col_num) - btext = element.ButtonText - btype = element.BType - if element.AutoSizeButton is not None: - auto_size = element.AutoSizeButton - else: auto_size = MyFlexForm.AutoSizeButtons - if auto_size is False: width=element_size[0] - else: width = 0 - height=element_size[1] - lines = btext.split('\n') - max_line_len = max([len(l) for l in lines]) - num_lines = len(lines) - if element.ButtonColor != (None, None)and element.ButtonColor != DEFAULT_BUTTON_COLOR: - bc = element.ButtonColor - elif MyFlexForm.ButtonColor != (None, None) and MyFlexForm.ButtonColor != DEFAULT_BUTTON_COLOR: - bc = MyFlexForm.ButtonColor - else: - bc = DEFAULT_BUTTON_COLOR - border_depth = element.BorderWidth - if btype != BUTTON_TYPE_REALTIME: - tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height,command=element.ButtonCallBack, justify=tk.LEFT, bd=border_depth) - else: - tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height, justify=tk.LEFT, bd=border_depth) - tkbutton.bind('', element.ButtonReleaseCallBack) - tkbutton.bind('', element.ButtonPressCallBack) - if bc != (None, None) and bc != COLOR_SYSTEM_DEFAULT: - tkbutton.config(foreground=bc[0], background=bc[1]) - element.TKButton = tkbutton # not used yet but save the TK button in case - wraplen = tkbutton.winfo_reqwidth() # width of widget in Pixels - if element.ImageFilename: # if button has an image on it - photo = tk.PhotoImage(file=element.ImageFilename) - if element.ImageSize != (None, None): - width, height = element.ImageSize - if element.ImageSubsample: - photo = photo.subsample(element.ImageSubsample) - else: - width, height = photo.width(), photo.height() - tkbutton.config(image=photo, width=width, height=height) - tkbutton.image = photo - tkbutton.configure(wraplength=wraplen+10, font=font) # set wrap to width of widget - tkbutton.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) - if element.Focus is True or (MyFlexForm.UseDefaultFocus and not focus_set): - focus_set = True - element.TKButton.bind('', element.ReturnKeyHandler) - element.TKButton.focus_set() - MyFlexForm.TKroot.focus_force() - # ------------------------- INPUT (Single Line) element ------------------------- # - elif element_type == ELEM_TYPE_INPUT_TEXT: - default_text = element.DefaultText - element.TKStringVar = tk.StringVar() - element.TKStringVar.set(default_text) - show = element.PasswordCharacter if element.PasswordCharacter else "" - element.TKEntry = tk.Entry(tk_row_frame, width=element_size[0], textvariable=element.TKStringVar, bd=border_depth, font=font, show=show) - element.TKEntry.bind('', element.ReturnKeyHandler) - if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: - element.TKEntry.configure(background=element.BackgroundColor) - if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: - element.TKEntry.configure(fg=text_color) - element.TKEntry.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) - if element.Focus is True or (MyFlexForm.UseDefaultFocus and not focus_set): - focus_set = True - element.TKEntry.focus_set() - # ------------------------- COMBO BOX (Drop Down) element ------------------------- # - elif element_type == ELEM_TYPE_INPUT_COMBO: - max_line_len = max([len(str(l)) for l in element.Values]) - if auto_size_text is False: width=element_size[0] - else: width = max_line_len - element.TKStringVar = tk.StringVar() - if element.BackgroundColor and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: - combostyle = ttk.Style() - try: - combostyle.theme_create('combostyle', - settings={'TCombobox': - {'configure': - {'selectbackground': element.BackgroundColor, - 'fieldbackground': element.BackgroundColor, - 'foreground': text_color, - 'background': element.BackgroundColor} - }}) - except: - try: - combostyle.theme_settings('combostyle', - settings={'TCombobox': - {'configure': - {'selectbackground': element.BackgroundColor, - 'fieldbackground': element.BackgroundColor, - 'foreground': text_color, - 'background': element.BackgroundColor} - }}) - except: pass - # ATTENTION: this applies the new style 'combostyle' to all ttk.Combobox - combostyle.theme_use('combostyle') - element.TKCombo = ttk.Combobox(tk_row_frame, width=width, textvariable=element.TKStringVar,font=font ) - # element.TKCombo['state']='readonly' - element.TKCombo['values'] = element.Values - # if element.BackgroundColor is not None: - # element.TKCombo.configure(background=element.BackgroundColor) - element.TKCombo.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) - element.TKCombo.current(0) - # ------------------------- LISTBOX element ------------------------- # - elif element_type == ELEM_TYPE_INPUT_LISTBOX: - max_line_len = max([len(str(l)) for l in element.Values]) - if auto_size_text is False: width=element_size[0] - else: width = max_line_len - - element.TKStringVar = tk.StringVar() - element.TKListbox= tk.Listbox(tk_row_frame, height=element_size[1], width=width, selectmode=element.SelectMode, font=font) - for item in element.Values: - element.TKListbox.insert(tk.END, item) - element.TKListbox.selection_set(0,0) - if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: - element.TKListbox.configure(background=element.BackgroundColor) - if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: - element.TKListbox.configure(fg=text_color) - # vsb = tk.Scrollbar(tk_row_frame, orient="vertical", command=element.TKListbox.yview) - # element.TKListbox.configure(yscrollcommand=vsb.set) - element.TKListbox.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) - # vsb.pack(side=tk.LEFT, fill='y') - # ------------------------- INPUT MULTI LINE element ------------------------- # - elif element_type == ELEM_TYPE_INPUT_MULTILINE: - default_text = element.DefaultText - width, height = element_size - element.TKText = tk.scrolledtext.ScrolledText(tk_row_frame, width=width, height=height, wrap='word', bd=border_depth,font=font) - element.TKText.insert(1.0, default_text) # set the default text - if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: - element.TKText.configure(background=element.BackgroundColor) - element.TKText.vbar.config(troughcolor=DEFAULT_SCROLLBAR_COLOR) - element.TKText.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) - if element.EnterSubmits: - element.TKText.bind('', element.ReturnKeyHandler) - if element.Focus is True or (MyFlexForm.UseDefaultFocus and not focus_set): - focus_set = True - element.TKText.focus_set() - if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: - element.TKText.configure(fg=text_color) - # ------------------------- INPUT CHECKBOX element ------------------------- # - elif element_type == ELEM_TYPE_INPUT_CHECKBOX: - width = 0 if auto_size_text else element_size[0] - default_value = element.InitialState - element.TKIntVar = tk.IntVar() - element.TKIntVar.set(default_value if default_value is not None else 0) - element.TKCheckbutton = tk.Checkbutton(tk_row_frame, anchor=tk.NW, text=element.Text, width=width, variable=element.TKIntVar, bd=border_depth, font=font) - if default_value is None: - element.TKCheckbutton.configure(state='disable') - if element.BackgroundColor is not None: - element.TKCheckbutton.configure(background=element.BackgroundColor) - if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: - element.TKCheckbutton.configure(fg=text_color) - element.TKCheckbutton.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) - # ------------------------- PROGRESS BAR element ------------------------- # - elif element_type == ELEM_TYPE_PROGRESS_BAR: - # save this form because it must be 'updated' (refreshed) solely for the purpose of updating bar - width = element_size[0] - fnt = tkinter.font.Font() - char_width = fnt.measure('A') # single character width - progress_length = width*char_width - progress_width = element_size[1] - direction = element.Orientation - if element.BarColor != (None, None): # if element has a bar color, use it - bar_color = element.BarColor - else: - bar_color = DEFAULT_PROGRESS_BAR_COLOR - element.TKProgressBar = TKProgressBar(tk_row_frame, element.MaxValue, progress_length, progress_width, orientation=direction, BarColor=bar_color, border_width=element.BorderWidth, relief=element.Relief, style=element.BarStyle ) - # element.TKProgressBar = TKProgressBar(tk_row_frame, element.MaxValue, progress_length, progress_width, orientation=direction, BarColor=bar_color, border_width=element.BorderWidth, relief=element.Relief) - element.TKProgressBar.TKProgressBarForReal.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) - # ------------------------- INPUT RADIO BUTTON element ------------------------- # - elif element_type == ELEM_TYPE_INPUT_RADIO: - width = 0 if auto_size_text else element_size[0] - default_value = element.InitialState - ID = element.GroupID - # see if ID has already been placed - value = EncodeRadioRowCol(row_num, col_num) # value to set intvar to if this radio is selected - if ID in MyFlexForm.RadioDict: - RadVar = MyFlexForm.RadioDict[ID] - else: - RadVar = tk.IntVar() - MyFlexForm.RadioDict[ID] = RadVar - element.TKIntVar = RadVar # store the RadVar in Radio object - if default_value: # if this radio is the one selected, set RadVar to match - element.TKIntVar.set(value) - element.TKRadio = tk.Radiobutton(tk_row_frame, anchor=tk.NW, text=element.Text, width=width, - variable=element.TKIntVar, value=value, bd=border_depth, font=font) - if element.BackgroundColor is not None: - element.TKRadio.configure(background=element.BackgroundColor) - if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: - element.TKRadio.configure(fg=text_color) - element.TKRadio.pack(side=tk.LEFT, padx=element.Pad[0],pady=element.Pad[1]) - # ------------------------- INPUT SPIN Box element ------------------------- # - elif element_type == ELEM_TYPE_INPUT_SPIN: - width, height = element_size - width = 0 if auto_size_text else element_size[0] - element.TKStringVar = tk.StringVar() - element.TKSpinBox = tk.Spinbox(tk_row_frame, values=element.Values, textvariable=element.TKStringVar, width=width, bd=border_depth) - element.TKStringVar.set(element.DefaultValue) - element.TKSpinBox.configure(font=font) # set wrap to width of widget - if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: - element.TKSpinBox.configure(background=element.BackgroundColor) - element.TKSpinBox.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) - if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: - element.TKSpinBox.configure(fg=text_color) - # ------------------------- OUTPUT element ------------------------- # - elif element_type == ELEM_TYPE_OUTPUT: - width, height = element_size - element.TKOut = TKOutput(tk_row_frame, width=width, height=height, bd=border_depth, background_color=element.BackgroundColor, text_color=text_color) - element.TKOut.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) - # ------------------------- IMAGE Box element ------------------------- # - elif element_type == ELEM_TYPE_IMAGE: - photo = tk.PhotoImage(file=element.Filename) - if element_size == (None, None) or element_size == None or element_size == MyFlexForm.DefaultElementSize: - width, height = photo.width(), photo.height() - else: - width, height = element_size - tktext_label = tk.Label(tk_row_frame, image=photo, width=width, height=height, bd=border_depth) - tktext_label.image = photo - # tktext_label.configure(anchor=tk.NW, image=photo) - tktext_label.pack(side=tk.LEFT) - # ------------------------- SLIDER Box element ------------------------- # - elif element_type == ELEM_TYPE_INPUT_SLIDER: - slider_length = element_size[0] * CharWidthInPixels() - slider_width = element_size[1] - element.TKIntVar = tk.IntVar() - element.TKIntVar.set(element.DefaultValue) - if element.Orientation[0] == 'v': - range_from = element.Range[1] - range_to = element.Range[0] - else: - range_from = element.Range[0] - range_to = element.Range[1] - tkscale = tk.Scale(tk_row_frame, orient=element.Orientation, variable=element.TKIntVar, from_=range_from, to_=range_to, length=slider_length, width=slider_width , bd=element.BorderWidth, relief=element.Relief, font=font) - # tktext_label.configure(anchor=tk.NW, image=photo) - if element.BackgroundColor is not None: - tkscale.configure(background=element.BackgroundColor) - tkscale.config(troughcolor=DEFAULT_SCROLLBAR_COLOR) - if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: - tkscale.configure(fg=text_color) - tkscale.pack(side=tk.LEFT) - #............................DONE WITH ROW pack the row of widgets ..........................# - # done with row, pack the row of widgets - tk_row_frame.grid(row=row_num+2, sticky=tk.W, padx=DEFAULT_MARGINS[0]) - if MyFlexForm.BackgroundColor is not None: - tk_row_frame.configure(background=MyFlexForm.BackgroundColor) - if not MyFlexForm.IsTabbedForm: - MyFlexForm.TKroot.configure(padx=DEFAULT_MARGINS[0], pady=DEFAULT_MARGINS[1]) - else: MyFlexForm.ParentWindow.configure(padx=DEFAULT_MARGINS[0], pady=DEFAULT_MARGINS[1]) - #....................................... DONE creating and laying out window ..........................# - if MyFlexForm.IsTabbedForm: - master = MyFlexForm.ParentWindow - master.attributes('-alpha', 0) # hide window while getting info and moving - screen_width = master.winfo_screenwidth() # get window info to move to middle of screen - screen_height = master.winfo_screenheight() - if MyFlexForm.Location != (None, None): - x,y = MyFlexForm.Location - elif DEFAULT_WINDOW_LOCATION != (None, None): - x,y = DEFAULT_WINDOW_LOCATION - else: - master.update_idletasks() # don't forget - win_width = master.winfo_width() - win_height = master.winfo_height() - x = screen_width/2 -win_width/2 - y = screen_height/2 - win_height/2 - if y+win_height > screen_height: - y = screen_height-win_height - if x+win_width > screen_width: - x = screen_width-win_width - - move_string = '+%i+%i'%(int(x),int(y)) - master.geometry(move_string) - master.attributes('-alpha', 255) # Make window visible again - master.update_idletasks() # don't forget - return # ----====----====----====----====----==== STARTUP TK ====----====----====----====----====----# def ShowTabbedForm(title, *args, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, fav_icon=DEFAULT_WINDOW_ICON): @@ -2815,13 +2463,23 @@ def ChangeLookAndFeel(index): 'GreenMono': {'BACKGROUND': '#A8C1B4', 'TEXT': 'black', 'INPUT': '#DDE0DE', 'SCROLL': '#E3E3E3','TEXT_INPUT' : 'black', 'BUTTON': ('white', '#6D9F85'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, - 'BrownBlue': {'BACKGROUND': '#64778d', 'TEXT': 'white', 'INPUT': '#f0f3f7', 'SCROLL': '#A6B2BE','TEXT_INPUT' : 'black', - 'BUTTON': ('white', '#283b5b'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, + 'BrownBlue': {'BACKGROUND': '#64778d', 'TEXT': 'white', 'INPUT': '#f0f3f7', 'SCROLL': '#A6B2BE','TEXT_INPUT' : 'black', 'BUTTON': ('white', '#283b5b'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, + + 'BrightColors': {'BACKGROUND': '#b4ffb4', 'TEXT': 'black', 'INPUT': '#ffff64','SCROLL': '#ffb482','TEXT_INPUT' : 'black', 'BUTTON': ('black', '#ffa0dc'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, + + 'NeutralBlue': {'BACKGROUND': '#92aa9d', 'TEXT': 'black', 'INPUT': '#fcfff6', + 'SCROLL': '#fcfff6', 'TEXT_INPUT': 'black', 'BUTTON': ('black', '#d0dbbd'), + 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, + + 'Kayak': {'BACKGROUND': '#a7ad7f', 'TEXT': 'black', 'INPUT': '#e6d3a8', + 'SCROLL': '#e6d3a8', 'TEXT_INPUT': 'black', 'BUTTON': ('white', '#5d907d'), + 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, - 'BrightColors': {'BACKGROUND': '#b4ffb4', 'TEXT': 'black', 'INPUT': '#ffff64','SCROLL': '#ffb482','TEXT_INPUT' : 'black', - 'BUTTON': ('black', '#ffa0dc'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, + 'SandyBeach': {'BACKGROUND': '#efeccb', 'TEXT': '#012f2f', 'INPUT': '#e6d3a8', + 'SCROLL': '#e6d3a8', 'TEXT_INPUT': '#012f2f', 'BUTTON': ('white', '#046380'), + 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, - 'TealMono': {'BACKGROUND': '#a8cfdd', 'TEXT': 'black', 'INPUT': '#dfedf2','SCROLL': '#dfedf2', 'TEXT_INPUT' : 'black', 'BUTTON': ('white', '#3b7f97'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR} + 'TealMono': {'BACKGROUND': '#a8cfdd', 'TEXT': 'black', 'INPUT': '#dfedf2','SCROLL': '#dfedf2', 'TEXT_INPUT' : 'black', 'BUTTON': ('white', '#183440'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR} } try: colors = look_and_feel[index] diff --git a/docs/index.md b/docs/index.md index 392287c2d..c22c0e5a8 100644 --- a/docs/index.md +++ b/docs/index.md @@ -8,7 +8,7 @@ # PySimpleGUI - (Ver 2.8) + (Ver 2.9) [Formatted ReadTheDocs Version of this Readme](http://pysimplegui.readthedocs.io/) @@ -1655,7 +1655,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ | 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting | 2.8.0 | Aug 9, 2018 - New None default option for Checkbox element, text color option for all elements, return values as a dictionary, setting focus, binding return key -| 2.9.0 | Aug XX,2018 - Screen flash fix, `do_not_clear` input field option, `autosize_text` defaults to `True` now, return values as ordered dict, removed text target from progress bar, rework of return values and initial return values, removed legacy Form.Refresh() method (replaced by Form.ReadNonBlockingForm()), COLUMN elements!!, +| 2.9.0 | Aug 16,2018 - Screen flash fix, `do_not_clear` input field option, `autosize_text` defaults to `True` now, return values as ordered dict, removed text target from progress bar, rework of return values and initial return values, removed legacy Form.Refresh() method (replaced by Form.ReadNonBlockingForm()), COLUMN elements!!, colored text defaults ### Release Notes @@ -1670,14 +1670,15 @@ New debug printing capability. `sg.Print` Listboxes are still without scrollwheels. The mouse can drag to see more items. The mouse scrollwheel will also scroll the list and will `page up` and `page down` keys. 2.7 Is the "feature complete" release. Pretty much all features are done and in the code + 2.8 More text color controls. The caller has more control over things like the focus and what buttons should be clicked when enter key is pressed. Return values as a dictionary! (NICE addition) +2.9 COLUMNS! This is the biggest feature and had the biggest impact on the code base. It was a difficult feature to add, but it was worth it. Can now make even more layouts. Almost any layout is possible with this addition. + ### Upcoming Make suggestions people! Future release features -Columns. How multiple columns would be specified in the SDK interface are still being designed. - Port to other graphic engines. Hook up the front-end interface to a backend other than tkinter. Qt, WxPython, etc. @@ -1738,7 +1739,7 @@ Here are the steps to run that application To run it: Python HowDoI.py -The pip command is all there is to the setup. +The pip command is all there is to the setup. The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. diff --git a/readme.md b/readme.md index 392287c2d..c22c0e5a8 100644 --- a/readme.md +++ b/readme.md @@ -8,7 +8,7 @@ # PySimpleGUI - (Ver 2.8) + (Ver 2.9) [Formatted ReadTheDocs Version of this Readme](http://pysimplegui.readthedocs.io/) @@ -1655,7 +1655,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ | 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting | 2.8.0 | Aug 9, 2018 - New None default option for Checkbox element, text color option for all elements, return values as a dictionary, setting focus, binding return key -| 2.9.0 | Aug XX,2018 - Screen flash fix, `do_not_clear` input field option, `autosize_text` defaults to `True` now, return values as ordered dict, removed text target from progress bar, rework of return values and initial return values, removed legacy Form.Refresh() method (replaced by Form.ReadNonBlockingForm()), COLUMN elements!!, +| 2.9.0 | Aug 16,2018 - Screen flash fix, `do_not_clear` input field option, `autosize_text` defaults to `True` now, return values as ordered dict, removed text target from progress bar, rework of return values and initial return values, removed legacy Form.Refresh() method (replaced by Form.ReadNonBlockingForm()), COLUMN elements!!, colored text defaults ### Release Notes @@ -1670,14 +1670,15 @@ New debug printing capability. `sg.Print` Listboxes are still without scrollwheels. The mouse can drag to see more items. The mouse scrollwheel will also scroll the list and will `page up` and `page down` keys. 2.7 Is the "feature complete" release. Pretty much all features are done and in the code + 2.8 More text color controls. The caller has more control over things like the focus and what buttons should be clicked when enter key is pressed. Return values as a dictionary! (NICE addition) +2.9 COLUMNS! This is the biggest feature and had the biggest impact on the code base. It was a difficult feature to add, but it was worth it. Can now make even more layouts. Almost any layout is possible with this addition. + ### Upcoming Make suggestions people! Future release features -Columns. How multiple columns would be specified in the SDK interface are still being designed. - Port to other graphic engines. Hook up the front-end interface to a backend other than tkinter. Qt, WxPython, etc. @@ -1738,7 +1739,7 @@ Here are the steps to run that application To run it: Python HowDoI.py -The pip command is all there is to the setup. +The pip command is all there is to the setup. The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. From 99ae29cd77a3f46e990b1179f303cbb9044f30db Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 18 Aug 2018 16:35:49 -0400 Subject: [PATCH 150/209] Tutorial checkin --- docs/tutorial.md | 253 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 253 insertions(+) create mode 100644 docs/tutorial.md diff --git a/docs/tutorial.md b/docs/tutorial.md new file mode 100644 index 000000000..51cb73c50 --- /dev/null +++ b/docs/tutorial.md @@ -0,0 +1,253 @@ +# Add GUIs to your programs and scripts easily with PySimpleGUI + +## Introduction +Python has dropped the GUI ball. While the rest of the world has been enjoying the use of a mouse, most Python programs continue to be accessed via the command line. Why is this, does anybody care, and what can be done about it? + +## GUI Frameworks +There is no shortage of GUI frameworks for Python. tkinter, WxPython, Qt, Kivy are a few of the major packages. In addition, there are a good number of dumbed down GUI packages that wrap one of the major packages. These include EasyGUI, PyGUI, Pyforms, ... + +The problem is that beginners (those with experience of less than 6 weeks) are not capable of learning even the simplest of the major packages. That leaves the wrapper-packages. Users will quickly find it difficult or impossible to build a custom GUI layout. Or, if it's possible, pages of code are still required. + +PySimpleGUI attempts to address these GUI challenges by providing a super-simple, easy to understand interface to GUIs that can be customized easily. Even the most complex of GUIs are often less than 20 lines of code when PySimpleGUI is used. + +## The Secret + +What makes PySimpleGUI superior for newcomers is that the package contains the majority of the code that the user is normally expected to write. Button callbacks are handled by PySimpleGUI, not the user's code. Beginners struggle to grasp the concept of a function, expecting them to understand a call-back function in the first few weeks is likely a stretch. + +With most GUIs arranging the GUI Widgets often requires several lines of code.... at least one or two lines per widget. PySimpleGUI uses an "auto-packer" that creates the layout for the user automatically. There is no concept of a pack nor a grid system needed to layout a GUI Window. + +Finally, PySimpleGUI leverages the Python language constructs in clever ways that shortens the amount of code and returns the GUI data in a straightforward manner. When a Widget is created in a form layout, it is configured in-place, not several lines of code away. + +## What is a GUI? + +Most GUIs do one thing.... they collect information from the user and return it. From a programmer's viewpoint this could be summed up as a function call that looks like this: + + button, values = GUI_Display(gui_layout) + +What's expected from most GUIs is the button that was clicked (OK, cancel, save, yes, no, etc), and the values that were input by the user. The essence of a GUI can be boiled down into a single line of code. + +This is exactly how PySimpleGUI works (for these simple kinds of GUIs). When the call is made to display the GUI, execution does no return until a button is clicked that closes the form. + +There are more complex GUIs such as those that don't close after a button is clicked. These complex forms can also be created with PySimpleGUI. A remote control interface for a robot and a chat window are a couple of examples. + +## The 5-Minute GUI + +When is PySimpleGUI useful? Immediately, anytime you've got a GUI need. It will take under 5 minutes for you to create and try your GUI. With those kinds of times, what do you have to lose trying it? + +The best way to go about making your GUI in under 5 minutes is to copy one of the GUIs from the [PySimpleGUI Cookbook](https://pysimplegui.readthedocs.io/en/latest/cookbook/). Follow these steps: +* Find a GUI that looks similar to what you want to create +* Copy code from Cookbook +* Paste into your IDE and run + +Let's look at the first recipe from the book + + import PySimpleGUI as sg + + # Very basic form. Return values as a list + form = sg.FlexForm('Simple data entry form') # begin with a blank form + + layout = [ + [sg.Text('Please enter your Name, Address, Phone')], + [sg.Text('Name', size=(15, 1)), sg.InputText()], + [sg.Text('Address', size=(15, 1)), sg.InputText()], + [sg.Text('Phone', size=(15, 1)), sg.InputText()], + [sg.Submit(), sg.Cancel()] + ] + + button, values = form.LayoutAndRead(layout) + + print(button, values[0], values[1], values[2]) + + +It's a reasonable sized form. + + +![super simple 2](https://user-images.githubusercontent.com/13696193/43934091-8100e29a-9c1b-11e8-8d0a-9bd2d13e6d8e.jpg) + +If you only need to collect a few values and they're all basically strings, then you would copy this recipe and modify it to suit your needs. + +## Making Your Custom GUI + +That 5-minute estimate wasn't the time it takes to copy and paste the code from the Cookbook. You should be able to modify the code within 5 minutes in order to get to your layout, assuming you've got a straightforward layout. + +Widgets are called Elements in PySimpleGUI. This list of Elements are spelled exactly as you would type it into your Python code. + +### Core Element list +``` + Text + InputText + Multiline + InputCombo + Listbox + Radio + Checkbox + Spin + Output + SimpleButton + RealtimeButton + ReadFormButton + ProgressBar + Image + Slider + Column +``` + +You can also have short-cut Elements. There are 2 types of shortcuts. One is simply other names for the exact same element (e.g. T instead of Text). The second type configures an Element with particular setting, sparing the programmer from specifying all of the parameters (e.g. Submit is a button with the text "Submit" on it). +### Shortcut list + + T = Text + Txt = Text + In = InputText + Input = IntputText + Combo = InputCombo + DropDown = InputCombo + Drop = InputCombo + +A number of common buttons have been implemented as shortcuts. These include: +### Button Shortcuts + FolderBrowse + FileBrowse + FileSaveAs + Save + Submit + OK + Ok + Cancel + Quit + Exit + Yes + No + +The more generic button functions, that are also shortcuts +### Generic Buttons + SimpleButton + ReadFormButton + RealtimeButton + +These are all of the GUI Widgets you have to choose from. If it's not in this list, it doesn't go in your form layout. + +### GUI Design Pattern + +The stuff that tends not to change in GUIs are the calls that setup and show the Window. It's the layout of the Elements that changes from one program to another. This is the code from above with the layout removed: + + import PySimpleGUI as sg + + form = sg.FlexForm('Simple data entry form') + # Define your form here (it's a list of lists) + button, values = form.LayoutAndRead(layout) + + The flow for most GUIs is: + * Create the Form object + * Define GUI as a list of lists + * Show the GUI and get results + +These are line for line what you see in design pattern. + +### GUI Layout + +To create your custom GUI, first break your form down into "rows". You'll be defining your form one row at a time. Then for each for, you'll be placing one Element after another, working from left to right. + +The result is a "list of lists" that looks something like this: + + layout = [ [Text('Row 1')], + [Text('Row 2'), Checkbox('Checkbox 1', OK()), Checkbox('Checkbox 2'), OK()] ] + +The layout produced this window: + +![tutorial2](https://user-images.githubusercontent.com/13696193/44302312-e5259c00-a2f3-11e8-9c17-63e4eb130a9e.jpg) + + +## Display GUI & Get Results + +Once you have your layout complete and you've copied over the lines of code that setup and show the form, it's time to look at how to display the form and get the values from the user. + +This is the line of code that displays the form and provides the results: + + button, values = form.LayoutAndRead(layout) + + Forms return 2 values, the text of the button that was clicked and a ***list of values*** the user entered into the form. + +If the example form was displayed and the user did nothing other than click the OK button, then the results would have been: + + button == 'OK' + values == [False, False] + +Checkbox Elements return a value of True/False. Because these checkboxes defaulted to unchecked, the values returned were both False. + +## Displaying Results + +Once you have the values from the GUI it would be nice to check what values are in the variables. Rather than print them out using a `print` statement, let's stick with the GUI idea and output to a window. + +PySimpleGUI has a number of Message Boxes to choose from. The data passed to the message box will be displayed in a window. The function takes any number of arguments. Simply indicate all the variables you would like to see in the call. + +The most-commonly used Message Box in PySimpleGUI is MsgBox. To display the results of the previous example, one would write: + + MsgBox('The GUI returned:', button, values) + +## Putting It All Together + +Now that you know the basics, let's put together a form that contains as many PySimpleGUI's elements as possible. Also, just to give it a nice look, we'll change the "look and feel" to a green and tan color scheme. + + import PySimpleGUI as sg + + sg.ChangeLookAndFeel('GreenTan') + + form = sg.FlexForm('Everything bagel', default_element_size=(40, 1)) + + column1 = [[sg.Text('Column 1', background_color='#d3dfda', justification='center', size=(10,1))], + [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 1')], + [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 2')], + [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 3')]] + layout = [ + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25))], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText('This is my text')], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text should you decide not to type anything', size=(35, 3)), + sg.Multiline(default_text='A second multi-line', size=(35, 3))], + [sg.InputCombo(('Combobox 1', 'Combobox 2'), size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85)], + [sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(30, 3)), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10), + sg.Column(column1, background_color='#d3dfda')], + [sg.Text('_' * 80)], + [sg.Text('Choose A Folder', size=(35, 1))], + [sg.Text('Your Folder', size=(15, 1), auto_size_text=False, justification='right'), + sg.InputText('Default Folder'), sg.FolderBrowse()], + [sg.Submit(), sg.Cancel()] + ] + + button, values = form.LayoutAndRead(layout) + sg.MsgBox(button, values) + +That may seem like a lot of code, but try coding this same GUI layout directly in tkinter and you'll quickly realize that the length is tiny. + +![everything for tutorial](https://user-images.githubusercontent.com/13696193/44302997-38531b00-a303-11e8-8c45-698ea62590a8.jpg) + +The last line of code opens a message box. This is how it looks: +![tutorial results](https://user-images.githubusercontent.com/13696193/44303004-79e3c600-a303-11e8-8311-2f3726d364ad.jpg) + +Each parameter to the message box call is displayed on a new line. There are actually 2 lines of text in the message box. The second line is very long and wrapped a number of times + +Take a moment and pair up the results values with the GUI to get an understanding of how results are created and returned. + +## Resources + +### Installation +Requires Python 3 + + pip install PySimpleGUI + +Works on all systems that run tkinter, including the Raspberry Pi + +### Documentation +[Main manual](https://pysimplegui.readthedocs.io/en/latest/) + +[Cookbook](https://pysimplegui.readthedocs.io/en/latest/cookbook/) + +### Home Page + +www.PySimpleGUI.com From 7392e06cea016678d0e670c63eb576c8dd7101de Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 18 Aug 2018 16:45:55 -0400 Subject: [PATCH 151/209] Fix formatting --- docs/tutorial.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/tutorial.md b/docs/tutorial.md index 51cb73c50..30fab5167 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -228,8 +228,10 @@ That may seem like a lot of code, but try coding this same GUI layout directly i ![everything for tutorial](https://user-images.githubusercontent.com/13696193/44302997-38531b00-a303-11e8-8c45-698ea62590a8.jpg) The last line of code opens a message box. This is how it looks: + ![tutorial results](https://user-images.githubusercontent.com/13696193/44303004-79e3c600-a303-11e8-8311-2f3726d364ad.jpg) + Each parameter to the message box call is displayed on a new line. There are actually 2 lines of text in the message box. The second line is very long and wrapped a number of times Take a moment and pair up the results values with the GUI to get an understanding of how results are created and returned. From cf9b11e75c316d8164eba0ca97938a8bf1630b06 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 18 Aug 2018 16:52:24 -0400 Subject: [PATCH 152/209] Pulling down current Master version --- PySimpleGUI.py | 386 +++---------------------------------------------- 1 file changed, 22 insertions(+), 364 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index dda7640a9..925130a09 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -269,7 +269,7 @@ def __init__(self, values, select_mode=None, scale=(None, None), size=(None, Non ''' Listbox Element :param values: - :param select_mode: + :param select_mode: SELECT_MODE_BROWSE, SELECT_MODE_EXTENDED, SELECT_MODE_MULTIPLE, SELECT_MODE_SINGLE :param font: :param scale: Adds multiplier to size (w,h) :param size: Size of field in characters @@ -791,6 +791,7 @@ def __init__(self, layout, background_color = None): self.Rows = [] self.ParentForm = None self.TKFrame = None + bg = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR self.Layout(layout) @@ -1058,11 +1059,11 @@ def __del__(self): # ====================================================================== # # ------------------------- INPUT TEXT Element lazy functions ------------------------- # -def In(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, do_not_clear=False, focus=False, key=None): - return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, do_not_clear = do_not_clear, focus=focus, key=key) +def In(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None, text_color=None, do_not_clear=False, key=None, focus=False): + return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, password_char=password_char, background_color=background_color, text_color=text_color, do_not_clear=do_not_clear, focus=focus, key=key) -def Input(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, do_not_clear = False, focus=False, key=None): - return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, do_not_clear=do_not_clear, focus=focus, key=key) +def Input(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None, text_color=None, do_not_clear=False, key=None, focus=False): + return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, password_char=password_char, background_color=background_color, text_color=text_color, do_not_clear=do_not_clear, focus=focus, key=key) # ------------------------- INPUT COMBO Element lazy functions ------------------------- # def Combo(values, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None): @@ -1311,7 +1312,7 @@ def CharWidthInPixels(): col_frame = tk.Frame(tk_row_frame) PackFormIntoFrame(element, col_frame, toplevel_form) col_frame.pack(side=tk.LEFT) - if element.BackgroundColor is not None: + if element.BackgroundColor != COLOR_SYSTEM_DEFAULT and element.BackgroundColor is not None: col_frame.configure(background=element.BackgroundColor, highlightbackground=element.BackgroundColor, highlightcolor=element.BackgroundColor) # ------------------------- TEXT element ------------------------- # elif element_type == ELEM_TYPE_TEXT: @@ -1630,359 +1631,6 @@ def ConvertFlexToTK(MyFlexForm): master.update_idletasks() # don't forget return -def ConvertFlexToTKOld(MyFlexForm): - def CharWidthInPixels(): - return tkinter.font.Font().measure('A') # single character width - master = MyFlexForm.TKroot - # only set title on non-tabbed forms - if not MyFlexForm.IsTabbedForm: - master.title(MyFlexForm.Title) - font = MyFlexForm.Font - InitializeResults(MyFlexForm) - border_depth = MyFlexForm.BorderDepth if MyFlexForm.BorderDepth is not None else DEFAULT_BORDER_WIDTH - # --------------------------------------------------------------------------- # - # **************** Use FlexForm to build the tkinter window ********** ----- # - # Building is done row by row. # - # --------------------------------------------------------------------------- # - focus_set = False - ######################### LOOP THROUGH ROWS ######################### - # *********** ------- Loop through ROWS ------- ***********# - for row_num, flex_row in enumerate(MyFlexForm.Rows): - ######################### LOOP THROUGH ELEMENTS ON ROW ######################### - # *********** ------- Loop through ELEMENTS ------- ***********# - # *********** Make TK Row ***********# - tk_row_frame = tk.Frame(master) - for col_num, element in enumerate(flex_row): - element.ParentForm = MyFlexForm # save the button's parent form object - if MyFlexForm.Font and (element.Font == DEFAULT_FONT or not element.Font): - font = MyFlexForm.Font - elif element.Font is not None: - font = element.Font - # ------- Determine Auto-Size setting on a cascading basis ------- # - if element.AutoSizeText is not None: # if element overide - auto_size_text = element.AutoSizeText - elif MyFlexForm.AutoSizeText is not None: # if form override - auto_size_text = MyFlexForm.AutoSizeText - else: - auto_size_text = DEFAULT_AUTOSIZE_TEXT - # Determine Element size - element_size = element.Size - if (element_size == (None, None)): # user did not specify a size - element_size = MyFlexForm.DefaultElementSize - else: auto_size_text = False # if user has specified a size then it shouldn't autosize - # Apply scaling... Element scaling is higher priority than form level - if element.Scale != (None, None): - element_size = (int(element_size[0] * element.Scale[0]), int(element_size[1] * element.Scale[1])) - elif MyFlexForm.Scale != (None, None): - element_size = (int(element_size[0] * MyFlexForm.Scale[0]), int(element_size[1] * MyFlexForm.Scale[1])) - # Set foreground color - text_color = element.TextColor - # ------------------------- TEXT element ------------------------- # - element_type = element.Type - if element_type == ELEM_TYPE_TEXT: - display_text = element.DisplayText # text to display - if auto_size_text is False: - width, height=element_size - else: - lines = display_text.split('\n') - max_line_len = max([len(l) for l in lines]) - num_lines = len(lines) - if max_line_len > element_size[0]: # if text exceeds element size, the will have to wrap - width = element_size[0] - else: - width=max_line_len - height=num_lines - # ---===--- LABEL widget create and place --- # - stringvar = tk.StringVar() - element.TKStringVar = stringvar - stringvar.set(display_text) - if auto_size_text: - width = 0 - justify = tk.LEFT if element.Justification == 'left' else tk.CENTER if element.Justification == 'center' else tk.RIGHT - anchor = tk.NW if element.Justification == 'left' else tk.N if element.Justification == 'center' else tk.NE - tktext_label = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height, justify=justify, bd=border_depth) - # tktext_label = tk.Label(tk_row_frame,anchor=tk.NW, text=display_text, width=width, height=height, justify=tk.LEFT, bd=border_depth) - # Set wrap-length for text (in PIXELS) == PAIN IN THE ASS - wraplen = tktext_label.winfo_reqwidth() # width of widget in Pixels - tktext_label.configure(anchor=anchor, font=font, wraplen=wraplen*2 ) # set wrap to width of widget - if element.BackgroundColor is not None: - tktext_label.configure(background=element.BackgroundColor) - if element.TextColor != COLOR_SYSTEM_DEFAULT and element.TextColor is not None: - tktext_label.configure(fg=element.TextColor) - - tktext_label.pack(side=tk.LEFT) - # ------------------------- BUTTON element ------------------------- # - elif element_type == ELEM_TYPE_BUTTON: - element.Location = (row_num, col_num) - btext = element.ButtonText - btype = element.BType - if element.AutoSizeButton is not None: - auto_size = element.AutoSizeButton - else: auto_size = MyFlexForm.AutoSizeButtons - if auto_size is False: width=element_size[0] - else: width = 0 - height=element_size[1] - lines = btext.split('\n') - max_line_len = max([len(l) for l in lines]) - num_lines = len(lines) - if element.ButtonColor != (None, None)and element.ButtonColor != DEFAULT_BUTTON_COLOR: - bc = element.ButtonColor - elif MyFlexForm.ButtonColor != (None, None) and MyFlexForm.ButtonColor != DEFAULT_BUTTON_COLOR: - bc = MyFlexForm.ButtonColor - else: - bc = DEFAULT_BUTTON_COLOR - border_depth = element.BorderWidth - if btype != BUTTON_TYPE_REALTIME: - tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height,command=element.ButtonCallBack, justify=tk.LEFT, bd=border_depth) - else: - tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height, justify=tk.LEFT, bd=border_depth) - tkbutton.bind('', element.ButtonReleaseCallBack) - tkbutton.bind('', element.ButtonPressCallBack) - if bc != (None, None) and bc != COLOR_SYSTEM_DEFAULT: - tkbutton.config(foreground=bc[0], background=bc[1]) - element.TKButton = tkbutton # not used yet but save the TK button in case - wraplen = tkbutton.winfo_reqwidth() # width of widget in Pixels - if element.ImageFilename: # if button has an image on it - photo = tk.PhotoImage(file=element.ImageFilename) - if element.ImageSize != (None, None): - width, height = element.ImageSize - if element.ImageSubsample: - photo = photo.subsample(element.ImageSubsample) - else: - width, height = photo.width(), photo.height() - tkbutton.config(image=photo, width=width, height=height) - tkbutton.image = photo - tkbutton.configure(wraplength=wraplen+10, font=font) # set wrap to width of widget - tkbutton.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) - if element.Focus is True or (MyFlexForm.UseDefaultFocus and not focus_set): - focus_set = True - element.TKButton.bind('', element.ReturnKeyHandler) - element.TKButton.focus_set() - MyFlexForm.TKroot.focus_force() - # ------------------------- INPUT (Single Line) element ------------------------- # - elif element_type == ELEM_TYPE_INPUT_TEXT: - default_text = element.DefaultText - element.TKStringVar = tk.StringVar() - element.TKStringVar.set(default_text) - show = element.PasswordCharacter if element.PasswordCharacter else "" - element.TKEntry = tk.Entry(tk_row_frame, width=element_size[0], textvariable=element.TKStringVar, bd=border_depth, font=font, show=show) - element.TKEntry.bind('', element.ReturnKeyHandler) - if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: - element.TKEntry.configure(background=element.BackgroundColor) - if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: - element.TKEntry.configure(fg=text_color) - element.TKEntry.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) - if element.Focus is True or (MyFlexForm.UseDefaultFocus and not focus_set): - focus_set = True - element.TKEntry.focus_set() - # ------------------------- COMBO BOX (Drop Down) element ------------------------- # - elif element_type == ELEM_TYPE_INPUT_COMBO: - max_line_len = max([len(str(l)) for l in element.Values]) - if auto_size_text is False: width=element_size[0] - else: width = max_line_len - element.TKStringVar = tk.StringVar() - if element.BackgroundColor and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: - combostyle = ttk.Style() - try: - combostyle.theme_create('combostyle', - settings={'TCombobox': - {'configure': - {'selectbackground': element.BackgroundColor, - 'fieldbackground': element.BackgroundColor, - 'foreground': text_color, - 'background': element.BackgroundColor} - }}) - except: - try: - combostyle.theme_settings('combostyle', - settings={'TCombobox': - {'configure': - {'selectbackground': element.BackgroundColor, - 'fieldbackground': element.BackgroundColor, - 'foreground': text_color, - 'background': element.BackgroundColor} - }}) - except: pass - # ATTENTION: this applies the new style 'combostyle' to all ttk.Combobox - combostyle.theme_use('combostyle') - element.TKCombo = ttk.Combobox(tk_row_frame, width=width, textvariable=element.TKStringVar,font=font ) - # element.TKCombo['state']='readonly' - element.TKCombo['values'] = element.Values - # if element.BackgroundColor is not None: - # element.TKCombo.configure(background=element.BackgroundColor) - element.TKCombo.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) - element.TKCombo.current(0) - # ------------------------- LISTBOX element ------------------------- # - elif element_type == ELEM_TYPE_INPUT_LISTBOX: - max_line_len = max([len(str(l)) for l in element.Values]) - if auto_size_text is False: width=element_size[0] - else: width = max_line_len - - element.TKStringVar = tk.StringVar() - element.TKListbox= tk.Listbox(tk_row_frame, height=element_size[1], width=width, selectmode=element.SelectMode, font=font) - for item in element.Values: - element.TKListbox.insert(tk.END, item) - element.TKListbox.selection_set(0,0) - if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: - element.TKListbox.configure(background=element.BackgroundColor) - if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: - element.TKListbox.configure(fg=text_color) - # vsb = tk.Scrollbar(tk_row_frame, orient="vertical", command=element.TKListbox.yview) - # element.TKListbox.configure(yscrollcommand=vsb.set) - element.TKListbox.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) - # vsb.pack(side=tk.LEFT, fill='y') - # ------------------------- INPUT MULTI LINE element ------------------------- # - elif element_type == ELEM_TYPE_INPUT_MULTILINE: - default_text = element.DefaultText - width, height = element_size - element.TKText = tk.scrolledtext.ScrolledText(tk_row_frame, width=width, height=height, wrap='word', bd=border_depth,font=font) - element.TKText.insert(1.0, default_text) # set the default text - if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: - element.TKText.configure(background=element.BackgroundColor) - element.TKText.vbar.config(troughcolor=DEFAULT_SCROLLBAR_COLOR) - element.TKText.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) - if element.EnterSubmits: - element.TKText.bind('', element.ReturnKeyHandler) - if element.Focus is True or (MyFlexForm.UseDefaultFocus and not focus_set): - focus_set = True - element.TKText.focus_set() - if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: - element.TKText.configure(fg=text_color) - # ------------------------- INPUT CHECKBOX element ------------------------- # - elif element_type == ELEM_TYPE_INPUT_CHECKBOX: - width = 0 if auto_size_text else element_size[0] - default_value = element.InitialState - element.TKIntVar = tk.IntVar() - element.TKIntVar.set(default_value if default_value is not None else 0) - element.TKCheckbutton = tk.Checkbutton(tk_row_frame, anchor=tk.NW, text=element.Text, width=width, variable=element.TKIntVar, bd=border_depth, font=font) - if default_value is None: - element.TKCheckbutton.configure(state='disable') - if element.BackgroundColor is not None: - element.TKCheckbutton.configure(background=element.BackgroundColor) - if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: - element.TKCheckbutton.configure(fg=text_color) - element.TKCheckbutton.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) - # ------------------------- PROGRESS BAR element ------------------------- # - elif element_type == ELEM_TYPE_PROGRESS_BAR: - # save this form because it must be 'updated' (refreshed) solely for the purpose of updating bar - width = element_size[0] - fnt = tkinter.font.Font() - char_width = fnt.measure('A') # single character width - progress_length = width*char_width - progress_width = element_size[1] - direction = element.Orientation - if element.BarColor != (None, None): # if element has a bar color, use it - bar_color = element.BarColor - else: - bar_color = DEFAULT_PROGRESS_BAR_COLOR - element.TKProgressBar = TKProgressBar(tk_row_frame, element.MaxValue, progress_length, progress_width, orientation=direction, BarColor=bar_color, border_width=element.BorderWidth, relief=element.Relief, style=element.BarStyle ) - # element.TKProgressBar = TKProgressBar(tk_row_frame, element.MaxValue, progress_length, progress_width, orientation=direction, BarColor=bar_color, border_width=element.BorderWidth, relief=element.Relief) - element.TKProgressBar.TKProgressBarForReal.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) - # ------------------------- INPUT RADIO BUTTON element ------------------------- # - elif element_type == ELEM_TYPE_INPUT_RADIO: - width = 0 if auto_size_text else element_size[0] - default_value = element.InitialState - ID = element.GroupID - # see if ID has already been placed - value = EncodeRadioRowCol(row_num, col_num) # value to set intvar to if this radio is selected - if ID in MyFlexForm.RadioDict: - RadVar = MyFlexForm.RadioDict[ID] - else: - RadVar = tk.IntVar() - MyFlexForm.RadioDict[ID] = RadVar - element.TKIntVar = RadVar # store the RadVar in Radio object - if default_value: # if this radio is the one selected, set RadVar to match - element.TKIntVar.set(value) - element.TKRadio = tk.Radiobutton(tk_row_frame, anchor=tk.NW, text=element.Text, width=width, - variable=element.TKIntVar, value=value, bd=border_depth, font=font) - if element.BackgroundColor is not None: - element.TKRadio.configure(background=element.BackgroundColor) - if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: - element.TKRadio.configure(fg=text_color) - element.TKRadio.pack(side=tk.LEFT, padx=element.Pad[0],pady=element.Pad[1]) - # ------------------------- INPUT SPIN Box element ------------------------- # - elif element_type == ELEM_TYPE_INPUT_SPIN: - width, height = element_size - width = 0 if auto_size_text else element_size[0] - element.TKStringVar = tk.StringVar() - element.TKSpinBox = tk.Spinbox(tk_row_frame, values=element.Values, textvariable=element.TKStringVar, width=width, bd=border_depth) - element.TKStringVar.set(element.DefaultValue) - element.TKSpinBox.configure(font=font) # set wrap to width of widget - if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: - element.TKSpinBox.configure(background=element.BackgroundColor) - element.TKSpinBox.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) - if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: - element.TKSpinBox.configure(fg=text_color) - # ------------------------- OUTPUT element ------------------------- # - elif element_type == ELEM_TYPE_OUTPUT: - width, height = element_size - element.TKOut = TKOutput(tk_row_frame, width=width, height=height, bd=border_depth, background_color=element.BackgroundColor, text_color=text_color) - element.TKOut.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) - # ------------------------- IMAGE Box element ------------------------- # - elif element_type == ELEM_TYPE_IMAGE: - photo = tk.PhotoImage(file=element.Filename) - if element_size == (None, None) or element_size == None or element_size == MyFlexForm.DefaultElementSize: - width, height = photo.width(), photo.height() - else: - width, height = element_size - tktext_label = tk.Label(tk_row_frame, image=photo, width=width, height=height, bd=border_depth) - tktext_label.image = photo - # tktext_label.configure(anchor=tk.NW, image=photo) - tktext_label.pack(side=tk.LEFT) - # ------------------------- SLIDER Box element ------------------------- # - elif element_type == ELEM_TYPE_INPUT_SLIDER: - slider_length = element_size[0] * CharWidthInPixels() - slider_width = element_size[1] - element.TKIntVar = tk.IntVar() - element.TKIntVar.set(element.DefaultValue) - if element.Orientation[0] == 'v': - range_from = element.Range[1] - range_to = element.Range[0] - else: - range_from = element.Range[0] - range_to = element.Range[1] - tkscale = tk.Scale(tk_row_frame, orient=element.Orientation, variable=element.TKIntVar, from_=range_from, to_=range_to, length=slider_length, width=slider_width , bd=element.BorderWidth, relief=element.Relief, font=font) - # tktext_label.configure(anchor=tk.NW, image=photo) - if element.BackgroundColor is not None: - tkscale.configure(background=element.BackgroundColor) - tkscale.config(troughcolor=DEFAULT_SCROLLBAR_COLOR) - if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: - tkscale.configure(fg=text_color) - tkscale.pack(side=tk.LEFT) - #............................DONE WITH ROW pack the row of widgets ..........................# - # done with row, pack the row of widgets - tk_row_frame.grid(row=row_num+2, sticky=tk.W, padx=DEFAULT_MARGINS[0]) - if MyFlexForm.BackgroundColor is not None: - tk_row_frame.configure(background=MyFlexForm.BackgroundColor) - if not MyFlexForm.IsTabbedForm: - MyFlexForm.TKroot.configure(padx=DEFAULT_MARGINS[0], pady=DEFAULT_MARGINS[1]) - else: MyFlexForm.ParentWindow.configure(padx=DEFAULT_MARGINS[0], pady=DEFAULT_MARGINS[1]) - #....................................... DONE creating and laying out window ..........................# - if MyFlexForm.IsTabbedForm: - master = MyFlexForm.ParentWindow - master.attributes('-alpha', 0) # hide window while getting info and moving - screen_width = master.winfo_screenwidth() # get window info to move to middle of screen - screen_height = master.winfo_screenheight() - if MyFlexForm.Location != (None, None): - x,y = MyFlexForm.Location - elif DEFAULT_WINDOW_LOCATION != (None, None): - x,y = DEFAULT_WINDOW_LOCATION - else: - master.update_idletasks() # don't forget - win_width = master.winfo_width() - win_height = master.winfo_height() - x = screen_width/2 -win_width/2 - y = screen_height/2 - win_height/2 - if y+win_height > screen_height: - y = screen_height-win_height - if x+win_width > screen_width: - x = screen_width-win_width - - move_string = '+%i+%i'%(int(x),int(y)) - master.geometry(move_string) - master.attributes('-alpha', 255) # Make window visible again - master.update_idletasks() # don't forget - return # ----====----====----====----====----==== STARTUP TK ====----====----====----====----====----# def ShowTabbedForm(title, *args, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, fav_icon=DEFAULT_WINDOW_ICON): @@ -2815,13 +2463,23 @@ def ChangeLookAndFeel(index): 'GreenMono': {'BACKGROUND': '#A8C1B4', 'TEXT': 'black', 'INPUT': '#DDE0DE', 'SCROLL': '#E3E3E3','TEXT_INPUT' : 'black', 'BUTTON': ('white', '#6D9F85'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, - 'BrownBlue': {'BACKGROUND': '#64778d', 'TEXT': 'white', 'INPUT': '#f0f3f7', 'SCROLL': '#A6B2BE','TEXT_INPUT' : 'black', - 'BUTTON': ('white', '#283b5b'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, + 'BrownBlue': {'BACKGROUND': '#64778d', 'TEXT': 'white', 'INPUT': '#f0f3f7', 'SCROLL': '#A6B2BE','TEXT_INPUT' : 'black', 'BUTTON': ('white', '#283b5b'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, + + 'BrightColors': {'BACKGROUND': '#b4ffb4', 'TEXT': 'black', 'INPUT': '#ffff64','SCROLL': '#ffb482','TEXT_INPUT' : 'black', 'BUTTON': ('black', '#ffa0dc'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, + + 'NeutralBlue': {'BACKGROUND': '#92aa9d', 'TEXT': 'black', 'INPUT': '#fcfff6', + 'SCROLL': '#fcfff6', 'TEXT_INPUT': 'black', 'BUTTON': ('black', '#d0dbbd'), + 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, + + 'Kayak': {'BACKGROUND': '#a7ad7f', 'TEXT': 'black', 'INPUT': '#e6d3a8', + 'SCROLL': '#e6d3a8', 'TEXT_INPUT': 'black', 'BUTTON': ('white', '#5d907d'), + 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, - 'BrightColors': {'BACKGROUND': '#b4ffb4', 'TEXT': 'black', 'INPUT': '#ffff64','SCROLL': '#ffb482','TEXT_INPUT' : 'black', - 'BUTTON': ('black', '#ffa0dc'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, + 'SandyBeach': {'BACKGROUND': '#efeccb', 'TEXT': '#012f2f', 'INPUT': '#e6d3a8', + 'SCROLL': '#e6d3a8', 'TEXT_INPUT': '#012f2f', 'BUTTON': ('white', '#046380'), + 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR}, - 'TealMono': {'BACKGROUND': '#a8cfdd', 'TEXT': 'black', 'INPUT': '#dfedf2','SCROLL': '#dfedf2', 'TEXT_INPUT' : 'black', 'BUTTON': ('white', '#3b7f97'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR} + 'TealMono': {'BACKGROUND': '#a8cfdd', 'TEXT': 'black', 'INPUT': '#dfedf2','SCROLL': '#dfedf2', 'TEXT_INPUT' : 'black', 'BUTTON': ('white', '#183440'), 'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR} } try: colors = look_and_feel[index] From 6ef5af67467ae77931a7a06c428ac3d41562ebf6 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 18 Aug 2018 16:55:21 -0400 Subject: [PATCH 153/209] Fixes, listbox scroll bars, more button lazy funcs, Fixed output element scrollbar length Added scroll bar to listbox New FileSaveAs, SaveAs, Save, Exit button functions Fixed button width bug Fixed button outline around images on Raspberry Pi Set border width = 0 for sliders --- PySimpleGUI.py | 110 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 74 insertions(+), 36 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 925130a09..4c36aeec6 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -100,6 +100,14 @@ def __init__(self): self.NumOpenWindows = 0 self.user_defined_icon = None + def Decrement(self): + self.NumOpenWindows -= 1 * (self.NumOpenWindows != 0) # decrement if not 0 + print('---- DECREMENTING Num Open Windows = {} ---'.format(self.NumOpenWindows)) + + def Increment(self): + self.NumOpenWindows += 1 + print('++++ INCREMENTING Num Open Windows = {} ++++'.format(self.NumOpenWindows)) + _my_windows = MyWindows() # terrible hack using globals... means need a class for collecing windows # ====================================================================== # @@ -116,6 +124,7 @@ def RGB(red,green,blue): return '#%02x%02x%02x' % (red,green,blue) # class ButtonType(Enum): BUTTON_TYPE_BROWSE_FOLDER = 1 BUTTON_TYPE_BROWSE_FILE = 2 +BUTTON_TYPE_SAVEAS_FILE = 3 BUTTON_TYPE_CLOSES_WIN = 5 BUTTON_TYPE_READ_FORM = 7 BUTTON_TYPE_REALTIME = 9 @@ -261,7 +270,7 @@ def __del__(self): # ---------------------------------------------------------------------- # -# Combo # +# Listbox # # ---------------------------------------------------------------------- # class Listbox(Element): @@ -514,16 +523,18 @@ def __del__(self): # ---------------------------------------------------------------------- # class TKOutput(tk.Frame): def __init__(self, parent, width, height, bd, background_color=None, text_color=None): - tk.Frame.__init__(self, parent) - self.output = tk.Text(parent, width=width, height=height, bd=bd) + frame = tk.Frame(parent, width=width, height=height) + tk.Frame.__init__(self, frame) + self.output = tk.Text(frame, width=width, height=height, bd=bd) if background_color and background_color != COLOR_SYSTEM_DEFAULT: self.output.configure(background=background_color) if text_color and text_color != COLOR_SYSTEM_DEFAULT: self.output.configure(fg=text_color) - self.vsb = tk.Scrollbar(parent, orient="vertical", command=self.output.yview) + self.vsb = tk.Scrollbar(frame, orient="vertical", command=self.output.yview) self.output.configure(yscrollcommand=self.vsb.set) - self.output.pack(side="left", fill="both", expand=True) + self.output.pack(side="left", fill="both") self.vsb.pack(side="left", fill="y") + frame.pack(side="left") self.previous_stdout = sys.stdout self.previous_stderr = sys.stderr @@ -650,6 +661,9 @@ def ButtonCallBack(self): elif self.BType == BUTTON_TYPE_BROWSE_FILE: file_name = tk.filedialog.askopenfilename(filetypes=filetypes) # show the 'get file' dialog box strvar.set(file_name) + elif self.BType == BUTTON_TYPE_SAVEAS_FILE: + file_name = tk.filedialog.asksaveasfilename(filetypes=filetypes) # show the 'get file' dialog box + strvar.set(file_name) elif self.BType == BUTTON_TYPE_CLOSES_WIN: # this is a return type button so GET RESULTS and destroy window # first, get the results table built # modify the Results table in the parent FlexForm object @@ -664,7 +678,7 @@ def ButtonCallBack(self): self.ParentForm.TKroot.quit() if self.ParentForm.NonBlocking: self.ParentForm.TKroot.destroy() - # _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 + _my_windows.Decrement() elif self.BType == BUTTON_TYPE_READ_FORM: # LEAVE THE WINDOW OPEN!! DO NOT CLOSE # first, get the results table built # modify the Results table in the parent FlexForm object @@ -718,7 +732,7 @@ def UpdateBar(self, current_count): try: self.ParentForm.TKroot.update() except: - # _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 + # _my_windows.Decrement() return False return True @@ -968,7 +982,7 @@ def Read(self): self.TKroot.mainloop() if self.RootNeedsDestroying: self.TKroot.destroy() - _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 + _my_windows.Decrement() return BuildResults(self, False, self) def ReadNonBlocking(self, Message=''): @@ -982,7 +996,7 @@ def ReadNonBlocking(self, Message=''): rc = self.TKroot.update() except: self.TKrootDestroyed = True - _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 + _my_windows.Decrement() return BuildResults(self, False, self) @@ -999,10 +1013,12 @@ def _Close(self): return None def CloseNonBlockingForm(self): + if self.TKrootDestroyed: + return try: self.TKroot.destroy() + _my_windows.Decrement() except: pass - _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 def OnClosingCallback(self): return @@ -1049,7 +1065,7 @@ def _Close(self): if not self.TKrootDestroyed: self.TKrootDestroyed = True self.TKroot.destroy() - _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 + _my_windows.Decrement() def __del__(self): return @@ -1082,24 +1098,36 @@ def T(display_text, scale=(None, None), size=(None, None), auto_size_text=None, return Text(display_text, scale=scale, size=size, auto_size_text=auto_size_text, font=font, text_color=text_color, justification=justification) # ------------------------- FOLDER BROWSE Element lazy function ------------------------- # -def FolderBrowse(target=(ThisRow, -1), button_text='Browse', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): +def FolderBrowse(target=(ThisRow, -1), button_text='Browse', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): return Button(BUTTON_TYPE_BROWSE_FOLDER, target=target, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) # ------------------------- FILE BROWSE Element lazy function ------------------------- # -def FileBrowse(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Browse', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None): - return Button(BUTTON_TYPE_BROWSE_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) +def FileBrowse(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Browse', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): + return Button(BUTTON_TYPE_BROWSE_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) + +# ------------------------- FILE BROWSE Element lazy function ------------------------- # +def FileSaveAs(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Save As...', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): + return Button(BUTTON_TYPE_SAVEAS_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) + +# ------------------------- SAVE AS Element lazy function ------------------------- # +def SaveAs(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Save As...', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): + return Button(BUTTON_TYPE_BROWSE_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) + +# ------------------------- SAVE BUTTON Element lazy function ------------------------- # +def Save(button_text='Save', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True,font=None, focus=False): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color,font=font, bind_return_key=bind_return_key, focus=focus) # ------------------------- SUBMIT BUTTON Element lazy function ------------------------- # -def Submit(button_text='Submit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True, focus=False): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, bind_return_key=bind_return_key, focus=focus) +def Submit(button_text='Submit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True,font=None, focus=False): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color,font=font, bind_return_key=bind_return_key, focus=focus) # ------------------------- OK BUTTON Element lazy function ------------------------- # -def OK(button_text='OK', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True, focus=False): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, bind_return_key=bind_return_key, focus=focus) +def OK(button_text='OK', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True, font=None,focus=False): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color,font=font, bind_return_key=bind_return_key, focus=focus) # ------------------------- YES BUTTON Element lazy function ------------------------- # -def Ok(button_text='Ok', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True, focus=False): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, bind_return_key=bind_return_key, focus=focus) +def Ok(button_text='Ok', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True, font=None,focus=False): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus) # ------------------------- CANCEL BUTTON Element lazy function ------------------------- # def Cancel(button_text='Cancel', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False): @@ -1109,13 +1137,17 @@ def Cancel(button_text='Cancel', scale=(None, None), size=(None, None), auto_siz def Quit(button_text='Quit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False): return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus) +# ------------------------- Exit BUTTON Element lazy function ------------------------- # +def Exit(button_text='Exit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus) + # ------------------------- YES BUTTON Element lazy function ------------------------- # -def Yes(button_text='Yes', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True, focus=False): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, bind_return_key=bind_return_key, focus=focus) +def Yes(button_text='Yes', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None,font=None, bind_return_key=True, focus=False): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus) # ------------------------- NO BUTTON Element lazy function ------------------------- # -def No(button_text='No', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=False, focus=False): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, bind_return_key=bind_return_key, focus=focus) +def No(button_text='No', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None,font=None, bind_return_key=False, focus=False): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus) # ------------------------- GENERIC BUTTON Element lazy function ------------------------- # # this is the only button that REQUIRES button text field @@ -1378,6 +1410,7 @@ def CharWidthInPixels(): element.TKButton = tkbutton # not used yet but save the TK button in case wraplen = tkbutton.winfo_reqwidth() # width of widget in Pixels if element.ImageFilename: # if button has an image on it + tkbutton.config(highlightthickness=0) photo = tk.PhotoImage(file=element.ImageFilename) if element.ImageSize != (None, None): width, height = element.ImageSize @@ -1387,7 +1420,10 @@ def CharWidthInPixels(): width, height = photo.width(), photo.height() tkbutton.config(image=photo, width=width, height=height) tkbutton.image = photo - tkbutton.configure(wraplength=wraplen+10, font=font) # set wrap to width of widget + if width != 0: + tkbutton.configure(wraplength=wraplen+10, font=font) # set wrap to width of widget + else: + tkbutton.configure(font=font) # only set the font, not wraplength tkbutton.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) if element.Focus is True or (toplevel_form.UseDefaultFocus and not focus_set): focus_set = True @@ -1452,9 +1488,9 @@ def CharWidthInPixels(): max_line_len = max([len(str(l)) for l in element.Values]) if auto_size_text is False: width=element_size[0] else: width = max_line_len - + listbox_frame = tk.Frame(tk_row_frame) element.TKStringVar = tk.StringVar() - element.TKListbox= tk.Listbox(tk_row_frame, height=element_size[1], width=width, selectmode=element.SelectMode, font=font) + element.TKListbox= tk.Listbox(listbox_frame, height=element_size[1], width=width, selectmode=element.SelectMode, font=font) for item in element.Values: element.TKListbox.insert(tk.END, item) element.TKListbox.selection_set(0,0) @@ -1462,10 +1498,11 @@ def CharWidthInPixels(): element.TKListbox.configure(background=element.BackgroundColor) if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: element.TKListbox.configure(fg=text_color) - # vsb = tk.Scrollbar(tk_row_frame, orient="vertical", command=element.TKListbox.yview) - # element.TKListbox.configure(yscrollcommand=vsb.set) - element.TKListbox.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) - # vsb.pack(side=tk.LEFT, fill='y') + vsb = tk.Scrollbar(listbox_frame, orient="vertical", command=element.TKListbox.yview) + element.TKListbox.configure(yscrollcommand=vsb.set) + element.TKListbox.pack(side=tk.LEFT) + vsb.pack(side=tk.LEFT, fill='y') + listbox_frame.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) # ------------------------- INPUT MULTI LINE element ------------------------- # elif element_type == ELEM_TYPE_INPUT_MULTILINE: default_text = element.DefaultText @@ -1563,7 +1600,7 @@ def CharWidthInPixels(): tktext_label = tk.Label(tk_row_frame, image=photo, width=width, height=height, bd=border_depth) tktext_label.image = photo # tktext_label.configure(anchor=tk.NW, image=photo) - tktext_label.pack(side=tk.LEFT) + tktext_label.pack(side=tk.LEFT, padx=element.Pad[0],pady=element.Pad[1]) # ------------------------- SLIDER Box element ------------------------- # elif element_type == ELEM_TYPE_INPUT_SLIDER: slider_length = element_size[0] * CharWidthInPixels() @@ -1579,12 +1616,13 @@ def CharWidthInPixels(): range_to = element.Range[1] tkscale = tk.Scale(tk_row_frame, orient=element.Orientation, variable=element.TKIntVar, from_=range_from, to_=range_to, length=slider_length, width=slider_width , bd=element.BorderWidth, relief=element.Relief, font=font) # tktext_label.configure(anchor=tk.NW, image=photo) + tkscale.config(highlightthickness=0) if element.BackgroundColor is not None: tkscale.configure(background=element.BackgroundColor) tkscale.config(troughcolor=DEFAULT_SCROLLBAR_COLOR) if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: tkscale.configure(fg=text_color) - tkscale.pack(side=tk.LEFT) + tkscale.pack(side=tk.LEFT, padx=element.Pad[0],pady=element.Pad[1]) #............................DONE WITH ROW pack the row of widgets ..........................# # done with row, pack the row of widgets tk_row_frame.grid(row=row_num+2, sticky=tk.NW, padx=DEFAULT_MARGINS[0]) @@ -1698,7 +1736,7 @@ def StartupTK(my_flex_form): root = tk.Tk() if not ow else tk.Toplevel() if my_flex_form.BackgroundColor is not None: root.configure(background=my_flex_form.BackgroundColor) - _my_windows.NumOpenWindows += 1 + _my_windows.Increment() my_flex_form.TKroot = root # root.protocol("WM_DELETE_WINDOW", MyFlexForm.DestroyedCallback()) @@ -1716,7 +1754,7 @@ def StartupTK(my_flex_form): my_flex_form.TKroot.mainloop() # print('..... BACK from MainLoop') if not my_flex_form.FormRemainedOpen: - _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 + _my_windows.Decrement() if my_flex_form.RootNeedsDestroying: my_flex_form.TKroot.destroy() my_flex_form.RootNeedsDestroying = False @@ -1992,8 +2030,8 @@ def _ProgressMeterUpdate(bar, value, text_elem, *args): bar.ParentForm._Close() if bar.ParentForm.RootNeedsDestroying: try: - _my_windows.NumOpenWindows -= 1 * (_my_windows.NumOpenWindows != 0) # decrement if not 0 bar.ParentForm.TKroot.destroy() + _my_windows.Decrement() except: pass bar.ParentForm.RootNeedsDestroying = False bar.ParentForm.__del__() From 405936978462d0fe66b6a5e75c234d03d13f1454 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 18 Aug 2018 17:22:38 -0400 Subject: [PATCH 154/209] Initial Checkin --- Demo_All_Widgets.py | 65 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Demo_All_Widgets.py diff --git a/Demo_All_Widgets.py b/Demo_All_Widgets.py new file mode 100644 index 000000000..8dcf08ed8 --- /dev/null +++ b/Demo_All_Widgets.py @@ -0,0 +1,65 @@ +import PySimpleGUI as sg + + +def Everything(): + + with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + layout = [ + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25))], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText()], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text should you decide not to type anything',size=(35,3)), + sg.Multiline(default_text='A second multi-line',size=(35,3))], + [sg.InputCombo(('Combobox 1', 'Combobox 2'), size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85)], + [sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3', 'Listbox 4'), size=(30, 3)), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10), + sg.Spin(values=('Spin Box 1', '2','3'), initial_value='Spin Box 1')], + [sg.Text('_' * 80)], + [sg.Text('Your Folder', size=(15, 1), auto_size_text=False, justification='right'), sg.InputText('Default Folder'), sg.FolderBrowse()], + [sg.Submit(), sg.Cancel()] ] + + button, values = form.LayoutAndRead(layout) + + sg.MsgBox('Title', 'The results of the form.', 'The button clicked was "{}"'.format(button), 'The values are', values) + +import PySimpleGUI as sg + +sg.ChangeLookAndFeel('GreenTan') + +form = sg.FlexForm('Everything bagel', default_element_size=(40, 1)) + +column1 = [[sg.Text('Column 1', background_color='#d3dfda', justification='center', size=(10,1))], + [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 1')], + [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 2')], + [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 3')]] +layout = [ + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25))], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText('This is my text')], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text should you decide not to type anything', size=(35, 3)), + sg.Multiline(default_text='A second multi-line', size=(35, 3))], + [sg.InputCombo(('Combobox 1', 'Combobox 2'), size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85)], + [sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(30, 3)), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10), + sg.Column(column1, background_color='#d3dfda')], + [sg.Text('_' * 80)], + [sg.Text('Choose A Folder', size=(35, 1))], + [sg.Text('Your Folder', size=(15, 1), auto_size_text=False, justification='right'), + sg.InputText('Default Folder'), sg.FolderBrowse()], + [sg.Submit(), sg.Cancel()] + ] + +button, values = form.LayoutAndRead(layout) +sg.MsgBox(button, values) + +# Everything_NoContextManager() \ No newline at end of file From 9a6661954a4cf40bdb202a5712bd1e035ffd24d9 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 18 Aug 2018 21:06:45 -0400 Subject: [PATCH 155/209] Typos --- docs/tutorial.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/tutorial.md b/docs/tutorial.md index 30fab5167..edc6b6198 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -12,7 +12,7 @@ PySimpleGUI attempts to address these GUI challenges by providing a super-simple ## The Secret -What makes PySimpleGUI superior for newcomers is that the package contains the majority of the code that the user is normally expected to write. Button callbacks are handled by PySimpleGUI, not the user's code. Beginners struggle to grasp the concept of a function, expecting them to understand a call-back function in the first few weeks is likely a stretch. +What makes PySimpleGUI superior for newcomers is that the package contains the majority of the code that the user is normally expected to write. Button callbacks are handled by PySimpleGUI, not the user's code. Beginners struggle to grasp the concept of a function, expecting them to understand a call-back function in the first few weeks is a stretch. With most GUIs arranging the GUI Widgets often requires several lines of code.... at least one or two lines per widget. PySimpleGUI uses an "auto-packer" that creates the layout for the user automatically. There is no concept of a pack nor a grid system needed to layout a GUI Window. @@ -48,9 +48,9 @@ Let's look at the first recipe from the book layout = [ [sg.Text('Please enter your Name, Address, Phone')], - [sg.Text('Name', size=(15, 1)), sg.InputText()], - [sg.Text('Address', size=(15, 1)), sg.InputText()], - [sg.Text('Phone', size=(15, 1)), sg.InputText()], + [sg.Text('Name', size=(15, 1)), sg.InputText('name')], + [sg.Text('Address', size=(15, 1)), sg.InputText('address')], + [sg.Text('Phone', size=(15, 1)), sg.InputText('phone')], [sg.Submit(), sg.Cancel()] ] From ea2b401801908247233a040a9b1f68a0e903dbce Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 18 Aug 2018 21:07:09 -0400 Subject: [PATCH 156/209] Checkin to match master branch --- docs/tutorial.md | 255 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 docs/tutorial.md diff --git a/docs/tutorial.md b/docs/tutorial.md new file mode 100644 index 000000000..edc6b6198 --- /dev/null +++ b/docs/tutorial.md @@ -0,0 +1,255 @@ +# Add GUIs to your programs and scripts easily with PySimpleGUI + +## Introduction +Python has dropped the GUI ball. While the rest of the world has been enjoying the use of a mouse, most Python programs continue to be accessed via the command line. Why is this, does anybody care, and what can be done about it? + +## GUI Frameworks +There is no shortage of GUI frameworks for Python. tkinter, WxPython, Qt, Kivy are a few of the major packages. In addition, there are a good number of dumbed down GUI packages that wrap one of the major packages. These include EasyGUI, PyGUI, Pyforms, ... + +The problem is that beginners (those with experience of less than 6 weeks) are not capable of learning even the simplest of the major packages. That leaves the wrapper-packages. Users will quickly find it difficult or impossible to build a custom GUI layout. Or, if it's possible, pages of code are still required. + +PySimpleGUI attempts to address these GUI challenges by providing a super-simple, easy to understand interface to GUIs that can be customized easily. Even the most complex of GUIs are often less than 20 lines of code when PySimpleGUI is used. + +## The Secret + +What makes PySimpleGUI superior for newcomers is that the package contains the majority of the code that the user is normally expected to write. Button callbacks are handled by PySimpleGUI, not the user's code. Beginners struggle to grasp the concept of a function, expecting them to understand a call-back function in the first few weeks is a stretch. + +With most GUIs arranging the GUI Widgets often requires several lines of code.... at least one or two lines per widget. PySimpleGUI uses an "auto-packer" that creates the layout for the user automatically. There is no concept of a pack nor a grid system needed to layout a GUI Window. + +Finally, PySimpleGUI leverages the Python language constructs in clever ways that shortens the amount of code and returns the GUI data in a straightforward manner. When a Widget is created in a form layout, it is configured in-place, not several lines of code away. + +## What is a GUI? + +Most GUIs do one thing.... they collect information from the user and return it. From a programmer's viewpoint this could be summed up as a function call that looks like this: + + button, values = GUI_Display(gui_layout) + +What's expected from most GUIs is the button that was clicked (OK, cancel, save, yes, no, etc), and the values that were input by the user. The essence of a GUI can be boiled down into a single line of code. + +This is exactly how PySimpleGUI works (for these simple kinds of GUIs). When the call is made to display the GUI, execution does no return until a button is clicked that closes the form. + +There are more complex GUIs such as those that don't close after a button is clicked. These complex forms can also be created with PySimpleGUI. A remote control interface for a robot and a chat window are a couple of examples. + +## The 5-Minute GUI + +When is PySimpleGUI useful? Immediately, anytime you've got a GUI need. It will take under 5 minutes for you to create and try your GUI. With those kinds of times, what do you have to lose trying it? + +The best way to go about making your GUI in under 5 minutes is to copy one of the GUIs from the [PySimpleGUI Cookbook](https://pysimplegui.readthedocs.io/en/latest/cookbook/). Follow these steps: +* Find a GUI that looks similar to what you want to create +* Copy code from Cookbook +* Paste into your IDE and run + +Let's look at the first recipe from the book + + import PySimpleGUI as sg + + # Very basic form. Return values as a list + form = sg.FlexForm('Simple data entry form') # begin with a blank form + + layout = [ + [sg.Text('Please enter your Name, Address, Phone')], + [sg.Text('Name', size=(15, 1)), sg.InputText('name')], + [sg.Text('Address', size=(15, 1)), sg.InputText('address')], + [sg.Text('Phone', size=(15, 1)), sg.InputText('phone')], + [sg.Submit(), sg.Cancel()] + ] + + button, values = form.LayoutAndRead(layout) + + print(button, values[0], values[1], values[2]) + + +It's a reasonable sized form. + + +![super simple 2](https://user-images.githubusercontent.com/13696193/43934091-8100e29a-9c1b-11e8-8d0a-9bd2d13e6d8e.jpg) + +If you only need to collect a few values and they're all basically strings, then you would copy this recipe and modify it to suit your needs. + +## Making Your Custom GUI + +That 5-minute estimate wasn't the time it takes to copy and paste the code from the Cookbook. You should be able to modify the code within 5 minutes in order to get to your layout, assuming you've got a straightforward layout. + +Widgets are called Elements in PySimpleGUI. This list of Elements are spelled exactly as you would type it into your Python code. + +### Core Element list +``` + Text + InputText + Multiline + InputCombo + Listbox + Radio + Checkbox + Spin + Output + SimpleButton + RealtimeButton + ReadFormButton + ProgressBar + Image + Slider + Column +``` + +You can also have short-cut Elements. There are 2 types of shortcuts. One is simply other names for the exact same element (e.g. T instead of Text). The second type configures an Element with particular setting, sparing the programmer from specifying all of the parameters (e.g. Submit is a button with the text "Submit" on it). +### Shortcut list + + T = Text + Txt = Text + In = InputText + Input = IntputText + Combo = InputCombo + DropDown = InputCombo + Drop = InputCombo + +A number of common buttons have been implemented as shortcuts. These include: +### Button Shortcuts + FolderBrowse + FileBrowse + FileSaveAs + Save + Submit + OK + Ok + Cancel + Quit + Exit + Yes + No + +The more generic button functions, that are also shortcuts +### Generic Buttons + SimpleButton + ReadFormButton + RealtimeButton + +These are all of the GUI Widgets you have to choose from. If it's not in this list, it doesn't go in your form layout. + +### GUI Design Pattern + +The stuff that tends not to change in GUIs are the calls that setup and show the Window. It's the layout of the Elements that changes from one program to another. This is the code from above with the layout removed: + + import PySimpleGUI as sg + + form = sg.FlexForm('Simple data entry form') + # Define your form here (it's a list of lists) + button, values = form.LayoutAndRead(layout) + + The flow for most GUIs is: + * Create the Form object + * Define GUI as a list of lists + * Show the GUI and get results + +These are line for line what you see in design pattern. + +### GUI Layout + +To create your custom GUI, first break your form down into "rows". You'll be defining your form one row at a time. Then for each for, you'll be placing one Element after another, working from left to right. + +The result is a "list of lists" that looks something like this: + + layout = [ [Text('Row 1')], + [Text('Row 2'), Checkbox('Checkbox 1', OK()), Checkbox('Checkbox 2'), OK()] ] + +The layout produced this window: + +![tutorial2](https://user-images.githubusercontent.com/13696193/44302312-e5259c00-a2f3-11e8-9c17-63e4eb130a9e.jpg) + + +## Display GUI & Get Results + +Once you have your layout complete and you've copied over the lines of code that setup and show the form, it's time to look at how to display the form and get the values from the user. + +This is the line of code that displays the form and provides the results: + + button, values = form.LayoutAndRead(layout) + + Forms return 2 values, the text of the button that was clicked and a ***list of values*** the user entered into the form. + +If the example form was displayed and the user did nothing other than click the OK button, then the results would have been: + + button == 'OK' + values == [False, False] + +Checkbox Elements return a value of True/False. Because these checkboxes defaulted to unchecked, the values returned were both False. + +## Displaying Results + +Once you have the values from the GUI it would be nice to check what values are in the variables. Rather than print them out using a `print` statement, let's stick with the GUI idea and output to a window. + +PySimpleGUI has a number of Message Boxes to choose from. The data passed to the message box will be displayed in a window. The function takes any number of arguments. Simply indicate all the variables you would like to see in the call. + +The most-commonly used Message Box in PySimpleGUI is MsgBox. To display the results of the previous example, one would write: + + MsgBox('The GUI returned:', button, values) + +## Putting It All Together + +Now that you know the basics, let's put together a form that contains as many PySimpleGUI's elements as possible. Also, just to give it a nice look, we'll change the "look and feel" to a green and tan color scheme. + + import PySimpleGUI as sg + + sg.ChangeLookAndFeel('GreenTan') + + form = sg.FlexForm('Everything bagel', default_element_size=(40, 1)) + + column1 = [[sg.Text('Column 1', background_color='#d3dfda', justification='center', size=(10,1))], + [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 1')], + [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 2')], + [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 3')]] + layout = [ + [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25))], + [sg.Text('Here is some text.... and a place to enter text')], + [sg.InputText('This is my text')], + [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], + [sg.Radio('My first Radio! ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], + [sg.Multiline(default_text='This is the default Text should you decide not to type anything', size=(35, 3)), + sg.Multiline(default_text='A second multi-line', size=(35, 3))], + [sg.InputCombo(('Combobox 1', 'Combobox 2'), size=(20, 3)), + sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85)], + [sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(30, 3)), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=25), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=75), + sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10), + sg.Column(column1, background_color='#d3dfda')], + [sg.Text('_' * 80)], + [sg.Text('Choose A Folder', size=(35, 1))], + [sg.Text('Your Folder', size=(15, 1), auto_size_text=False, justification='right'), + sg.InputText('Default Folder'), sg.FolderBrowse()], + [sg.Submit(), sg.Cancel()] + ] + + button, values = form.LayoutAndRead(layout) + sg.MsgBox(button, values) + +That may seem like a lot of code, but try coding this same GUI layout directly in tkinter and you'll quickly realize that the length is tiny. + +![everything for tutorial](https://user-images.githubusercontent.com/13696193/44302997-38531b00-a303-11e8-8c45-698ea62590a8.jpg) + +The last line of code opens a message box. This is how it looks: + +![tutorial results](https://user-images.githubusercontent.com/13696193/44303004-79e3c600-a303-11e8-8311-2f3726d364ad.jpg) + + +Each parameter to the message box call is displayed on a new line. There are actually 2 lines of text in the message box. The second line is very long and wrapped a number of times + +Take a moment and pair up the results values with the GUI to get an understanding of how results are created and returned. + +## Resources + +### Installation +Requires Python 3 + + pip install PySimpleGUI + +Works on all systems that run tkinter, including the Raspberry Pi + +### Documentation +[Main manual](https://pysimplegui.readthedocs.io/en/latest/) + +[Cookbook](https://pysimplegui.readthedocs.io/en/latest/cookbook/) + +### Home Page + +www.PySimpleGUI.com From a6d375f8a19c73ae4d42fbdb3c348384b5714627 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 18 Aug 2018 23:19:11 -0400 Subject: [PATCH 157/209] New Image features - load from RAM, update with new image --- PySimpleGUI.py | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 4c36aeec6..685075f7d 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -747,7 +747,7 @@ def __del__(self): # Image # # ---------------------------------------------------------------------- # class Image(Element): - def __init__(self, filename, scale=(None, None), size=(None, None)): + def __init__(self, filename=None, data=None,scale=(None, None), size=(None, None)): ''' Image Element :param filename: @@ -755,9 +755,23 @@ def __init__(self, filename, scale=(None, None), size=(None, None)): :param size: Size of field in characters ''' self.Filename = filename + self.Data = data + self.tktext_label = None + + if data is None and filename is None: + print('* Warning... no image specified in Image Element! *') super().__init__(ELEM_TYPE_IMAGE, scale=scale, size=size) return + def Update(self, filename=None, data=None): + if filename is not None: + image = tk.PhotoImage(file=filename) + elif data is not None: + image = tk.PhotoImage(data=data) + else: return + self.tktext_label.configure(image=image) + self.tktext_label.image = image + def __del__(self): super().__del__() @@ -835,7 +849,7 @@ def __del__(self): for element in row: element.__del__() try: - del(self.TKroot) + del(self.TKFrame) except: pass super().__del__() @@ -1592,15 +1606,23 @@ def CharWidthInPixels(): element.TKOut.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) # ------------------------- IMAGE Box element ------------------------- # elif element_type == ELEM_TYPE_IMAGE: - photo = tk.PhotoImage(file=element.Filename) - if element_size == (None, None) or element_size == None or element_size == toplevel_form.DefaultElementSize: - width, height = photo.width(), photo.height() + if element.Filename is not None: + photo = tk.PhotoImage(file=element.Filename) + elif element.Data is not None: + photo = tk.PhotoImage(data=element.Data) else: - width, height = element_size - tktext_label = tk.Label(tk_row_frame, image=photo, width=width, height=height, bd=border_depth) - tktext_label.image = photo - # tktext_label.configure(anchor=tk.NW, image=photo) - tktext_label.pack(side=tk.LEFT, padx=element.Pad[0],pady=element.Pad[1]) + photo = None + print('*ERROR laying out form.... Image Element has no image specified*') + + if photo is not None: + if element_size == (None, None) or element_size == None or element_size == toplevel_form.DefaultElementSize: + width, height = photo.width(), photo.height() + else: + width, height = element_size + element.tktext_label = tk.Label(tk_row_frame, image=photo, width=width, height=height, bd=border_depth) + element.tktext_label.image = photo + # tktext_label.configure(anchor=tk.NW, image=photo) + element.tktext_label.pack(side=tk.LEFT, padx=element.Pad[0],pady=element.Pad[1]) # ------------------------- SLIDER Box element ------------------------- # elif element_type == ELEM_TYPE_INPUT_SLIDER: slider_length = element_size[0] * CharWidthInPixels() From beebcbab0c8594e0d8abd8b601dd259ed0a422cf Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sun, 19 Aug 2018 20:59:08 -0400 Subject: [PATCH 158/209] Turned off 2 debug print statements, incomplete keyboard feature Also has some code for Keyboard handling, but it's incomplete --- PySimpleGUI.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 685075f7d..d20da4b49 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -102,11 +102,11 @@ def __init__(self): def Decrement(self): self.NumOpenWindows -= 1 * (self.NumOpenWindows != 0) # decrement if not 0 - print('---- DECREMENTING Num Open Windows = {} ---'.format(self.NumOpenWindows)) + # print('---- DECREMENTING Num Open Windows = {} ---'.format(self.NumOpenWindows)) def Increment(self): self.NumOpenWindows += 1 - print('++++ INCREMENTING Num Open Windows = {} ++++'.format(self.NumOpenWindows)) + # print('++++ INCREMENTING Num Open Windows = {} ++++'.format(self.NumOpenWindows)) _my_windows = MyWindows() # terrible hack using globals... means need a class for collecing windows @@ -862,7 +862,7 @@ class FlexForm: ''' Display a user defined for and return the filled in data ''' - def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=None, auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON): + def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=None, auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, return_keyboard_events=False): self.AutoSizeText = auto_size_text if auto_size_text is not None else DEFAULT_AUTOSIZE_TEXT self.AutoSizeButtons = auto_size_buttons if auto_size_buttons is not None else DEFAULT_AUTOSIZE_BUTTONS self.Title = title @@ -896,6 +896,7 @@ def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT self.LastButtonClicked = None self.UseDictionary = False self.UseDefaultFocus = False + self.ReturnKeyboardEvents = return_keyboard_events # ------------------------- Add ONE Row to Form ------------------------- # def AddRow(self, *args): @@ -1013,6 +1014,8 @@ def ReadNonBlocking(self, Message=''): _my_windows.Decrement() return BuildResults(self, False, self) + def KeyboardCallback(self, event ): + print("pressed", event) def _Close(self): try: @@ -1765,6 +1768,8 @@ def StartupTK(my_flex_form): # root.bind('', MyFlexForm.DestroyedCallback()) ConvertFlexToTK(my_flex_form) my_flex_form.SetIcon(my_flex_form.WindowIcon) + if my_flex_form.ReturnKeyboardEvents: + root.bind("", my_flex_form.KeyboardCallback) if my_flex_form.AutoClose: duration = DEFAULT_AUTOCLOSE_TIME if my_flex_form.AutoCloseDuration is None else my_flex_form.AutoCloseDuration From 3af033122b04c521aad19d8430d88f97c90093fb Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sun, 19 Aug 2018 21:05:59 -0400 Subject: [PATCH 159/209] 5-line GUI added --- docs/tutorial.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/tutorial.md b/docs/tutorial.md index edc6b6198..ab1e798b7 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -59,13 +59,31 @@ Let's look at the first recipe from the book print(button, values[0], values[1], values[2]) -It's a reasonable sized form. +It's a reasonably sized form. ![super simple 2](https://user-images.githubusercontent.com/13696193/43934091-8100e29a-9c1b-11e8-8d0a-9bd2d13e6d8e.jpg) If you only need to collect a few values and they're all basically strings, then you would copy this recipe and modify it to suit your needs. +## The 5-line GUI + +Not all GUIs take 5 minutes. Some take 5 lines of code. This is a GUI with a custom layout contained in 5 lines of code. + + import PySimpleGUI as sg + + form = sg.FlexForm('My first GUI') + + layout = [ [sg.Text('Enter your name'), sg.InputText()], + [sg.OK()] ] + + button, (name,) = form.LayoutAndRead(layout) + + +![myfirstgui](https://user-images.githubusercontent.com/13696193/44315412-d2918c80-a3f1-11e8-9eda-0d5d9bfefb0f.jpg) + + + ## Making Your Custom GUI That 5-minute estimate wasn't the time it takes to copy and paste the code from the Cookbook. You should be able to modify the code within 5 minutes in order to get to your layout, assuming you've got a straightforward layout. From 1f9247e6ce5e084210d04a9816c60f6313a9d944 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 20 Aug 2018 13:48:02 -0400 Subject: [PATCH 160/209] Keyboard capture! You can now have a form return the keystokes. This is great for page-up page-down, etc. Returned as a string in the button field.. Specified in the FlexForm call. return_keyboard_events is the boolean parameter. --- PySimpleGUI.py | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 685075f7d..2ceb7ac32 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -102,11 +102,11 @@ def __init__(self): def Decrement(self): self.NumOpenWindows -= 1 * (self.NumOpenWindows != 0) # decrement if not 0 - print('---- DECREMENTING Num Open Windows = {} ---'.format(self.NumOpenWindows)) + # print('---- DECREMENTING Num Open Windows = {} ---'.format(self.NumOpenWindows)) def Increment(self): self.NumOpenWindows += 1 - print('++++ INCREMENTING Num Open Windows = {} ++++'.format(self.NumOpenWindows)) + # print('++++ INCREMENTING Num Open Windows = {} ++++'.format(self.NumOpenWindows)) _my_windows = MyWindows() # terrible hack using globals... means need a class for collecing windows @@ -862,7 +862,7 @@ class FlexForm: ''' Display a user defined for and return the filled in data ''' - def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=None, auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON): + def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=None, auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, return_keyboard_events=False): self.AutoSizeText = auto_size_text if auto_size_text is not None else DEFAULT_AUTOSIZE_TEXT self.AutoSizeButtons = auto_size_buttons if auto_size_buttons is not None else DEFAULT_AUTOSIZE_BUTTONS self.Title = title @@ -896,6 +896,8 @@ def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT self.LastButtonClicked = None self.UseDictionary = False self.UseDefaultFocus = False + self.ReturnKeyboardEvents = return_keyboard_events + self.LastKeyboardEvent = None # ------------------------- Add ONE Row to Form ------------------------- # def AddRow(self, *args): @@ -993,11 +995,18 @@ def Read(self): if not self.Shown: self.Show() else: + InitializeResults(self) self.TKroot.mainloop() if self.RootNeedsDestroying: self.TKroot.destroy() _my_windows.Decrement() - return BuildResults(self, False, self) + # if self.ReturnValues[0] is not None: # keyboard events build their own return values + # return self.ReturnValues + if self.LastKeyboardEvent is not None or self.LastButtonClicked is not None: + return BuildResults(self, False, self) + else: + return self.ReturnValues + def ReadNonBlocking(self, Message=''): if self.TKrootDestroyed: @@ -1013,6 +1022,19 @@ def ReadNonBlocking(self, Message=''): _my_windows.Decrement() return BuildResults(self, False, self) + def KeyboardCallback(self, event ): + print(".",) + self.LastButtonClicked = None + self.FormRemainedOpen = True + if event.char != '': + self.LastKeyboardEvent = event.char + else: + self.LastKeyboardEvent = str(event.keysym) + ':' + str(event.keycode) + # self.LastKeyboardEvent = event + if not self.NonBlocking: + results = BuildResults(self, False, self) + self.TKroot.quit() + def _Close(self): try: @@ -1125,7 +1147,7 @@ def FileSaveAs(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_ # ------------------------- SAVE AS Element lazy function ------------------------- # def SaveAs(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Save As...', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): - return Button(BUTTON_TYPE_BROWSE_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) + return Button(BUTTON_TYPE_SAVEAS_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) # ------------------------- SAVE BUTTON Element lazy function ------------------------- # def Save(button_text='Save', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True,font=None, focus=False): @@ -1244,7 +1266,7 @@ def BuildResultsForSubform(form, initialize_only, top_level_form): if not initialize_only: if element.Type == ELEM_TYPE_INPUT_TEXT: value=element.TKStringVar.get() - if not top_level_form.NonBlocking and not element.do_not_clear: + if not top_level_form.NonBlocking and not element.do_not_clear and not top_level_form.ReturnKeyboardEvents: element.TKStringVar.set('') elif element.Type == ELEM_TYPE_INPUT_CHECKBOX: value = element.TKIntVar.get() @@ -1279,7 +1301,7 @@ def BuildResultsForSubform(form, initialize_only, top_level_form): elif element.Type == ELEM_TYPE_INPUT_MULTILINE: try: value=element.TKText.get(1.0, tk.END) - if not top_level_form.NonBlocking and not element.do_not_clear: + if not top_level_form.NonBlocking and not element.do_not_clear and not top_level_form.ReturnKeyboardEvents: element.TKText.delete('1.0', tk.END) except: value = None @@ -1292,6 +1314,10 @@ def BuildResultsForSubform(form, initialize_only, top_level_form): AddToReturnList(form, value) AddToReturnDictionary(top_level_form, element, value) + if form.ReturnKeyboardEvents and form.LastKeyboardEvent is not None: + button_pressed_text = form.LastKeyboardEvent + form.LastKeyboardEvent = None + try: form.ReturnValuesDictionary.pop(None, None) # clean up dictionary include None was included except: pass @@ -1765,6 +1791,8 @@ def StartupTK(my_flex_form): # root.bind('', MyFlexForm.DestroyedCallback()) ConvertFlexToTK(my_flex_form) my_flex_form.SetIcon(my_flex_form.WindowIcon) + if my_flex_form.ReturnKeyboardEvents: + root.bind("", my_flex_form.KeyboardCallback) if my_flex_form.AutoClose: duration = DEFAULT_AUTOCLOSE_TIME if my_flex_form.AutoCloseDuration is None else my_flex_form.AutoCloseDuration @@ -2571,11 +2599,15 @@ def ChangeLookAndFeel(index): sprint=ScrolledTextBox # Converts an object's contents into a nice printable string. Great for dumping debug data -def ObjToString_old(obj): +def ObjToStringSingleObj(obj): + if obj is None: + return 'None' return str(obj.__class__) + '\n' + '\n'.join( (repr(item) + ' = ' + repr(obj.__dict__[item]) for item in sorted(obj.__dict__))) def ObjToString(obj, extra=' '): + if obj is None: + return 'None' return str(obj.__class__) + '\n' + '\n'.join( (extra + (str(item) + ' = ' + (ObjToString(obj.__dict__[item], extra + ' ') if hasattr(obj.__dict__[item], '__dict__') else str( From aa2d31f24bc17ec68c5f58f075d76cdea0186103 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 20 Aug 2018 15:27:12 -0400 Subject: [PATCH 161/209] Added non-blocking form keyboard binding If the form is a non-blocking form, when a key is pressed, the form will continuously return that key as being pressed until it is released. --- PySimpleGUI.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 2ceb7ac32..fc07064a5 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1791,8 +1791,10 @@ def StartupTK(my_flex_form): # root.bind('', MyFlexForm.DestroyedCallback()) ConvertFlexToTK(my_flex_form) my_flex_form.SetIcon(my_flex_form.WindowIcon) - if my_flex_form.ReturnKeyboardEvents: + if my_flex_form.ReturnKeyboardEvents and not my_flex_form.NonBlocking: root.bind("", my_flex_form.KeyboardCallback) + elif my_flex_form.ReturnKeyboardEvents: + root.bind("", my_flex_form.KeyboardCallback) if my_flex_form.AutoClose: duration = DEFAULT_AUTOCLOSE_TIME if my_flex_form.AutoCloseDuration is None else my_flex_form.AutoCloseDuration From 51ea64ce07fbe552e63370f0ab324d99550a9ef1 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 20 Aug 2018 15:51:29 -0400 Subject: [PATCH 162/209] Removed print --- PySimpleGUI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index fc07064a5..dae19930c 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1023,7 +1023,7 @@ def ReadNonBlocking(self, Message=''): return BuildResults(self, False, self) def KeyboardCallback(self, event ): - print(".",) + # print(".",) self.LastButtonClicked = None self.FormRemainedOpen = True if event.char != '': From 9b190f5cee6dff31eb7682b297eaf25440ec3deb Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 20 Aug 2018 18:43:33 -0400 Subject: [PATCH 163/209] Added page-up / page-down --- Demo_PDF_Viewer.py | 92 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Demo_PDF_Viewer.py diff --git a/Demo_PDF_Viewer.py b/Demo_PDF_Viewer.py new file mode 100644 index 000000000..1e933ef84 --- /dev/null +++ b/Demo_PDF_Viewer.py @@ -0,0 +1,92 @@ +import sys +import fitz +import PySimpleGUI as sg + +try: + fname = sys.argv[1] +except: + fname = 'C:/Python/PycharmProjects/GooeyGUI/test.pdf' +doc = fitz.open(fname) +title = "PyMuPDF display of '%s' (%i pages)" % (fname, len(doc)) + +def get_page(pno, zoom = 0): + page = doc[pno] + r = page.rect + mp = r.tl + (r.br - r.tl) * 0.5 + mt = r.tl + (r.tr - r.tl) * 0.5 + ml = r.tl + (r.bl - r.tl) * 0.5 + mr = r.tr + (r.br - r.tr) * 0.5 + mb = r.bl + (r.br - r.bl) * 0.5 + mat = fitz.Matrix(2, 2) + if zoom == 1: + clip = fitz.Rect(r.tl, mp) + elif zoom == 4: + clip = fitz.Rect(mp, r.br) + elif zoom == 2: + clip = fitz.Rect(mt, mr) + elif zoom == 3: + clip = fitz.Rect(ml, mb) + if zoom == 0: + pix = page.getPixmap(alpha = False) + else: + pix = page.getPixmap(alpha = False, matrix = mat, clip = clip) + return pix.getPNGData() + +form = sg.FlexForm(title, return_keyboard_events=True) + +data = get_page(0) +image_elem = sg.Image(data=data) +layout = [ [image_elem], + [sg.ReadFormButton('Next'), + sg.ReadFormButton('Prev'), + sg.ReadFormButton('First'), + sg.ReadFormButton('Last'), + sg.ReadFormButton('Zoom-1'), + sg.ReadFormButton('Zoom-2'), + sg.ReadFormButton('Zoom-3'), + sg.ReadFormButton('Zoom-4'), + sg.Quit()] ] + +form.Layout(layout) + +i = 0 +oldzoom = 0 +while True: + button,value = form.Read() + zoom = 0 + if button in (None, 'Quit'): + break + if button in ("Next", 'Next:34'): + i += 1 + elif button in ("Prev", "Prior:33"): + i -= 1 + elif button == "First": + i = 0 + elif button == "Last": + i = -1 + elif button == "Zoom-1": + if oldzoom == 1: + zoom = oldzoom = 0 + else: + zoom = oldzoom = 1 + elif button == "Zoom-2": + if oldzoom == 2: + zoom = oldzoom = 0 + else: + zoom = oldzoom = 2 + elif button == "Zoom-3": + if oldzoom == 3: + zoom = oldzoom = 0 + else: + zoom = oldzoom = 3 + elif button == "Zoom-4": + if oldzoom == 4: + zoom = oldzoom = 0 + else: + zoom = oldzoom = 4 + try: + data = get_page(i, zoom) + except: + i = 0 + data = get_page(i, zoom) + image_elem.Update(data=data) From 88bdf72d8afa9f8ce2e0bba9282fb9c4cb1b791f Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 20 Aug 2018 18:44:33 -0400 Subject: [PATCH 164/209] Removed a commment --- PySimpleGUI.py | 1 - 1 file changed, 1 deletion(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index dae19930c..18edc84c5 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1030,7 +1030,6 @@ def KeyboardCallback(self, event ): self.LastKeyboardEvent = event.char else: self.LastKeyboardEvent = str(event.keysym) + ':' + str(event.keycode) - # self.LastKeyboardEvent = event if not self.NonBlocking: results = BuildResults(self, False, self) self.TKroot.quit() From e0deebea9ea513415428615b8a390c4734068cfc Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 20 Aug 2018 19:00:02 -0400 Subject: [PATCH 165/209] Initial checkin of Keyboard Demos --- Demo_Keyboard.py | 26 ++++++++++++++++++++++++++ Demo_Keyboard_Realtime.py | 23 +++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 Demo_Keyboard.py create mode 100644 Demo_Keyboard_Realtime.py diff --git a/Demo_Keyboard.py b/Demo_Keyboard.py new file mode 100644 index 000000000..a6bbda996 --- /dev/null +++ b/Demo_Keyboard.py @@ -0,0 +1,26 @@ +import sys +import PySimpleGUI as sg + +# Recipe for getting keys, one at a time as they are released +# If want to use the space bar, then be sure and disable the "default focus" + +with sg.FlexForm('Realtime Keyboard Test', return_keyboard_events=True, use_default_focus=False) as form: + text_elem = sg.Text('', size=(12,1)) + layout = [[sg.Text('Press a key')], + [text_elem], + [sg.SimpleButton('OK')]] + + form.Layout(layout) + # ---===--- Loop taking in user input --- # + while True: + button, value = form.Read() + + if button == 'OK': + print(button, 'exiting') + break + if button is not None: + text_elem.Update(button) + elif value is None: + break + + diff --git a/Demo_Keyboard_Realtime.py b/Demo_Keyboard_Realtime.py new file mode 100644 index 000000000..bb1d145e5 --- /dev/null +++ b/Demo_Keyboard_Realtime.py @@ -0,0 +1,23 @@ +import PySimpleGUI as sg + +# Recipe for getting a continuous stream of keys when using a non-blocking form +# If want to use the space bar, then be sure and disable the "default focus" + +with sg.FlexForm('Realtime Keyboard Test', return_keyboard_events=True, use_default_focus=False) as form: + layout = [[sg.Text('Hold down a key')], + [sg.SimpleButton('OK')]] + + form.Layout(layout) + # ---===--- Loop taking in user input --- # + while True: + button, value = form.ReadNonBlocking() + + if button == 'OK': + print(button, value, 'exiting') + break + if button is not None: + print(button) + elif value is None: + break + + From d3d154b8708e27f1e9f1a22f1d301eabdf1e33a3 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 20 Aug 2018 19:09:05 -0400 Subject: [PATCH 166/209] Cleaned up code --- Demo_PDF_Viewer.py | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/Demo_PDF_Viewer.py b/Demo_PDF_Viewer.py index 1e933ef84..85825bcc1 100644 --- a/Demo_PDF_Viewer.py +++ b/Demo_PDF_Viewer.py @@ -49,8 +49,7 @@ def get_page(pno, zoom = 0): form.Layout(layout) -i = 0 -oldzoom = 0 +i = oldzoom = 0 while True: button,value = form.Read() zoom = 0 @@ -65,25 +64,13 @@ def get_page(pno, zoom = 0): elif button == "Last": i = -1 elif button == "Zoom-1": - if oldzoom == 1: - zoom = oldzoom = 0 - else: - zoom = oldzoom = 1 + zoom = oldzoom = 0 if oldzoom == 1 else 1 elif button == "Zoom-2": - if oldzoom == 2: - zoom = oldzoom = 0 - else: - zoom = oldzoom = 2 + zoom = oldzoom = 0 if oldzoom == 2 else 2 elif button == "Zoom-3": - if oldzoom == 3: - zoom = oldzoom = 0 - else: - zoom = oldzoom = 3 + zoom = oldzoom = 0 if oldzoom == 3 else 3 elif button == "Zoom-4": - if oldzoom == 4: - zoom = oldzoom = 0 - else: - zoom = oldzoom = 4 + zoom = oldzoom = 0 if oldzoom == 4 else 4 try: data = get_page(i, zoom) except: From 4667a2f3ffbc9f801f4767bd468d941266587017 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 20 Aug 2018 20:47:24 -0400 Subject: [PATCH 167/209] New use_default_focus option for forms. --- Demo_Keyboard.py | 2 +- PySimpleGUI.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Demo_Keyboard.py b/Demo_Keyboard.py index a6bbda996..85f63b8a9 100644 --- a/Demo_Keyboard.py +++ b/Demo_Keyboard.py @@ -20,7 +20,7 @@ break if button is not None: text_elem.Update(button) - elif value is None: + else: break diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 18edc84c5..eed9167c8 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -862,7 +862,7 @@ class FlexForm: ''' Display a user defined for and return the filled in data ''' - def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=None, auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, return_keyboard_events=False): + def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=None, auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, return_keyboard_events=False, use_default_focus=True): self.AutoSizeText = auto_size_text if auto_size_text is not None else DEFAULT_AUTOSIZE_TEXT self.AutoSizeButtons = auto_size_buttons if auto_size_buttons is not None else DEFAULT_AUTOSIZE_BUTTONS self.Title = title @@ -895,7 +895,7 @@ def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT self.DictionaryKeyCounter = 0 self.LastButtonClicked = None self.UseDictionary = False - self.UseDefaultFocus = False + self.UseDefaultFocus = use_default_focus self.ReturnKeyboardEvents = return_keyboard_events self.LastKeyboardEvent = None @@ -954,8 +954,10 @@ def Show(self, non_blocking=False): except: pass - if not found_focus: + if not found_focus and self.UseDefaultFocus: self.UseDefaultFocus = True + else: + self.UseDefaultFocus = False # -=-=-=-=-=-=-=-=- RUN the GUI -=-=-=-=-=-=-=-=- ## StartupTK(self) return self.ReturnValues From c482dee57e958231aa8492bba08071e5e91171d1 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 20 Aug 2018 21:59:00 -0400 Subject: [PATCH 168/209] Update method for InputText element --- PySimpleGUI.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index eed9167c8..751ef6dec 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -236,6 +236,8 @@ def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto super().__init__(ELEM_TYPE_INPUT_TEXT, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=fg, key=key) + def Update(self, new_value): + self.TKStringVar.set(new_value) def __del__(self): super().__del__() From 240a0a71e40d8fcb6d9a92157202d4d27c85bd3f Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 20 Aug 2018 23:45:09 -0400 Subject: [PATCH 169/209] Mouse scroll wheel! New PDF viewer demo --- Demo_PDF_Viewer.py | 222 +++++++++++++++++++++++++++++++++------------ PySimpleGUI.py | 13 ++- 2 files changed, 175 insertions(+), 60 deletions(-) diff --git a/Demo_PDF_Viewer.py b/Demo_PDF_Viewer.py index 85825bcc1..ecd60c9c5 100644 --- a/Demo_PDF_Viewer.py +++ b/Demo_PDF_Viewer.py @@ -1,79 +1,183 @@ +""" +@created: 2018-08-19 18:00:00 + +@author: (c) 2018 Jorj X. McKie + +Display a PyMuPDF Document using Tkinter +------------------------------------------------------------------------------- + +Dependencies: +------------- +PyMuPDF, PySimpleGUI > v2.9.0, Tkinter with Tk v8.6+, Python 3 + + +License: +-------- +GNU GPL V3+ + +Description +------------ +Read filename from command line and start display with page 1. +Pages can be directly jumped to, or buttons for paging can be used. +For experimental / demonstration purposes, we have included options to zoom +into the four page quadrants (top-left, bottom-right, etc.). + +We also interpret keyboard events to support paging by PageDown / PageUp +keys as if the resp. buttons were clicked. Similarly, we do not include +a 'Quit' button. Instead, the ESCAPE key can be used, or cancelling the form. + +To improve paging performance, we are not directly creating pixmaps from +pages, but instead from the fitz.DisplayList of the page. A display list +will be stored in a list and looked up by page number. This way, zooming +pixmaps and page re-visits will re-use a once-created display list. + +""" import sys import fitz import PySimpleGUI as sg +from binascii import hexlify -try: +if len(sys.argv) == 1: + rc, fname = sg.GetFileBox('PDF Browser', 'PDF file to open', file_types=(("PDF Files", "*.pdf"),)) + if rc is False: + sg.MsgBoxCancel('Cancelling') + exit(0) +else: fname = sys.argv[1] -except: - fname = 'C:/Python/PycharmProjects/GooeyGUI/test.pdf' + doc = fitz.open(fname) -title = "PyMuPDF display of '%s' (%i pages)" % (fname, len(doc)) - -def get_page(pno, zoom = 0): - page = doc[pno] - r = page.rect - mp = r.tl + (r.br - r.tl) * 0.5 - mt = r.tl + (r.tr - r.tl) * 0.5 - ml = r.tl + (r.bl - r.tl) * 0.5 - mr = r.tr + (r.br - r.tr) * 0.5 - mb = r.bl + (r.br - r.bl) * 0.5 - mat = fitz.Matrix(2, 2) - if zoom == 1: +page_count = len(doc) + +# storage for page display lists +dlist_tab = [None] * page_count + +title = "PyMuPDF display of '%s', pages: %i" % (fname, page_count) + + +def get_page(pno, zoom=0): + """Return a PNG image for a document page number. If zoom is other than 0, one of the 4 page quadrants are zoomed-in instead and the corresponding clip returned. + + """ + dlist = dlist_tab[pno] # get display list + if not dlist: # create if not yet there + dlist_tab[pno] = doc[pno].getDisplayList() + dlist = dlist_tab[pno] + r = dlist.rect # page rectangle + mp = r.tl + (r.br - r.tl) * 0.5 # rect middle point + mt = r.tl + (r.tr - r.tl) * 0.5 # middle of top edge + ml = r.tl + (r.bl - r.tl) * 0.5 # middle of left edge + mr = r.tr + (r.br - r.tr) * 0.5 # middle of right egde + mb = r.bl + (r.br - r.bl) * 0.5 # middle of bottom edge + mat = fitz.Matrix(2, 2) # zoom matrix + if zoom == 1: # top-left quadrant clip = fitz.Rect(r.tl, mp) - elif zoom == 4: + elif zoom == 4: # bot-right quadrant clip = fitz.Rect(mp, r.br) - elif zoom == 2: + elif zoom == 2: # top-right clip = fitz.Rect(mt, mr) - elif zoom == 3: + elif zoom == 3: # bot-left clip = fitz.Rect(ml, mb) - if zoom == 0: - pix = page.getPixmap(alpha = False) + if zoom == 0: # total page + pix = dlist.getPixmap(alpha=False) else: - pix = page.getPixmap(alpha = False, matrix = mat, clip = clip) - return pix.getPNGData() + pix = dlist.getPixmap(alpha=False, matrix=mat, clip=clip) + return pix.getPNGData() # return the PNG image + -form = sg.FlexForm(title, return_keyboard_events=True) +form = sg.FlexForm(title, return_keyboard_events=True, use_default_focus=False) -data = get_page(0) +cur_page = 0 +data = get_page(cur_page) # show page 1 for start image_elem = sg.Image(data=data) -layout = [ [image_elem], - [sg.ReadFormButton('Next'), - sg.ReadFormButton('Prev'), - sg.ReadFormButton('First'), - sg.ReadFormButton('Last'), - sg.ReadFormButton('Zoom-1'), - sg.ReadFormButton('Zoom-2'), - sg.ReadFormButton('Zoom-3'), - sg.ReadFormButton('Zoom-4'), - sg.Quit()] ] +goto = sg.InputText(str(cur_page + 1), size=(5, 1), do_not_clear=True) + +layout = [ + [ + sg.ReadFormButton('Next'), + sg.ReadFormButton('Prev'), + sg.Text('Page:'), + goto, + ], + [ + sg.Text("Zoom:"), + sg.ReadFormButton('Top-L'), + sg.ReadFormButton('Top-R'), + sg.ReadFormButton('Bot-L'), + sg.ReadFormButton('Bot-R'), + ], + [image_elem], +] form.Layout(layout) +my_keys = ("Next", "Next:34", "Prev", "Prior:33", "Top-L", "Top-R", + "Bot-L", "Bot-R", "MouseWheel:Down", "MouseWheel:Up") +zoom_buttons = ("Top-L", "Top-R", "Bot-L", "Bot-R") + +old_page = 0 +old_zoom = 0 # used for zoom on/off +# the zoom buttons work in on/off mode. -i = oldzoom = 0 while True: - button,value = form.Read() + button, value = form.ReadNonBlocking() zoom = 0 - if button in (None, 'Quit'): + force_page = False + if button is None and value is None: break - if button in ("Next", 'Next:34'): - i += 1 - elif button in ("Prev", "Prior:33"): - i -= 1 - elif button == "First": - i = 0 - elif button == "Last": - i = -1 - elif button == "Zoom-1": - zoom = oldzoom = 0 if oldzoom == 1 else 1 - elif button == "Zoom-2": - zoom = oldzoom = 0 if oldzoom == 2 else 2 - elif button == "Zoom-3": - zoom = oldzoom = 0 if oldzoom == 3 else 3 - elif button == "Zoom-4": - zoom = oldzoom = 0 if oldzoom == 4 else 4 - try: - data = get_page(i, zoom) - except: - i = 0 - data = get_page(i, zoom) - image_elem.Update(data=data) + if button is None: + continue + + if button in ("Escape:27"): # this spares me a 'Quit' button! + break + # print("hex(button)", hexlify(button.encode())) + if button[0] == chr(13): # surprise: this is 'Enter'! + try: + cur_page = int(value[0]) - 1 # check if valid + while cur_page < 0: + cur_page += page_count + except: + cur_page = 0 # this guy's trying to fool me + goto.Update(str(cur_page + 1)) + # goto.TKStringVar.set(str(cur_page + 1)) + + elif button in ("Next", "Next:34", "MouseWheel:Down"): + cur_page += 1 + elif button in ("Prev", "Prior:33", "MouseWheel:Up"): + cur_page -= 1 + elif button == "Top-L": + zoom = 1 + elif button == "Top-R": + zoom = 2 + elif button == "Bot-L": + zoom = 3 + elif button == "Bot-R": + zoom = 4 + + # sanitize page number + if cur_page >= page_count: # wrap around + cur_page = 0 + while cur_page < 0: # we show conventional page numbers + cur_page += page_count + + # prevent creating same data again + if cur_page != old_page: + zoom = old_zoom = 0 + force_page = True + + if button in zoom_buttons: + if 0 < zoom == old_zoom: + zoom = 0 + force_page = True + + if zoom != old_zoom: + force_page = True + + if force_page: + data = get_page(cur_page, zoom) + image_elem.Update(data=data) + old_page = cur_page + old_zoom = zoom + + # update page number field + if button in my_keys or not value[0]: + goto.Update(str(cur_page + 1)) + # goto.TKStringVar.set(str(cur_page + 1)) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 751ef6dec..c69c74d13 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1027,7 +1027,6 @@ def ReadNonBlocking(self, Message=''): return BuildResults(self, False, self) def KeyboardCallback(self, event ): - # print(".",) self.LastButtonClicked = None self.FormRemainedOpen = True if event.char != '': @@ -1038,6 +1037,16 @@ def KeyboardCallback(self, event ): results = BuildResults(self, False, self) self.TKroot.quit() + def MouseWheelCallback(self, event ): + self.LastButtonClicked = None + self.FormRemainedOpen = True + # print(ObjToStringSingleObj(event)) + direction = 'Down' if event.delta < 0 else 'Up' + self.LastKeyboardEvent = 'MouseWheel:' + direction + if not self.NonBlocking: + results = BuildResults(self, False, self) + self.TKroot.quit() + def _Close(self): try: @@ -1796,8 +1805,10 @@ def StartupTK(my_flex_form): my_flex_form.SetIcon(my_flex_form.WindowIcon) if my_flex_form.ReturnKeyboardEvents and not my_flex_form.NonBlocking: root.bind("", my_flex_form.KeyboardCallback) + root.bind("", my_flex_form.MouseWheelCallback) elif my_flex_form.ReturnKeyboardEvents: root.bind("", my_flex_form.KeyboardCallback) + root.bind("", my_flex_form.MouseWheelCallback) if my_flex_form.AutoClose: duration = DEFAULT_AUTOCLOSE_TIME if my_flex_form.AutoCloseDuration is None else my_flex_form.AutoCloseDuration From 23123c532062400683784c80cb9295a6f6e62d73 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 21 Aug 2018 10:33:42 -0400 Subject: [PATCH 170/209] Fix for missing results on persistent form --- PySimpleGUI.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index c69c74d13..c26ae0305 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -962,6 +962,9 @@ def Show(self, non_blocking=False): self.UseDefaultFocus = False # -=-=-=-=-=-=-=-=- RUN the GUI -=-=-=-=-=-=-=-=- ## StartupTK(self) + # If a button or keyboard event happened but no results have been built, build the results + if self.LastKeyboardEvent is not None or self.LastButtonClicked is not None: + return BuildResults(self, False, self) return self.ReturnValues # ------------------------- SetIcon - set the window's fav icon ------------------------- # From 1d61773df611124e26f3ae1cc5d2143799a2b619 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 21 Aug 2018 13:10:05 -0400 Subject: [PATCH 171/209] Option added to Image.UIpdate to create a new PhotoImage --- PySimpleGUI.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index c26ae0305..fc1c59dab 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -769,7 +769,10 @@ def Update(self, filename=None, data=None): if filename is not None: image = tk.PhotoImage(file=filename) elif data is not None: - image = tk.PhotoImage(data=data) + if type(data) is bytes: + image = tk.PhotoImage(data=data) + else: + image = data else: return self.tktext_label.configure(image=image) self.tktext_label.image = image From a4461313aef6fbc7b63a397902a9d7860f360151 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 21 Aug 2018 18:29:32 -0400 Subject: [PATCH 172/209] Added text justification setting to FlexForm --- PySimpleGUI.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index fc1c59dab..8cbed783d 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -452,7 +452,7 @@ def __init__(self, text, scale=(None, None), size=(None, None), auto_size_text=N ''' self.DisplayText = text self.TextColor = text_color if text_color else DEFAULT_TEXT_COLOR - self.Justification = justification if justification else DEFAULT_TEXT_JUSTIFICATION + self.Justification = justification if background_color is None: bg = DEFAULT_TEXT_ELEMENT_BACKGROUND_COLOR else: @@ -867,7 +867,7 @@ class FlexForm: ''' Display a user defined for and return the filled in data ''' - def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=None, auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, return_keyboard_events=False, use_default_focus=True): + def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=None, auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, return_keyboard_events=False, use_default_focus=True, text_justification=None): self.AutoSizeText = auto_size_text if auto_size_text is not None else DEFAULT_AUTOSIZE_TEXT self.AutoSizeButtons = auto_size_buttons if auto_size_buttons is not None else DEFAULT_AUTOSIZE_BUTTONS self.Title = title @@ -903,6 +903,7 @@ def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT self.UseDefaultFocus = use_default_focus self.ReturnKeyboardEvents = return_keyboard_events self.LastKeyboardEvent = None + self.TextJustification = text_justification # ------------------------- Add ONE Row to Form ------------------------- # def AddRow(self, *args): @@ -1040,17 +1041,15 @@ def KeyboardCallback(self, event ): else: self.LastKeyboardEvent = str(event.keysym) + ':' + str(event.keycode) if not self.NonBlocking: - results = BuildResults(self, False, self) + BuildResults(self, False, self) self.TKroot.quit() def MouseWheelCallback(self, event ): self.LastButtonClicked = None self.FormRemainedOpen = True - # print(ObjToStringSingleObj(event)) - direction = 'Down' if event.delta < 0 else 'Up' - self.LastKeyboardEvent = 'MouseWheel:' + direction + self.LastKeyboardEvent = 'MouseWheel:' + 'Down' if event.delta < 0 else 'Up' if not self.NonBlocking: - results = BuildResults(self, False, self) + BuildResults(self, False, self) self.TKroot.quit() @@ -1059,7 +1058,7 @@ def _Close(self): self.TKroot.update() except: pass if not self.NonBlocking: - results = BuildResults(self, False, self) + BuildResults(self, False, self) if self.TKrootDestroyed: return None self.TKrootDestroyed = True @@ -1424,8 +1423,14 @@ def CharWidthInPixels(): stringvar.set(display_text) if auto_size_text: width = 0 - justify = tk.LEFT if element.Justification == 'left' else tk.CENTER if element.Justification == 'center' else tk.RIGHT - anchor = tk.NW if element.Justification == 'left' else tk.N if element.Justification == 'center' else tk.NE + if element.Justification is not None: + justification = element.Justification + elif toplevel_form.TextJustification is not None: + justification = toplevel_form.TextJustification + else: + justification = DEFAULT_TEXT_JUSTIFICATION + justify = tk.LEFT if justification == 'left' else tk.CENTER if justification == 'center' else tk.RIGHT + anchor = tk.NW if justification == 'left' else tk.N if justification == 'center' else tk.NE tktext_label = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height, justify=justify, bd=border_depth) # tktext_label = tk.Label(tk_row_frame,anchor=tk.NW, text=display_text, width=width, height=height, justify=tk.LEFT, bd=border_depth) # Set wrap-length for text (in PIXELS) == PAIN IN THE ASS From 5f2740055e560ab83a0140ff516dcee3f0ec0f40 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 21 Aug 2018 18:56:10 -0400 Subject: [PATCH 173/209] Updated readme with new FlexForm options --- docs/index.md | 61 ++++++++++++++++++++++++++++++++++++++++++++------- readme.md | 61 ++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 106 insertions(+), 16 deletions(-) diff --git a/docs/index.md b/docs/index.md index 392287c2d..2efe1958f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -6,16 +6,28 @@ ![Documentation Status](https://readthedocs.org/projects/pysimplegui/badge/?version=latest) +[![Python Version](https://img.shields.io/badge/Python-3-brightgreen.svg)](https://www.python.org/downloads/) + # PySimpleGUI - (Ver 2.8) + (Ver 2.9) +Lots of documentation available in addition to this Readme File. [Formatted ReadTheDocs Version of this Readme](http://pysimplegui.readthedocs.io/) [COOKBOOK documentation now online!](https://pysimplegui.readthedocs.io/en/latest/cookbook/) +[Brief Tutorial on PySimpleGUI](https://pysimplegui.readthedocs.io/en/latest/tutorial/) + +[See Wiki for latest news about development branch + new features](https://github.com/MikeTheWatchGuy/PySimpleGUI/wiki) + + Super-simple GUI to grasp... Powerfully customizable. +Create a custom GUI in 5 lines of code. + +Can create a custom GUI in 1 line of code if desired. + Note - ***Python3*** is required to run PySimpleGUI. It takes advantage of some Python3 features that do not translate well into Python2. Looking to take your Python code from the world of command lines and into the convenience of a GUI? Have a Raspberry **Pi** with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK? Into Machine Learning and are sick of the command line? Look no further, **you've found your GUI package**. @@ -27,6 +39,14 @@ Looking to take your Python code from the world of command lines and into the co ![snap0136](https://user-images.githubusercontent.com/13696193/43162494-33095ece-8f59-11e8-86de-b6d8bcc5a52f.jpg) +Or how about a ***custom GUI*** in 1 line of code? + + import PySimpleGUI as sg + + button, (filename,) = sg.FlexForm('Get filename example'). LayoutAndRead([[sg.Text('Filename')], [sg.Input(), sg.FileBrowse()], [sg.OK(), sg.Cancel()] ]) + +![simple](https://user-images.githubusercontent.com/13696193/44279378-2f891900-a21f-11e8-89d1-52d935a4f5f5.jpg) + Build beautiful customized forms that fit your specific problem. Let PySimpleGUI solve your GUI problem while you solve the real problems. Do you really want to plod through the mountains of code required to program tkinter? PySimpleGUI wraps tkinter so that you get all the same widgets as you would tkinter, but you interact with them in a **much** more friendly way. @@ -35,7 +55,8 @@ PySimpleGUI wraps tkinter so that you get all the same widgets as you would tkin Perhaps you're looking for a way to interact with your **Raspberry Pi** in a more friendly way. The is the same form as above, except shown on a Pi. -![raspberry pi](https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg) +![raspberry pi everything demo](https://user-images.githubusercontent.com/13696193/44279694-5b58ce80-a220-11e8-9ab6-d6021f5a944f.jpg) + In addition to a primary GUI, you can add a Progress Meter to your code with ONE LINE of code. Slide this into any of your `for` loops and get a nice meter like this: @@ -48,6 +69,7 @@ You can build an async media player GUI with custom buttons in 30 lines of code. ![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) + ## Background I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? There are a number of 'easy to use' Python GUIs, but they're **very** limiting. PySimpleGUI takes the best of packages like `EasyGUI`and `WxSimpleGUI` , both really handy but limited. The primary difference between these and `PySimpleGUI` is that in addition to getting the simple Message Boxes you also get the ability to **make your own forms** that are highly customizeable. Don't like the standard Message Box? Then make your own! @@ -60,6 +82,8 @@ With a simple GUI, it becomes practical to "associate" .py files with the python The `PySimpleGUI` package is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? +## Features + Features of PySimpleGUI include: Text Single Line Input @@ -89,6 +113,7 @@ The `PySimpleGUI` package is focused on the ***developer***. How can the desire Return values as dictionary Set focus Bind return key to buttons + Group widgets into a column and place into form anywhere An example of many widgets used on a single form. A little further down you'll find the TWENTY lines of code required to create this complex form. Try it if you don't believe it. Start Python, copy and paste the code below into the >>> prompt and hit enter. This will pop up... @@ -143,6 +168,7 @@ You will see a number of different styles of buttons, data entry fields, etc, in - A row is a list of elements - Return values are a list of button presses and input values. - Return values can also be represented as a dictionary +- The SDK calls collapse down into a single line of Python code that presents a custom GUI and returns values ----- @@ -733,11 +759,19 @@ This is the definition of the FlexForm object: location=(None, None), button_color=None,Font=None, progress_bar_color=(None,None), + background_color=None is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, - icon=DEFAULT_WINDOW_ICON): + icon=DEFAULT_WINDOW_ICON, + return_keyboard_events=False, + use_default_focus=True, + text_justification=None): + + + + Parameter Descriptions. You will find these same parameters specified for each `Element` and some of them in `Row` specifications. The `Element` specified value will take precedence over the `Row` and `Form` values. @@ -748,11 +782,15 @@ Parameter Descriptions. You will find these same parameters specified for each location - (x,y) Location to place window in pixels button_color - Default color for buttons (foreground, background). Can be text or hex progress_bar_color - Foreground and background colors for progress bars + background_color - Color of the window background is_tabbed_form - Bool. If True then form is a tabbed form border_depth - Amount of 'bezel' to put on input boxes, buttons, etc. auto_close - Bool. If True form will autoclose auto_close_duration - Duration in seconds before form closes icon - .ICO file that will appear on the Task Bar and end of Title Bar + return_keyboard_events - if True key presses are returned as buttons + use_default_focus - if True and no focus set, then automatically set a focus + text_justification - Justification to use for Text Elements in this form #### Window Location @@ -1111,7 +1149,7 @@ While it's possible to build forms using the Button Element directly, you should button_color=None, font=None) -Pre-made buttons include: +These Pre-made buttons are some of the most important elements of all because they are used so much. If you find yourself needing to create a custom button often because it's not on this list, please post a request on GitHub. (hmmm Save already comes to mind). They include: OK Ok @@ -1600,8 +1638,14 @@ Valid values for the description string are: GreenMono BrownBlue BrightColors + NeutralBlue + Kayak + SandyBeach TealMono +To see the latest list of color choices, take a look at the bottom of the `PySimpleGUI.py` file where you'll find the `ChangLookAndFeel` function. + +You can also combine the `ChangeLookAndFeel` function with the `SetOptions` function to quickly modify one of the canned color schemes. Maybe you like the colors but was more depth to your bezels. You can dial in exactly what you want. **ObjToString** Ever wanted to easily display an objects contents easily? Use ObjToString to get a nicely formatted recursive walk of your objects. @@ -1655,7 +1699,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ | 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting | 2.8.0 | Aug 9, 2018 - New None default option for Checkbox element, text color option for all elements, return values as a dictionary, setting focus, binding return key -| 2.9.0 | Aug XX,2018 - Screen flash fix, `do_not_clear` input field option, `autosize_text` defaults to `True` now, return values as ordered dict, removed text target from progress bar, rework of return values and initial return values, removed legacy Form.Refresh() method (replaced by Form.ReadNonBlockingForm()), COLUMN elements!!, +| 2.9.0 | Aug 16,2018 - Screen flash fix, `do_not_clear` input field option, `autosize_text` defaults to `True` now, return values as ordered dict, removed text target from progress bar, rework of return values and initial return values, removed legacy Form.Refresh() method (replaced by Form.ReadNonBlockingForm()), COLUMN elements!!, colored text defaults ### Release Notes @@ -1670,14 +1714,15 @@ New debug printing capability. `sg.Print` Listboxes are still without scrollwheels. The mouse can drag to see more items. The mouse scrollwheel will also scroll the list and will `page up` and `page down` keys. 2.7 Is the "feature complete" release. Pretty much all features are done and in the code + 2.8 More text color controls. The caller has more control over things like the focus and what buttons should be clicked when enter key is pressed. Return values as a dictionary! (NICE addition) +2.9 COLUMNS! This is the biggest feature and had the biggest impact on the code base. It was a difficult feature to add, but it was worth it. Can now make even more layouts. Almost any layout is possible with this addition. + ### Upcoming Make suggestions people! Future release features -Columns. How multiple columns would be specified in the SDK interface are still being designed. - Port to other graphic engines. Hook up the front-end interface to a backend other than tkinter. Qt, WxPython, etc. @@ -1738,7 +1783,7 @@ Here are the steps to run that application To run it: Python HowDoI.py -The pip command is all there is to the setup. +The pip command is all there is to the setup. The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. diff --git a/readme.md b/readme.md index 392287c2d..2efe1958f 100644 --- a/readme.md +++ b/readme.md @@ -6,16 +6,28 @@ ![Documentation Status](https://readthedocs.org/projects/pysimplegui/badge/?version=latest) +[![Python Version](https://img.shields.io/badge/Python-3-brightgreen.svg)](https://www.python.org/downloads/) + # PySimpleGUI - (Ver 2.8) + (Ver 2.9) +Lots of documentation available in addition to this Readme File. [Formatted ReadTheDocs Version of this Readme](http://pysimplegui.readthedocs.io/) [COOKBOOK documentation now online!](https://pysimplegui.readthedocs.io/en/latest/cookbook/) +[Brief Tutorial on PySimpleGUI](https://pysimplegui.readthedocs.io/en/latest/tutorial/) + +[See Wiki for latest news about development branch + new features](https://github.com/MikeTheWatchGuy/PySimpleGUI/wiki) + + Super-simple GUI to grasp... Powerfully customizable. +Create a custom GUI in 5 lines of code. + +Can create a custom GUI in 1 line of code if desired. + Note - ***Python3*** is required to run PySimpleGUI. It takes advantage of some Python3 features that do not translate well into Python2. Looking to take your Python code from the world of command lines and into the convenience of a GUI? Have a Raspberry **Pi** with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK? Into Machine Learning and are sick of the command line? Look no further, **you've found your GUI package**. @@ -27,6 +39,14 @@ Looking to take your Python code from the world of command lines and into the co ![snap0136](https://user-images.githubusercontent.com/13696193/43162494-33095ece-8f59-11e8-86de-b6d8bcc5a52f.jpg) +Or how about a ***custom GUI*** in 1 line of code? + + import PySimpleGUI as sg + + button, (filename,) = sg.FlexForm('Get filename example'). LayoutAndRead([[sg.Text('Filename')], [sg.Input(), sg.FileBrowse()], [sg.OK(), sg.Cancel()] ]) + +![simple](https://user-images.githubusercontent.com/13696193/44279378-2f891900-a21f-11e8-89d1-52d935a4f5f5.jpg) + Build beautiful customized forms that fit your specific problem. Let PySimpleGUI solve your GUI problem while you solve the real problems. Do you really want to plod through the mountains of code required to program tkinter? PySimpleGUI wraps tkinter so that you get all the same widgets as you would tkinter, but you interact with them in a **much** more friendly way. @@ -35,7 +55,8 @@ PySimpleGUI wraps tkinter so that you get all the same widgets as you would tkin Perhaps you're looking for a way to interact with your **Raspberry Pi** in a more friendly way. The is the same form as above, except shown on a Pi. -![raspberry pi](https://user-images.githubusercontent.com/13696193/43298356-9cfe9008-9123-11e8-9612-14649a2f6c7f.jpg) +![raspberry pi everything demo](https://user-images.githubusercontent.com/13696193/44279694-5b58ce80-a220-11e8-9ab6-d6021f5a944f.jpg) + In addition to a primary GUI, you can add a Progress Meter to your code with ONE LINE of code. Slide this into any of your `for` loops and get a nice meter like this: @@ -48,6 +69,7 @@ You can build an async media player GUI with custom buttons in 30 lines of code. ![media file player](https://user-images.githubusercontent.com/13696193/43161977-9ee7cace-8f57-11e8-8ff8-3ea24b69dab9.jpg) + ## Background I was frustrated by having to deal with the dos prompt when I had a powerful Windows machine right in front of me. Why is it SO difficult to do even the simplest of input/output to a window in Python?? There are a number of 'easy to use' Python GUIs, but they're **very** limiting. PySimpleGUI takes the best of packages like `EasyGUI`and `WxSimpleGUI` , both really handy but limited. The primary difference between these and `PySimpleGUI` is that in addition to getting the simple Message Boxes you also get the ability to **make your own forms** that are highly customizeable. Don't like the standard Message Box? Then make your own! @@ -60,6 +82,8 @@ With a simple GUI, it becomes practical to "associate" .py files with the python The `PySimpleGUI` package is focused on the ***developer***. How can the desired result be achieved in as little and as simple code as possible? This was the mantra used to create PySimpleGUI. How can it be done is a Python-like way? +## Features + Features of PySimpleGUI include: Text Single Line Input @@ -89,6 +113,7 @@ The `PySimpleGUI` package is focused on the ***developer***. How can the desire Return values as dictionary Set focus Bind return key to buttons + Group widgets into a column and place into form anywhere An example of many widgets used on a single form. A little further down you'll find the TWENTY lines of code required to create this complex form. Try it if you don't believe it. Start Python, copy and paste the code below into the >>> prompt and hit enter. This will pop up... @@ -143,6 +168,7 @@ You will see a number of different styles of buttons, data entry fields, etc, in - A row is a list of elements - Return values are a list of button presses and input values. - Return values can also be represented as a dictionary +- The SDK calls collapse down into a single line of Python code that presents a custom GUI and returns values ----- @@ -733,11 +759,19 @@ This is the definition of the FlexForm object: location=(None, None), button_color=None,Font=None, progress_bar_color=(None,None), + background_color=None is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, - icon=DEFAULT_WINDOW_ICON): + icon=DEFAULT_WINDOW_ICON, + return_keyboard_events=False, + use_default_focus=True, + text_justification=None): + + + + Parameter Descriptions. You will find these same parameters specified for each `Element` and some of them in `Row` specifications. The `Element` specified value will take precedence over the `Row` and `Form` values. @@ -748,11 +782,15 @@ Parameter Descriptions. You will find these same parameters specified for each location - (x,y) Location to place window in pixels button_color - Default color for buttons (foreground, background). Can be text or hex progress_bar_color - Foreground and background colors for progress bars + background_color - Color of the window background is_tabbed_form - Bool. If True then form is a tabbed form border_depth - Amount of 'bezel' to put on input boxes, buttons, etc. auto_close - Bool. If True form will autoclose auto_close_duration - Duration in seconds before form closes icon - .ICO file that will appear on the Task Bar and end of Title Bar + return_keyboard_events - if True key presses are returned as buttons + use_default_focus - if True and no focus set, then automatically set a focus + text_justification - Justification to use for Text Elements in this form #### Window Location @@ -1111,7 +1149,7 @@ While it's possible to build forms using the Button Element directly, you should button_color=None, font=None) -Pre-made buttons include: +These Pre-made buttons are some of the most important elements of all because they are used so much. If you find yourself needing to create a custom button often because it's not on this list, please post a request on GitHub. (hmmm Save already comes to mind). They include: OK Ok @@ -1600,8 +1638,14 @@ Valid values for the description string are: GreenMono BrownBlue BrightColors + NeutralBlue + Kayak + SandyBeach TealMono +To see the latest list of color choices, take a look at the bottom of the `PySimpleGUI.py` file where you'll find the `ChangLookAndFeel` function. + +You can also combine the `ChangeLookAndFeel` function with the `SetOptions` function to quickly modify one of the canned color schemes. Maybe you like the colors but was more depth to your bezels. You can dial in exactly what you want. **ObjToString** Ever wanted to easily display an objects contents easily? Use ObjToString to get a nicely formatted recursive walk of your objects. @@ -1655,7 +1699,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.6.0 | July 27, 2018 - auto_size_button setting. License changed to LGPL 3+ | 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting | 2.8.0 | Aug 9, 2018 - New None default option for Checkbox element, text color option for all elements, return values as a dictionary, setting focus, binding return key -| 2.9.0 | Aug XX,2018 - Screen flash fix, `do_not_clear` input field option, `autosize_text` defaults to `True` now, return values as ordered dict, removed text target from progress bar, rework of return values and initial return values, removed legacy Form.Refresh() method (replaced by Form.ReadNonBlockingForm()), COLUMN elements!!, +| 2.9.0 | Aug 16,2018 - Screen flash fix, `do_not_clear` input field option, `autosize_text` defaults to `True` now, return values as ordered dict, removed text target from progress bar, rework of return values and initial return values, removed legacy Form.Refresh() method (replaced by Form.ReadNonBlockingForm()), COLUMN elements!!, colored text defaults ### Release Notes @@ -1670,14 +1714,15 @@ New debug printing capability. `sg.Print` Listboxes are still without scrollwheels. The mouse can drag to see more items. The mouse scrollwheel will also scroll the list and will `page up` and `page down` keys. 2.7 Is the "feature complete" release. Pretty much all features are done and in the code + 2.8 More text color controls. The caller has more control over things like the focus and what buttons should be clicked when enter key is pressed. Return values as a dictionary! (NICE addition) +2.9 COLUMNS! This is the biggest feature and had the biggest impact on the code base. It was a difficult feature to add, but it was worth it. Can now make even more layouts. Almost any layout is possible with this addition. + ### Upcoming Make suggestions people! Future release features -Columns. How multiple columns would be specified in the SDK interface are still being designed. - Port to other graphic engines. Hook up the front-end interface to a backend other than tkinter. Qt, WxPython, etc. @@ -1738,7 +1783,7 @@ Here are the steps to run that application To run it: Python HowDoI.py -The pip command is all there is to the setup. +The pip command is all there is to the setup. The way HowDoI works is that it uses your search term to look through stack overflow posts. It finds the best answer, gets the code from the answer, and presents it as a response. It gives you the correct answer OFTEN. It's a miracle that it work SO well. For Python questions, I simply start my query with 'Python'. Let's say you forgot how to reverse a list in Python. When you run HowDoI and ask this question, this is what you'll see. From 038ce5eb6a3f16fbaf50590ec8358bff899b997a Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 21 Aug 2018 19:05:55 -0400 Subject: [PATCH 174/209] Manually submitting the file from dev branch --- PySimpleGUI.py | 84 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 69 insertions(+), 15 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index d20da4b49..8cbed783d 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -236,6 +236,8 @@ def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto super().__init__(ELEM_TYPE_INPUT_TEXT, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=fg, key=key) + def Update(self, new_value): + self.TKStringVar.set(new_value) def __del__(self): super().__del__() @@ -450,7 +452,7 @@ def __init__(self, text, scale=(None, None), size=(None, None), auto_size_text=N ''' self.DisplayText = text self.TextColor = text_color if text_color else DEFAULT_TEXT_COLOR - self.Justification = justification if justification else DEFAULT_TEXT_JUSTIFICATION + self.Justification = justification if background_color is None: bg = DEFAULT_TEXT_ELEMENT_BACKGROUND_COLOR else: @@ -767,7 +769,10 @@ def Update(self, filename=None, data=None): if filename is not None: image = tk.PhotoImage(file=filename) elif data is not None: - image = tk.PhotoImage(data=data) + if type(data) is bytes: + image = tk.PhotoImage(data=data) + else: + image = data else: return self.tktext_label.configure(image=image) self.tktext_label.image = image @@ -862,7 +867,7 @@ class FlexForm: ''' Display a user defined for and return the filled in data ''' - def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=None, auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, return_keyboard_events=False): + def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=None, auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, return_keyboard_events=False, use_default_focus=True, text_justification=None): self.AutoSizeText = auto_size_text if auto_size_text is not None else DEFAULT_AUTOSIZE_TEXT self.AutoSizeButtons = auto_size_buttons if auto_size_buttons is not None else DEFAULT_AUTOSIZE_BUTTONS self.Title = title @@ -895,8 +900,10 @@ def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT self.DictionaryKeyCounter = 0 self.LastButtonClicked = None self.UseDictionary = False - self.UseDefaultFocus = False + self.UseDefaultFocus = use_default_focus self.ReturnKeyboardEvents = return_keyboard_events + self.LastKeyboardEvent = None + self.TextJustification = text_justification # ------------------------- Add ONE Row to Form ------------------------- # def AddRow(self, *args): @@ -953,10 +960,15 @@ def Show(self, non_blocking=False): except: pass - if not found_focus: + if not found_focus and self.UseDefaultFocus: self.UseDefaultFocus = True + else: + self.UseDefaultFocus = False # -=-=-=-=-=-=-=-=- RUN the GUI -=-=-=-=-=-=-=-=- ## StartupTK(self) + # If a button or keyboard event happened but no results have been built, build the results + if self.LastKeyboardEvent is not None or self.LastButtonClicked is not None: + return BuildResults(self, False, self) return self.ReturnValues # ------------------------- SetIcon - set the window's fav icon ------------------------- # @@ -994,11 +1006,18 @@ def Read(self): if not self.Shown: self.Show() else: + InitializeResults(self) self.TKroot.mainloop() if self.RootNeedsDestroying: self.TKroot.destroy() _my_windows.Decrement() - return BuildResults(self, False, self) + # if self.ReturnValues[0] is not None: # keyboard events build their own return values + # return self.ReturnValues + if self.LastKeyboardEvent is not None or self.LastButtonClicked is not None: + return BuildResults(self, False, self) + else: + return self.ReturnValues + def ReadNonBlocking(self, Message=''): if self.TKrootDestroyed: @@ -1015,14 +1034,31 @@ def ReadNonBlocking(self, Message=''): return BuildResults(self, False, self) def KeyboardCallback(self, event ): - print("pressed", event) + self.LastButtonClicked = None + self.FormRemainedOpen = True + if event.char != '': + self.LastKeyboardEvent = event.char + else: + self.LastKeyboardEvent = str(event.keysym) + ':' + str(event.keycode) + if not self.NonBlocking: + BuildResults(self, False, self) + self.TKroot.quit() + + def MouseWheelCallback(self, event ): + self.LastButtonClicked = None + self.FormRemainedOpen = True + self.LastKeyboardEvent = 'MouseWheel:' + 'Down' if event.delta < 0 else 'Up' + if not self.NonBlocking: + BuildResults(self, False, self) + self.TKroot.quit() + def _Close(self): try: self.TKroot.update() except: pass if not self.NonBlocking: - results = BuildResults(self, False, self) + BuildResults(self, False, self) if self.TKrootDestroyed: return None self.TKrootDestroyed = True @@ -1128,7 +1164,7 @@ def FileSaveAs(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_ # ------------------------- SAVE AS Element lazy function ------------------------- # def SaveAs(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Save As...', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): - return Button(BUTTON_TYPE_BROWSE_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) + return Button(BUTTON_TYPE_SAVEAS_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) # ------------------------- SAVE BUTTON Element lazy function ------------------------- # def Save(button_text='Save', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True,font=None, focus=False): @@ -1247,7 +1283,7 @@ def BuildResultsForSubform(form, initialize_only, top_level_form): if not initialize_only: if element.Type == ELEM_TYPE_INPUT_TEXT: value=element.TKStringVar.get() - if not top_level_form.NonBlocking and not element.do_not_clear: + if not top_level_form.NonBlocking and not element.do_not_clear and not top_level_form.ReturnKeyboardEvents: element.TKStringVar.set('') elif element.Type == ELEM_TYPE_INPUT_CHECKBOX: value = element.TKIntVar.get() @@ -1282,7 +1318,7 @@ def BuildResultsForSubform(form, initialize_only, top_level_form): elif element.Type == ELEM_TYPE_INPUT_MULTILINE: try: value=element.TKText.get(1.0, tk.END) - if not top_level_form.NonBlocking and not element.do_not_clear: + if not top_level_form.NonBlocking and not element.do_not_clear and not top_level_form.ReturnKeyboardEvents: element.TKText.delete('1.0', tk.END) except: value = None @@ -1295,6 +1331,10 @@ def BuildResultsForSubform(form, initialize_only, top_level_form): AddToReturnList(form, value) AddToReturnDictionary(top_level_form, element, value) + if form.ReturnKeyboardEvents and form.LastKeyboardEvent is not None: + button_pressed_text = form.LastKeyboardEvent + form.LastKeyboardEvent = None + try: form.ReturnValuesDictionary.pop(None, None) # clean up dictionary include None was included except: pass @@ -1383,8 +1423,14 @@ def CharWidthInPixels(): stringvar.set(display_text) if auto_size_text: width = 0 - justify = tk.LEFT if element.Justification == 'left' else tk.CENTER if element.Justification == 'center' else tk.RIGHT - anchor = tk.NW if element.Justification == 'left' else tk.N if element.Justification == 'center' else tk.NE + if element.Justification is not None: + justification = element.Justification + elif toplevel_form.TextJustification is not None: + justification = toplevel_form.TextJustification + else: + justification = DEFAULT_TEXT_JUSTIFICATION + justify = tk.LEFT if justification == 'left' else tk.CENTER if justification == 'center' else tk.RIGHT + anchor = tk.NW if justification == 'left' else tk.N if justification == 'center' else tk.NE tktext_label = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height, justify=justify, bd=border_depth) # tktext_label = tk.Label(tk_row_frame,anchor=tk.NW, text=display_text, width=width, height=height, justify=tk.LEFT, bd=border_depth) # Set wrap-length for text (in PIXELS) == PAIN IN THE ASS @@ -1768,8 +1814,12 @@ def StartupTK(my_flex_form): # root.bind('', MyFlexForm.DestroyedCallback()) ConvertFlexToTK(my_flex_form) my_flex_form.SetIcon(my_flex_form.WindowIcon) - if my_flex_form.ReturnKeyboardEvents: + if my_flex_form.ReturnKeyboardEvents and not my_flex_form.NonBlocking: + root.bind("", my_flex_form.KeyboardCallback) + root.bind("", my_flex_form.MouseWheelCallback) + elif my_flex_form.ReturnKeyboardEvents: root.bind("", my_flex_form.KeyboardCallback) + root.bind("", my_flex_form.MouseWheelCallback) if my_flex_form.AutoClose: duration = DEFAULT_AUTOCLOSE_TIME if my_flex_form.AutoCloseDuration is None else my_flex_form.AutoCloseDuration @@ -2576,11 +2626,15 @@ def ChangeLookAndFeel(index): sprint=ScrolledTextBox # Converts an object's contents into a nice printable string. Great for dumping debug data -def ObjToString_old(obj): +def ObjToStringSingleObj(obj): + if obj is None: + return 'None' return str(obj.__class__) + '\n' + '\n'.join( (repr(item) + ' = ' + repr(obj.__dict__[item]) for item in sorted(obj.__dict__))) def ObjToString(obj, extra=' '): + if obj is None: + return 'None' return str(obj.__class__) + '\n' + '\n'.join( (extra + (str(item) + ' = ' + (ObjToString(obj.__dict__[item], extra + ' ') if hasattr(obj.__dict__[item], '__dict__') else str( From c765f1f6f754fe8d6a6fd3321c5dd474c9ebf2e8 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 21 Aug 2018 19:10:26 -0400 Subject: [PATCH 175/209] Manually moving from Dev Latest on PC --- Demo_Keyboard.py | 17 +++++++---------- Demo_Keyboard_Realtime.py | 15 ++++++--------- Demo_PDF_Viewer.py | 4 +++- PySimpleGUI.py | 16 ---------------- 4 files changed, 16 insertions(+), 36 deletions(-) diff --git a/Demo_Keyboard.py b/Demo_Keyboard.py index 85f63b8a9..88c5fc5dc 100644 --- a/Demo_Keyboard.py +++ b/Demo_Keyboard.py @@ -1,26 +1,23 @@ -import sys import PySimpleGUI as sg # Recipe for getting keys, one at a time as they are released # If want to use the space bar, then be sure and disable the "default focus" -with sg.FlexForm('Realtime Keyboard Test', return_keyboard_events=True, use_default_focus=False) as form: - text_elem = sg.Text('', size=(12,1)) - layout = [[sg.Text('Press a key')], +with sg.FlexForm("Keyboard Test", return_keyboard_events=True, use_default_focus=False) as form: + text_elem = sg.Text("", size=(18,1)) + layout = [[sg.Text("Press a key or scroll mouse")], [text_elem], - [sg.SimpleButton('OK')]] + [sg.SimpleButton("OK")]] form.Layout(layout) # ---===--- Loop taking in user input --- # while True: - button, value = form.Read() + button, value = form.ReadNonBlocking() - if button == 'OK': - print(button, 'exiting') + if button == "OK" or (button is None and value is None): + print(button, "exiting") break if button is not None: text_elem.Update(button) - else: - break diff --git a/Demo_Keyboard_Realtime.py b/Demo_Keyboard_Realtime.py index bb1d145e5..258120240 100644 --- a/Demo_Keyboard_Realtime.py +++ b/Demo_Keyboard_Realtime.py @@ -1,19 +1,16 @@ import PySimpleGUI as sg -# Recipe for getting a continuous stream of keys when using a non-blocking form -# If want to use the space bar, then be sure and disable the "default focus" - -with sg.FlexForm('Realtime Keyboard Test', return_keyboard_events=True, use_default_focus=False) as form: - layout = [[sg.Text('Hold down a key')], - [sg.SimpleButton('OK')]] +with sg.FlexForm("Realtime Keyboard Test", return_keyboard_events=True, use_default_focus=False) as form: + layout = [[sg.Text("Hold down a key")], + [sg.SimpleButton("OK")]] form.Layout(layout) - # ---===--- Loop taking in user input --- # + while True: button, value = form.ReadNonBlocking() - if button == 'OK': - print(button, value, 'exiting') + if button == "OK": + print(button, value, "exiting") break if button is not None: print(button) diff --git a/Demo_PDF_Viewer.py b/Demo_PDF_Viewer.py index ecd60c9c5..6fd5fb424 100644 --- a/Demo_PDF_Viewer.py +++ b/Demo_PDF_Viewer.py @@ -37,6 +37,8 @@ import PySimpleGUI as sg from binascii import hexlify +sg.ChangeLookAndFeel('GreenTan') + if len(sys.argv) == 1: rc, fname = sg.GetFileBox('PDF Browser', 'PDF file to open', file_types=(("PDF Files", "*.pdf"),)) if rc is False: @@ -126,7 +128,7 @@ def get_page(pno, zoom=0): if button is None: continue - if button in ("Escape:27"): # this spares me a 'Quit' button! + if button in ("Escape:27",): # this spares me a 'Quit' button! break # print("hex(button)", hexlify(button.encode())) if button[0] == chr(13): # surprise: this is 'Enter'! diff --git a/PySimpleGUI.py b/PySimpleGUI.py index ffdec2b7c..8cbed783d 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -867,10 +867,6 @@ class FlexForm: ''' Display a user defined for and return the filled in data ''' -<<<<<<< HEAD -======= - ->>>>>>> 531b32ab66746c9f4b6acd2ea8b6d113cb235827 def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=None, auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, return_keyboard_events=False, use_default_focus=True, text_justification=None): self.AutoSizeText = auto_size_text if auto_size_text is not None else DEFAULT_AUTOSIZE_TEXT self.AutoSizeButtons = auto_size_buttons if auto_size_buttons is not None else DEFAULT_AUTOSIZE_BUTTONS @@ -1038,10 +1034,6 @@ def ReadNonBlocking(self, Message=''): return BuildResults(self, False, self) def KeyboardCallback(self, event ): -<<<<<<< HEAD -======= - ->>>>>>> 531b32ab66746c9f4b6acd2ea8b6d113cb235827 self.LastButtonClicked = None self.FormRemainedOpen = True if event.char != '': @@ -1060,10 +1052,6 @@ def MouseWheelCallback(self, event ): BuildResults(self, False, self) self.TKroot.quit() -<<<<<<< HEAD -======= - ->>>>>>> 531b32ab66746c9f4b6acd2ea8b6d113cb235827 def _Close(self): try: @@ -1826,10 +1814,6 @@ def StartupTK(my_flex_form): # root.bind('', MyFlexForm.DestroyedCallback()) ConvertFlexToTK(my_flex_form) my_flex_form.SetIcon(my_flex_form.WindowIcon) -<<<<<<< HEAD -======= - ->>>>>>> 531b32ab66746c9f4b6acd2ea8b6d113cb235827 if my_flex_form.ReturnKeyboardEvents and not my_flex_form.NonBlocking: root.bind("", my_flex_form.KeyboardCallback) root.bind("", my_flex_form.MouseWheelCallback) From 1889a706f864f99a588a54b56aeda53d0bdf5d81 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 21 Aug 2018 20:21:03 -0400 Subject: [PATCH 176/209] Fix mouse up bug --- PySimpleGUI.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 4dae3cb99..5b8202ac5 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -867,7 +867,6 @@ class FlexForm: ''' Display a user defined for and return the filled in data ''' - def __init__(self, title, default_element_size=(DEFAULT_ELEMENT_SIZE[0], DEFAULT_ELEMENT_SIZE[1]), auto_size_text=None, auto_size_buttons=None, scale=(None, None), location=(None, None), button_color=None, font=None, progress_bar_color=(None, None), background_color=None, is_tabbed_form=False, border_depth=None, auto_close=False, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, return_keyboard_events=False, use_default_focus=True, text_justification=None): self.AutoSizeText = auto_size_text if auto_size_text is not None else DEFAULT_AUTOSIZE_TEXT self.AutoSizeButtons = auto_size_buttons if auto_size_buttons is not None else DEFAULT_AUTOSIZE_BUTTONS @@ -1035,7 +1034,6 @@ def ReadNonBlocking(self, Message=''): return BuildResults(self, False, self) def KeyboardCallback(self, event ): - self.LastButtonClicked = None self.FormRemainedOpen = True if event.char != '': @@ -1049,13 +1047,12 @@ def KeyboardCallback(self, event ): def MouseWheelCallback(self, event ): self.LastButtonClicked = None self.FormRemainedOpen = True - self.LastKeyboardEvent = 'MouseWheel:' + 'Down' if event.delta < 0 else 'Up' + self.LastKeyboardEvent = 'MouseWheel:Down' if event.delta < 0 else 'MouseWheel:Up' if not self.NonBlocking: BuildResults(self, False, self) self.TKroot.quit() - def _Close(self): try: self.TKroot.update() @@ -1817,7 +1814,6 @@ def StartupTK(my_flex_form): # root.bind('', MyFlexForm.DestroyedCallback()) ConvertFlexToTK(my_flex_form) my_flex_form.SetIcon(my_flex_form.WindowIcon) - if my_flex_form.ReturnKeyboardEvents and not my_flex_form.NonBlocking: root.bind("", my_flex_form.KeyboardCallback) root.bind("", my_flex_form.MouseWheelCallback) From 1b0f7488d0bec9561cdb6609496fdace793ca393 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 21 Aug 2018 20:21:27 -0400 Subject: [PATCH 177/209] Fix mousewheel up bug --- PySimpleGUI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 8cbed783d..5b8202ac5 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1047,7 +1047,7 @@ def KeyboardCallback(self, event ): def MouseWheelCallback(self, event ): self.LastButtonClicked = None self.FormRemainedOpen = True - self.LastKeyboardEvent = 'MouseWheel:' + 'Down' if event.delta < 0 else 'Up' + self.LastKeyboardEvent = 'MouseWheel:Down' if event.delta < 0 else 'MouseWheel:Up' if not self.NonBlocking: BuildResults(self, False, self) self.TKroot.quit() From 150779ba1c745f84106799e922367691d75dd1c2 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 22 Aug 2018 11:37:51 -0400 Subject: [PATCH 178/209] New "get" methods. Get+Update for Checkboxes, Get for TextInput, Get for Multiline, New shortcut funcs --- PySimpleGUI.py | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 5b8202ac5..ef4e8e779 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -239,6 +239,9 @@ def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto def Update(self, new_value): self.TKStringVar.set(new_value) + def Get(self): + return self.TKStringVar.get() + def __del__(self): super().__del__() @@ -359,15 +362,22 @@ def __init__(self, text, default=False, scale=(None, None), size=(None, None), a self.Text = text self.InitialState = default self.Value = None - self.TKCheckbox = None + self.TKCheckbutton = None super().__init__(ELEM_TYPE_INPUT_CHECKBOX, scale=scale, size=size, auto_size_text=auto_size_text, font=font, background_color=background_color, text_color=text_color, key=key) + def Get(self): + return self.TKIntVar.get() + + def Update(self, value): + if value is None: + self.TKCheckbutton.configure(state='disabled') + else: + self.TKCheckbutton.configure(state='normal') + self.TKIntVar.set(value) + + def __del__(self): - try: - self.TKCheckbox.__del__() - except: - pass super().__del__() # ---------------------------------------------------------------------- # @@ -431,6 +441,10 @@ def __init__(self, default_text='', enter_submits = False, scale=(None, None), s def Update(self, NewValue): self.TKText.insert(1.0, NewValue) + def Get(self): + return self.TKText.get(1.0, tk.END) + + def __del__(self): super().__del__() @@ -521,7 +535,7 @@ def __del__(self): # TKOutput # # New Type of TK Widget that's a Text Widget in disguise # # Note that it's inherited from the TKFrame class so that the # -# Scroll bar will span the length of the frame +# Scroll bar will span the length of the frame # # ---------------------------------------------------------------------- # class TKOutput(tk.Frame): def __init__(self, parent, width, height, bd, background_color=None, text_color=None): @@ -1134,6 +1148,11 @@ def In(default_text ='', scale=(None, None), size=(None, None), auto_size_text=N def Input(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None, text_color=None, do_not_clear=False, key=None, focus=False): return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, password_char=password_char, background_color=background_color, text_color=text_color, do_not_clear=do_not_clear, focus=focus, key=key) +# ------------------------- CHECKBOX Element lazy functions ------------------------- # +CB = Checkbox +CBox = Checkbox +Check = Checkbox + # ------------------------- INPUT COMBO Element lazy functions ------------------------- # def Combo(values, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None): return InputCombo(values=values, scale=scale, size=size, auto_size_text=auto_size_text, background_color=background_color) From b975c4f18872712481d7efc88ac2a64d3c0ec496 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 22 Aug 2018 13:58:04 -0400 Subject: [PATCH 179/209] Image.Update now resizes TK Label that contains it, removed wraplen setting in text label configure Having trouble with text wrapping. Ended up removing the wraplen from call to tktext_label.configure. --- PySimpleGUI.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index ef4e8e779..f2d112ffa 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -788,7 +788,8 @@ def Update(self, filename=None, data=None): else: image = data else: return - self.tktext_label.configure(image=image) + width, height = image.width(), image.height() + self.tktext_label.configure(image=image, width=width, height=height) self.tktext_label.image = image def __del__(self): @@ -1454,7 +1455,7 @@ def CharWidthInPixels(): # tktext_label = tk.Label(tk_row_frame,anchor=tk.NW, text=display_text, width=width, height=height, justify=tk.LEFT, bd=border_depth) # Set wrap-length for text (in PIXELS) == PAIN IN THE ASS wraplen = tktext_label.winfo_reqwidth() # width of widget in Pixels - tktext_label.configure(anchor=anchor, font=font, wraplen=wraplen*2 ) # set wrap to width of widget + tktext_label.configure(anchor=anchor, font=font) # set wrap to width of widget if element.BackgroundColor is not None: tktext_label.configure(background=element.BackgroundColor) if element.TextColor != COLOR_SYSTEM_DEFAULT and element.TextColor is not None: From 945625b388a0226e9c5f475c55ff82a4afd7560e Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 22 Aug 2018 14:35:33 -0400 Subject: [PATCH 180/209] More Wraplength changes for Text Elements Struggling to get wrapping to work --- PySimpleGUI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index f2d112ffa..c3fb2e940 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1455,7 +1455,7 @@ def CharWidthInPixels(): # tktext_label = tk.Label(tk_row_frame,anchor=tk.NW, text=display_text, width=width, height=height, justify=tk.LEFT, bd=border_depth) # Set wrap-length for text (in PIXELS) == PAIN IN THE ASS wraplen = tktext_label.winfo_reqwidth() # width of widget in Pixels - tktext_label.configure(anchor=anchor, font=font) # set wrap to width of widget + tktext_label.configure(anchor=anchor, font=font, wraplen=wraplen+10) # set wrap to width of widget if element.BackgroundColor is not None: tktext_label.configure(background=element.BackgroundColor) if element.TextColor != COLOR_SYSTEM_DEFAULT and element.TextColor is not None: From 3f64564ad212e9408516b4f8b03c9e1db671b362 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 22 Aug 2018 15:48:28 -0400 Subject: [PATCH 181/209] Fix for column crash due to keyboard feature, struggling with message box sizes and wrapping --- PySimpleGUI.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index c3fb2e940..b9c9b24a7 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1351,9 +1351,12 @@ def BuildResultsForSubform(form, initialize_only, top_level_form): AddToReturnList(form, value) AddToReturnDictionary(top_level_form, element, value) - if form.ReturnKeyboardEvents and form.LastKeyboardEvent is not None: - button_pressed_text = form.LastKeyboardEvent - form.LastKeyboardEvent = None + # if this is a column, then will fail so need to wrap with tr + try: + if form.ReturnKeyboardEvents and form.LastKeyboardEvent is not None: + button_pressed_text = form.LastKeyboardEvent + form.LastKeyboardEvent = None + except: pass try: form.ReturnValuesDictionary.pop(None, None) # clean up dictionary include None was included @@ -1455,12 +1458,13 @@ def CharWidthInPixels(): # tktext_label = tk.Label(tk_row_frame,anchor=tk.NW, text=display_text, width=width, height=height, justify=tk.LEFT, bd=border_depth) # Set wrap-length for text (in PIXELS) == PAIN IN THE ASS wraplen = tktext_label.winfo_reqwidth() # width of widget in Pixels - tktext_label.configure(anchor=anchor, font=font, wraplen=wraplen+10) # set wrap to width of widget + tktext_label.configure(anchor=anchor, font=font, wraplen=0) # set wrap to width of widget if element.BackgroundColor is not None: tktext_label.configure(background=element.BackgroundColor) if element.TextColor != COLOR_SYSTEM_DEFAULT and element.TextColor is not None: tktext_label.configure(fg=element.TextColor) tktext_label.pack(side=tk.LEFT) + # print(f'Text element placed w = {width}, h = {height}, wrap = {wraplen}') # ------------------------- BUTTON element ------------------------- # elif element_type == ELEM_TYPE_BUTTON: element.Location = (row_num, col_num) @@ -1921,7 +1925,7 @@ def MsgBox(*args, button_color=None, button_type=MSG_BOX_OK, auto_close=False, a max_line_total = max(max_line_total, width_used) # height = _GetNumLinesNeeded(message, width_used) height = message_wrapped_lines - form.AddRow(Text(message_wrapped, auto_size_text=True)) + form.AddRow(Text(message_wrapped, auto_size_text=True, size=(width_used, height))) total_lines += height pad = max_line_total-15 if max_line_total > 15 else 1 @@ -2665,7 +2669,7 @@ def ObjToString(obj, extra=' '): def main(): with FlexForm('Demo form..') as form: form_rows = [[Text('You are running the PySimpleGUI.py file itself')], - [Text('You should be importing it rather than running it\n')], + [Text('You should be importing it rather than running it', size=(50,2))], [Text('Here is your sample input form....')], [Text('Source Folder', size=(15, 1), justification='right'), InputText('Source', focus=True),FolderBrowse()], [Text('Destination Folder', size=(15, 1), justification='right'), InputText('Dest'), FolderBrowse()], From 6547a1b689ab2534ef0cc1ef1fe19101c5b3a9ed Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 22 Aug 2018 17:01:30 -0400 Subject: [PATCH 182/209] Demo of PNG file viewer --- Demo_PNG_Viewer.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Demo_PNG_Viewer.py diff --git a/Demo_PNG_Viewer.py b/Demo_PNG_Viewer.py new file mode 100644 index 000000000..463f3a8c9 --- /dev/null +++ b/Demo_PNG_Viewer.py @@ -0,0 +1,56 @@ +import PySimpleGUI as sg +import os + +# Simple Image Browser based on PySimpleGUI + +# sg.ChangeLookAndFeel('GreenTan') + +# Get the folder containing the images from the user +rc, folder = sg.GetPathBox('Image Browser', 'Image folder to open', default_path='A:/TEMP/PDFs') +if rc is False or folder is '': + sg.MsgBoxCancel('Cancelling') + exit(0) + +# get list of PNG files in folder +png_files = [folder + '\\' + f for f in os.listdir(folder) if '.png' in f] + +if len(png_files) == 0: + sg.MsgBox('No PNG images in folder') + exit(0) + +# create the form +form = sg.FlexForm('Image Browser', return_keyboard_events=True) + +# make these 2 elements outside the layout because want to "update" them later +image_elem = sg.Image(filename=png_files[0]) +text_elem = sg.Text(png_files[0], size=(80,3)) + +# define layout, show and read the form +layout = [[text_elem], + [image_elem], + [sg.ReadFormButton('Next', size=(8,2)), sg.ReadFormButton('Prev', size=(8,2))]] + +form.LayoutAndRead(layout) + +# loop reading the user input and display each image and the filename +i=0 +while True: + f = png_files[i] + # update window with new image + image_elem.Update(filename=f) + # update window with filename + text_elem.Update(f) + # read the form + button, values = form.Read() + + # perform button operations + if button is None: + break + elif button in ('Next', 'MouseWheel:Down', 'Down:40', 'Next:34') and i < len(png_files): + i += 1 + elif button in ('Prev', 'MouseWheel:Up', 'Up:38', 'Prior:33') and i > 0: + i -= 1 + # else: + # print(button) + + From b1829438a952e72f641e6e36f82eed0e1ebb5c83 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 22 Aug 2018 17:14:58 -0400 Subject: [PATCH 183/209] Adjusted wraplength, Updated demo program that displays PNG files --- Demo_PNG_Viewer.py | 25 +++++++++++++------------ PySimpleGUI.py | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Demo_PNG_Viewer.py b/Demo_PNG_Viewer.py index 463f3a8c9..4729d9c3c 100644 --- a/Demo_PNG_Viewer.py +++ b/Demo_PNG_Viewer.py @@ -3,8 +3,6 @@ # Simple Image Browser based on PySimpleGUI -# sg.ChangeLookAndFeel('GreenTan') - # Get the folder containing the images from the user rc, folder = sg.GetPathBox('Image Browser', 'Image folder to open', default_path='A:/TEMP/PDFs') if rc is False or folder is '': @@ -18,39 +16,42 @@ sg.MsgBox('No PNG images in folder') exit(0) -# create the form +# create the form that also returns keyboard events form = sg.FlexForm('Image Browser', return_keyboard_events=True) # make these 2 elements outside the layout because want to "update" them later +# initialize to the first PNG file in the list image_elem = sg.Image(filename=png_files[0]) -text_elem = sg.Text(png_files[0], size=(80,3)) +filename_display_elem = sg.Text(png_files[0], size=(80, 3)) +file_num_display_elem = sg.Text('File 1 of {}'.format(len(png_files)), size=(10,1)) # define layout, show and read the form -layout = [[text_elem], +layout = [[filename_display_elem], [image_elem], - [sg.ReadFormButton('Next', size=(8,2)), sg.ReadFormButton('Prev', size=(8,2))]] + [sg.ReadFormButton('Next', size=(8,2)), sg.ReadFormButton('Prev', size=(8,2)), file_num_display_elem]] -form.LayoutAndRead(layout) +form.LayoutAndRead(layout) # Shows form on screen -# loop reading the user input and display each image and the filename +# loop reading the user input and displaying image, filename i=0 while True: f = png_files[i] # update window with new image image_elem.Update(filename=f) # update window with filename - text_elem.Update(f) + filename_display_elem.Update(f) + # update page display + file_num_display_elem.Update('File {} of {}'.format(i+1, len(png_files))) # read the form button, values = form.Read() - # perform button operations + # perform button and keyboard operations if button is None: break elif button in ('Next', 'MouseWheel:Down', 'Down:40', 'Next:34') and i < len(png_files): i += 1 elif button in ('Prev', 'MouseWheel:Up', 'Up:38', 'Prior:33') and i > 0: i -= 1 - # else: - # print(button) + diff --git a/PySimpleGUI.py b/PySimpleGUI.py index b9c9b24a7..0233c23df 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1458,7 +1458,7 @@ def CharWidthInPixels(): # tktext_label = tk.Label(tk_row_frame,anchor=tk.NW, text=display_text, width=width, height=height, justify=tk.LEFT, bd=border_depth) # Set wrap-length for text (in PIXELS) == PAIN IN THE ASS wraplen = tktext_label.winfo_reqwidth() # width of widget in Pixels - tktext_label.configure(anchor=anchor, font=font, wraplen=0) # set wrap to width of widget + tktext_label.configure(anchor=anchor, font=font, wraplen=wraplen+40) # set wrap to width of widget if element.BackgroundColor is not None: tktext_label.configure(background=element.BackgroundColor) if element.TextColor != COLOR_SYSTEM_DEFAULT and element.TextColor is not None: From 8f4e0e182a7e70bc6fac42edceaa105b38c7a8be Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 22 Aug 2018 17:47:32 -0400 Subject: [PATCH 184/209] New GetScreenDimension method for FlexForms --- PySimpleGUI.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 0233c23df..9fa1ca910 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1048,6 +1048,14 @@ def ReadNonBlocking(self, Message=''): _my_windows.Decrement() return BuildResults(self, False, self) + def GetScreenDimensions(self): + if self.TKrootDestroyed: + return None, None + screen_width = self.TKroot.winfo_screenwidth() # get window info to move to middle of screen + screen_height = self.TKroot.winfo_screenheight() + return screen_width, screen_height + + def KeyboardCallback(self, event ): self.LastButtonClicked = None self.FormRemainedOpen = True From 9a8ece087e7761880a314c489e6d710a4b8b73d8 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 23 Aug 2018 12:30:35 -0400 Subject: [PATCH 185/209] Support for Listbox.Update --- PySimpleGUI.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 9fa1ca910..51ac0bfc5 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -290,7 +290,7 @@ def __init__(self, values, select_mode=None, scale=(None, None), size=(None, Non :param auto_size_text: True if should shrink field to fit the default text :param background_color: Color for Element. Text or RGB Hex ''' self.Values = values - self.TKListBox = None + self.TKListbox = None if select_mode == LISTBOX_SELECT_MODE_BROWSE: self.SelectMode = SELECT_MODE_BROWSE elif select_mode == LISTBOX_SELECT_MODE_EXTENDED: @@ -305,6 +305,12 @@ def __init__(self, values, select_mode=None, scale=(None, None), size=(None, Non fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR super().__init__(ELEM_TYPE_INPUT_LISTBOX, scale=scale, size=size, auto_size_text=auto_size_text, font=font, background_color=bg, text_color=fg, key=key) + def Update(self, values): + self.TKListbox.delete(0, 'end') + for item in values: + self.TKListbox.insert(tk.END, item) + self.TKListbox.selection_set(0, 0) + def __del__(self): try: self.TKListBox.__del__() From dcbbf319ebddd24e6bfd77b66b08697abb85467a Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 23 Aug 2018 12:45:51 -0400 Subject: [PATCH 186/209] Update method for Text Element now includes colors --- PySimpleGUI.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 51ac0bfc5..78430d43c 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -482,10 +482,15 @@ def __init__(self, text, scale=(None, None), size=(None, None), auto_size_text=N super().__init__(ELEM_TYPE_TEXT, scale, size, auto_size_text, background_color=bg, font=font if font else DEFAULT_FONT, text_color=self.TextColor) return - def Update(self, NewValue): - self.DisplayText=NewValue - stringvar = self.TKStringVar - stringvar.set(NewValue) + def Update(self, new_value = None, background_color=None, text_color=None): + if new_value is not None: + self.DisplayText=new_value + stringvar = self.TKStringVar + stringvar.set(new_value) + if background_color is not None: + self.TKText.configure(background=background_color) + if text_color is not None: + self.TKText.configure(fg=text_color) def __del__(self): super().__del__() @@ -1478,6 +1483,7 @@ def CharWidthInPixels(): if element.TextColor != COLOR_SYSTEM_DEFAULT and element.TextColor is not None: tktext_label.configure(fg=element.TextColor) tktext_label.pack(side=tk.LEFT) + element.TKText = tktext_label # print(f'Text element placed w = {width}, h = {height}, wrap = {wraplen}') # ------------------------- BUTTON element ------------------------- # elif element_type == ELEM_TYPE_BUTTON: From dad31df5479bace26a9e7198946f4eb52c0663d2 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 23 Aug 2018 13:17:58 -0400 Subject: [PATCH 187/209] New simple persistent form. --- docs/cookbook.md | 53 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/docs/cookbook.md b/docs/cookbook.md index 61e581c04..256b2cbfc 100644 --- a/docs/cookbook.md +++ b/docs/cookbook.md @@ -57,7 +57,7 @@ Browse for a filename that is populated into the input field. import PySimpleGUI as sg - with sg.FlexForm('SHA-1 & 256 Hash', auto_size_text=True) as form: + with sg.FlexForm('SHA-1 & 256 Hash') as form: form_rows = [[sg.Text('SHA-1 and SHA-256 Hashes for the file')], [sg.InputText(), sg.FileBrowse()], [sg.Submit(), sg.Cancel()]] @@ -101,7 +101,7 @@ Example of nearly all of the widgets in a single form. Uses a customized color progress_meter_border_depth=0, scrollbar_color='#F7F3EC') - with sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) as form: + with sg.FlexForm('Everything bagel', default_element_size=(40, 1)) as form: layout = [ [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25))], [sg.Text('Here is some text.... and a place to enter text')], @@ -141,7 +141,7 @@ Example of nearly all of the widgets in a single form. Uses a customized color progress_meter_border_depth=0, scrollbar_color='#F7F3EC') - form = sg.FlexForm('Everything bagel', auto_size_text=True, default_element_size=(40, 1)) + form = sg.FlexForm('Everything bagel', default_element_size=(40, 1)) layout = [ [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25))], [sg.Text('Here is some text.... and a place to enter text')], @@ -175,7 +175,7 @@ An async form that has a button read loop. A Text Element is updated periodical import PySimpleGUI as sg import time - form = sg.FlexForm('Running Timer', auto_size_text=True) + form = sg.FlexForm('Running Timer') # create a text element that will be updated periodically text_element = sg.Text('', size=(10, 2), font=('Helvetica', 20), justification='center') @@ -210,7 +210,7 @@ Like the previous recipe, this form is an async form. The difference is that th import PySimpleGUI as sg import time - with sg.FlexForm('Running Timer', auto_size_text=True) as form: + with sg.FlexForm('Running Timer') as form: text_element = sg.Text('', size=(10, 2), font=('Helvetica', 20), text_color='red', justification='center') layout = [[sg.Text('Non blocking GUI with updates', justification='center')], [text_element], @@ -249,7 +249,7 @@ The architecture of some programs works better with button callbacks instead of # Create a standard form form = sg.FlexForm('Button callback example') # Layout the design of the GUI - layout = [[sg.Text('Please click a button', auto_size_text=True)], + layout = [[sg.Text('Please click a button')], [sg.ReadFormButton('1'), sg.ReadFormButton('2'), sg.Quit()]] # Show the form to the user form.Layout(layout) @@ -593,3 +593,44 @@ To make it easier to see the Column in the window, the Column background has bee button, values = sg.FlexForm('Compact 1-line form with column').LayoutAndRead(layout) sg.MsgBox(button, values, line_width=200) + + +## Persistent Form With Text Element Updates + +This simple program keep a form open, taking input values until the user terminates the program using the "X" button. + +![math game](https://user-images.githubusercontent.com/13696193/44537842-c9444080-a6cd-11e8-94bc-6cdf1b765dd8.jpg) + + + + import PySimpleGUI as sg + + form = sg.FlexForm('Math') + + output = sg.Txt('', size=(8,1)) + + layout = [ [sg.Txt('Enter values to calculate')], + [sg.In(size=(8,1), key='numerator')], + [sg.Txt('_' * 10)], + [sg.In(size=(8,1), key='denominator')], + [output], + [sg.ReadFormButton('Calculate', bind_return_key=True)]] + + form.Layout(layout) + + while True: + button, values = form.Read() + + if button is not None: + try: + numerator = float(values['numerator']) + denominator = float(values['denominator']) + calc = numerator / denominator + except: + calc = 'Invalid' + + output.Update(calc) + else: + break + + From a57fc797063b74327b34d3656da017150db451c4 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 23 Aug 2018 13:50:20 -0400 Subject: [PATCH 188/209] Update method for Buttons --- PySimpleGUI.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 78430d43c..1b34a341d 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -715,6 +715,9 @@ def ButtonCallBack(self): self.ParentForm.TKroot.quit() # kick the users out of the mainloop return + def Update(self, new_text): + self.TKButton.configure(text=new_text) + def __del__(self): try: self.TKButton.__del__() From fcdd58ae8366b5626f09db568350ca79613d113f Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 23 Aug 2018 14:10:58 -0400 Subject: [PATCH 189/209] Protection around update in case form was manually closed --- PySimpleGUI.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 1b34a341d..0813e8cec 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -716,7 +716,10 @@ def ButtonCallBack(self): return def Update(self, new_text): - self.TKButton.configure(text=new_text) + try: + self.TKButton.configure(text=new_text) + except: + return def __del__(self): try: @@ -1060,6 +1063,7 @@ def ReadNonBlocking(self, Message=''): except: self.TKrootDestroyed = True _my_windows.Decrement() + # return None, None return BuildResults(self, False, self) def GetScreenDimensions(self): From cc96d52ae4d364df9749843f791a00e32fe337dc Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Thu, 23 Aug 2018 14:17:46 -0400 Subject: [PATCH 190/209] Added ability to change button colors using Update method --- PySimpleGUI.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 0813e8cec..0df8a727c 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -715,9 +715,11 @@ def ButtonCallBack(self): self.ParentForm.TKroot.quit() # kick the users out of the mainloop return - def Update(self, new_text): + def Update(self, new_text, button_color=(None, None)): try: self.TKButton.configure(text=new_text) + if button_color != (None, None): + self.TKButton.config(foreground=button_color[0], background=button_color[1]) except: return @@ -1043,8 +1045,6 @@ def Read(self): if self.RootNeedsDestroying: self.TKroot.destroy() _my_windows.Decrement() - # if self.ReturnValues[0] is not None: # keyboard events build their own return values - # return self.ReturnValues if self.LastKeyboardEvent is not None or self.LastButtonClicked is not None: return BuildResults(self, False, self) else: From a2e8b0fad3ec42af7452ad4b770027ed71508460 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 24 Aug 2018 07:45:31 -0400 Subject: [PATCH 191/209] Added Slider Update method, reworking of how Text Elements wrap (risky change), rework how MsgBox wraps Some risky changes to how text wraps, but hopefully these will fix problems of forms being way too wide. Also added Update to Slider Element. This allows it to be used for things like tracking progress in a song being played. --- PySimpleGUI.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 0df8a727c..985bf2441 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -840,6 +840,9 @@ def __init__(self, range=(None,None), default_value=None, orientation=None, bord super().__init__(ELEM_TYPE_INPUT_SLIDER, scale=scale, size=size, font=font, background_color=background_color, text_color=text_color, key=key) return + def Update(self, value): + self.TKIntVar.set(value) + def __del__(self): super().__del__() @@ -1481,17 +1484,18 @@ def CharWidthInPixels(): justify = tk.LEFT if justification == 'left' else tk.CENTER if justification == 'center' else tk.RIGHT anchor = tk.NW if justification == 'left' else tk.N if justification == 'center' else tk.NE tktext_label = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height, justify=justify, bd=border_depth) - # tktext_label = tk.Label(tk_row_frame,anchor=tk.NW, text=display_text, width=width, height=height, justify=tk.LEFT, bd=border_depth) # Set wrap-length for text (in PIXELS) == PAIN IN THE ASS - wraplen = tktext_label.winfo_reqwidth() # width of widget in Pixels - tktext_label.configure(anchor=anchor, font=font, wraplen=wraplen+40) # set wrap to width of widget + wraplen = tktext_label.winfo_reqwidth()+40 # width of widget in Pixels + if not auto_size_text: + wraplen = 0 + # print("wraplen, width, height", wraplen, width, height) + tktext_label.configure(anchor=anchor, font=font, wraplen=wraplen) # set wrap to width of widget if element.BackgroundColor is not None: tktext_label.configure(background=element.BackgroundColor) if element.TextColor != COLOR_SYSTEM_DEFAULT and element.TextColor is not None: tktext_label.configure(fg=element.TextColor) tktext_label.pack(side=tk.LEFT) element.TKText = tktext_label - # print(f'Text element placed w = {width}, h = {height}, wrap = {wraplen}') # ------------------------- BUTTON element ------------------------- # elif element_type == ELEM_TYPE_BUTTON: element.Location = (row_num, col_num) @@ -1952,7 +1956,8 @@ def MsgBox(*args, button_color=None, button_type=MSG_BOX_OK, auto_close=False, a max_line_total = max(max_line_total, width_used) # height = _GetNumLinesNeeded(message, width_used) height = message_wrapped_lines - form.AddRow(Text(message_wrapped, auto_size_text=True, size=(width_used, height))) + # print('Msgbox width, height', width_used, height) + form.AddRow(Text(message_wrapped, auto_size_text=True)) total_lines += height pad = max_line_total-15 if max_line_total > 15 else 1 From 53e0c25a0227c7e4a5ffdb99ab1a89e5b404b0bb Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 24 Aug 2018 07:57:22 -0400 Subject: [PATCH 192/209] Chaned how wrapping in Text Elements work, changed MsgBox to use new wrapping More risky Text Element changes --- PySimpleGUI.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 985bf2441..0fc5f76a4 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1473,7 +1473,7 @@ def CharWidthInPixels(): stringvar = tk.StringVar() element.TKStringVar = stringvar stringvar.set(display_text) - if auto_size_text: + if element.AutoSizeText: width = 0 if element.Justification is not None: justification = element.Justification @@ -1957,7 +1957,7 @@ def MsgBox(*args, button_color=None, button_type=MSG_BOX_OK, auto_close=False, a # height = _GetNumLinesNeeded(message, width_used) height = message_wrapped_lines # print('Msgbox width, height', width_used, height) - form.AddRow(Text(message_wrapped, auto_size_text=True)) + form.AddRow(Text(message_wrapped, auto_size_text=True, size=(width_used, height))) total_lines += height pad = max_line_total-15 if max_line_total > 15 else 1 From 2e3c401e872576a40bf1edc8fa31b5af0ea87482 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 24 Aug 2018 08:03:56 -0400 Subject: [PATCH 193/209] NEW Demo - MIDI player using Mido --- Demo_MIDI_Player.py | 228 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 228 insertions(+) create mode 100644 Demo_MIDI_Player.py diff --git a/Demo_MIDI_Player.py b/Demo_MIDI_Player.py new file mode 100644 index 000000000..3da9b17df --- /dev/null +++ b/Demo_MIDI_Player.py @@ -0,0 +1,228 @@ +import os +import PySimpleGUI as g +import mido +import time + +PLAYER_COMMAND_NONE = 0 +PLAYER_COMMAND_EXIT = 1 +PLAYER_COMMAND_PAUSE = 2 +PLAYER_COMMAND_NEXT = 3 +PLAYER_COMMAND_RESTART_SONG = 4 + +# ---------------------------------------------------------------------- # +# PlayerGUI CLASS # +# ---------------------------------------------------------------------- # +class PlayerGUI(): + ''' + Class implementing GUI for both initial screen but the player itself + ''' + + def __init__(self): + self.Form = None + self.TextElem = None + self.PortList = mido.get_output_names() # use to get the list of midi ports + self.PortList = self.PortList[::-1] # reverse the list so the last one is first + + # ---------------------------------------------------------------------- # + # PlayerChooseSongGUI # + # Show a GUI get to the file to playback # + # ---------------------------------------------------------------------- # + def PlayerChooseSongGUI(self): + + # ---------------------- DEFINION OF CHOOSE WHAT TO PLAY GUI ---------------------------- + with g.FlexForm('MIDI File Player', auto_size_text=False, + default_element_size=(30, 1), + font=("Helvetica", 12)) as form: + layout = [[g.Text('MIDI File Player', font=("Helvetica", 15), size=(20, 1), text_color='green')], + [g.Text('File Selection', font=("Helvetica", 15), size=(20, 1))], + [g.Text('Single File Playback', justification='right'), g.InputText(size=(65, 1), key='midifile'), g.FileBrowse(size=(10, 1), file_types=(("MIDI files", "*.mid"),))], + [g.Text('Or Batch Play From This Folder', auto_size_text=False, justification='right'), g.InputText(size=(65, 1), key='folder'), g.FolderBrowse(size=(10, 1))], + [g.Text('_' * 250, auto_size_text=False, size=(100, 1))], + [g.Text('Choose MIDI Output Device', size=(22, 1)), + g.Listbox(values=self.PortList, size=(30, len(self.PortList) + 1), key='device')], + [g.Text('_' * 250, auto_size_text=False, size=(100, 1))], + [g.SimpleButton('PLAY!', size=(10, 2), button_color=('red', 'white'), font=("Helvetica", 15), bind_return_key=True), g.Text(' ' * 2, size=(4, 1)), g.Cancel(size=(8, 2), font=("Helvetica", 15))]] + + + self.Form = form + return form.LayoutAndRead(layout) + + + def PlayerPlaybackGUIStart(self, NumFiles=1): + # ------- Make a new FlexForm ------- # + + image_pause = './ButtonGraphics/Pause.png' + image_restart = './ButtonGraphics/Restart.png' + image_next = './ButtonGraphics/Next.png' + image_exit = './ButtonGraphics/Exit.png' + + self.TextElem = g.T('Song loading....', size=(85, 5 + NumFiles), font=("Helvetica", 14), auto_size_text=False) + form = g.FlexForm('MIDI File Player', default_element_size=(30, 1),font=("Helvetica", 25)) + layout = [ + [g.T('MIDI File Player', size=(30, 1), font=("Helvetica", 25))], + [self.TextElem], + [g.ReadFormButton('PAUSE', button_color=g.TRANSPARENT_BUTTON, + image_filename=image_pause, image_size=(50,50),image_subsample=2, border_width=0, + font=("Helvetica", 15), size=(10, 2)), g.T(' ' * 3), + g.ReadFormButton('NEXT', button_color=g.TRANSPARENT_BUTTON, + image_filename=image_next, image_size=(50,50),image_subsample=2, border_width=0, + size=(10, 2), font=("Helvetica", 15)), g.T(' ' * 3), + g.ReadFormButton('Restart Song', button_color=g.TRANSPARENT_BUTTON, + image_filename=image_restart, image_size=(50,50), image_subsample=2,border_width=0, + size=(10, 2), font=("Helvetica", 15)), g.T(' ' * 3), + g.T(' '*2), g.SimpleButton('EXIT', button_color=g.TRANSPARENT_BUTTON, + image_filename=image_exit, image_size=(50,50), image_subsample=2,border_width=0, + size=(10, 2), font=("Helvetica", 15))] + ] + + form.LayoutAndRead(layout, non_blocking=True) + self.Form = form + + + + # ------------------------------------------------------------------------- # + # PlayerPlaybackGUIUpdate # + # Refresh the GUI for the main playback interface (must call periodically # + # ------------------------------------------------------------------------- # + def PlayerPlaybackGUIUpdate(self, DisplayString): + form = self.Form + if 'form' not in locals() or form is None: # if the form has been destoyed don't mess with it + return PLAYER_COMMAND_EXIT + self.TextElem.Update(DisplayString) + button, (values) = form.ReadNonBlocking() + if values is None: + return PLAYER_COMMAND_EXIT + if button == 'PAUSE': + return PLAYER_COMMAND_PAUSE + elif button == 'EXIT': + return PLAYER_COMMAND_EXIT + elif button == 'NEXT': + return PLAYER_COMMAND_NEXT + elif button == 'Restart Song': + return PLAYER_COMMAND_RESTART_SONG + return PLAYER_COMMAND_NONE + + +# ---------------------------------------------------------------------- # +# MAIN - our main program... this is it # +# Runs the GUI to get the file / path to play # +# Decodes the MIDI-Video into a MID file # +# Plays the decoded MIDI file # +# ---------------------------------------------------------------------- # +def main(): + def GetCurrentTime(): + ''' + Get the current system time in milliseconds + :return: milliseconds + ''' + return int(round(time.time() * 1000)) + + g.SetOptions(border_width=1, element_padding=(4, 6), font=("Helvetica", 10), button_color=('white', g.BLUES[0]), + progress_meter_border_depth=1, slider_border_width=1) + pback = PlayerGUI() + + button, values = pback.PlayerChooseSongGUI() + if button != 'PLAY!': + g.MsgBoxCancel('Cancelled...\nAutoclose in 2 sec...', auto_close=True, auto_close_duration=2) + exit(69) + if values['device'] is not None: + midi_port = values['device'][0] + else: + g.MsgBoxCancel('No devices found\nAutoclose in 2 sec...', auto_close=True, auto_close_duration=2) + + batch_folder = values['folder'] + midi_filename = values['midifile'] + # ------ Build list of files to play --------------------------------------------------------- # + if batch_folder: + filelist = os.listdir(batch_folder) + filelist = [batch_folder+'/'+f for f in filelist if f.endswith(('.mid', '.MID'))] + filetitles = [os.path.basename(f) for f in filelist] + elif midi_filename: # an individual filename + filelist = [midi_filename,] + filetitles = [os.path.basename(midi_filename),] + else: + g.MsgBoxError('*** Error - No MIDI files specified ***') + exit(666) + + # ------ LOOP THROUGH MULTIPLE FILES --------------------------------------------------------- # + pback.PlayerPlaybackGUIStart(NumFiles=len(filelist) if len(filelist) <=10 else 10) + port = None + # Loop through the files in the filelist + for now_playing_number, current_midi_filename in enumerate(filelist): + display_string = 'Playing Local File...\n{} of {}\n{}'.format(now_playing_number+1, len(filelist), current_midi_filename) + midi_title = filetitles[now_playing_number] + # --------------------------------- REFRESH THE GUI ----------------------------------------- # + pback.PlayerPlaybackGUIUpdate(display_string) + + # ---===--- Output Filename is .MID --- # + midi_filename = current_midi_filename + + # --------------------------------- MIDI - STARTS HERE ----------------------------------------- # + if not port: # if the midi output port not opened yet, then open it + port = mido.open_output(midi_port if midi_port else None) + + try: + mid = mido.MidiFile(filename=midi_filename) + except: + print('****** Exception trying to play MidiFile filename = {}***************'.format(midi_filename)) + g.MsgBoxError('Exception trying to play MIDI file:', midi_filename, 'Skipping file') + continue + + # Build list of data contained in MIDI File using only track 0 + midi_length_in_seconds = mid.length + display_file_list = '>> ' + '\n'.join([f for i, f in enumerate(filelist[now_playing_number:]) if i < 10]) + paused = cancelled = next_file = False + ######################### Loop through MIDI Messages ########################### + while(True): + start_playback_time = GetCurrentTime() + port.reset() + + for midi_msg_number, msg in enumerate(mid.play()): + #################### GUI - read values ################## + if not midi_msg_number % 4: # update the GUI every 4 MIDI messages + t = (GetCurrentTime() - start_playback_time)//1000 + display_midi_len = '{:02d}:{:02d}'.format(*divmod(int(midi_length_in_seconds),60)) + display_string = 'Now Playing {} of {}\n{}\n {:02d}:{:02d} of {}\nPlaylist:'.\ + format(now_playing_number+1, len(filelist), midi_title, *divmod(t, 60), display_midi_len) + # display list of next 10 files to be played. + rc = pback.PlayerPlaybackGUIUpdate(display_string + '\n' + display_file_list) + else: # fake rest of code as if GUI did nothing + rc = PLAYER_COMMAND_NONE + if paused: + rc = PLAYER_COMMAND_NONE + while rc == PLAYER_COMMAND_NONE: # TIGHT-ASS loop waiting on a GUI command + rc = pback.PlayerPlaybackGUIUpdate(display_string) + time.sleep(.25) + + ####################################### MIDI send data ################################## + port.send(msg) + + # ------- Execute GUI Commands after sending MIDI data ------- # + if rc == PLAYER_COMMAND_EXIT: + cancelled = True + break + elif rc == PLAYER_COMMAND_PAUSE: + paused = not paused + port.reset() + elif rc == PLAYER_COMMAND_NEXT: + next_file = True + break + elif rc == PLAYER_COMMAND_RESTART_SONG: + break + + if cancelled or next_file: + break + #------- DONE playing the song ------- # + port.reset() # reset the midi port when done with the song + + if cancelled: + break + exit(69) + +# ---------------------------------------------------------------------- # +# LAUNCH POINT -- program starts and ends here # +# ---------------------------------------------------------------------- # +if __name__ == '__main__': + main() + + exit(69) From 60a6c07b7aac5bca9932a3b8f2d31cfe019987c0 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 24 Aug 2018 08:36:45 -0400 Subject: [PATCH 194/209] Cleanup code --- Demo_MIDI_Player.py | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/Demo_MIDI_Player.py b/Demo_MIDI_Player.py index 3da9b17df..3e0e81b5b 100644 --- a/Demo_MIDI_Player.py +++ b/Demo_MIDI_Player.py @@ -56,23 +56,19 @@ def PlayerPlaybackGUIStart(self, NumFiles=1): image_next = './ButtonGraphics/Next.png' image_exit = './ButtonGraphics/Exit.png' - self.TextElem = g.T('Song loading....', size=(85, 5 + NumFiles), font=("Helvetica", 14), auto_size_text=False) - form = g.FlexForm('MIDI File Player', default_element_size=(30, 1),font=("Helvetica", 25)) + self.TextElem = g.T('Song loading....', size=(85,5 + NumFiles), font=("Helvetica", 14), auto_size_text=False) + form = g.FlexForm('MIDI File Player', default_element_size=(30,1),font=("Helvetica", 25)) layout = [ - [g.T('MIDI File Player', size=(30, 1), font=("Helvetica", 25))], + [g.T('MIDI File Player', size=(30,1), font=("Helvetica", 25))], [self.TextElem], [g.ReadFormButton('PAUSE', button_color=g.TRANSPARENT_BUTTON, - image_filename=image_pause, image_size=(50,50),image_subsample=2, border_width=0, - font=("Helvetica", 15), size=(10, 2)), g.T(' ' * 3), + image_filename=image_pause, image_size=(50,50),image_subsample=2, border_width=0), g.T(' '), g.ReadFormButton('NEXT', button_color=g.TRANSPARENT_BUTTON, - image_filename=image_next, image_size=(50,50),image_subsample=2, border_width=0, - size=(10, 2), font=("Helvetica", 15)), g.T(' ' * 3), + image_filename=image_next, image_size=(50,50),image_subsample=2, border_width=0), g.T(' '), g.ReadFormButton('Restart Song', button_color=g.TRANSPARENT_BUTTON, - image_filename=image_restart, image_size=(50,50), image_subsample=2,border_width=0, - size=(10, 2), font=("Helvetica", 15)), g.T(' ' * 3), - g.T(' '*2), g.SimpleButton('EXIT', button_color=g.TRANSPARENT_BUTTON, - image_filename=image_exit, image_size=(50,50), image_subsample=2,border_width=0, - size=(10, 2), font=("Helvetica", 15))] + image_filename=image_restart, image_size=(50,50), image_subsample=2, border_width=0), g.T(' '), + g.SimpleButton('EXIT', button_color=g.TRANSPARENT_BUTTON, + image_filename=image_exit, image_size=(50,50), image_subsample=2, border_width=0,)] ] form.LayoutAndRead(layout, non_blocking=True) @@ -117,15 +113,13 @@ def GetCurrentTime(): ''' return int(round(time.time() * 1000)) - g.SetOptions(border_width=1, element_padding=(4, 6), font=("Helvetica", 10), button_color=('white', g.BLUES[0]), - progress_meter_border_depth=1, slider_border_width=1) pback = PlayerGUI() button, values = pback.PlayerChooseSongGUI() if button != 'PLAY!': g.MsgBoxCancel('Cancelled...\nAutoclose in 2 sec...', auto_close=True, auto_close_duration=2) exit(69) - if values['device'] is not None: + if values['device']: midi_port = values['device'][0] else: g.MsgBoxCancel('No devices found\nAutoclose in 2 sec...', auto_close=True, auto_close_duration=2) From 21dc55d1d79ec711f369b63526e59c3b7f39c340 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 24 Aug 2018 12:19:05 -0400 Subject: [PATCH 195/209] Chatterbot GUI Front End - Machine Learning Initial checkin of a GUI front-end to the Chatterbot Machine Learning software package. Uses graphical progress meters to show training progress Provides a "chat-window" style interface for conversing --- Demo_Chatterbot.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Demo_Chatterbot.py diff --git a/Demo_Chatterbot.py b/Demo_Chatterbot.py new file mode 100644 index 000000000..a0e69844f --- /dev/null +++ b/Demo_Chatterbot.py @@ -0,0 +1,38 @@ +import PySimpleGUI as gui +from chatterbot import ChatBot +import chatterbot.utils + +''' +Demo_Chatterbot.py +A GUI wrapped arouind the Chatterbot package. +The GUI is used to show progress bars during the training process and +to collect user input that is sent to the chatbot. The reply is displayed in the GUI window +''' + +# redefine the chatbot text based progress bar with a graphical one +def print_progress_bar(description, iteration_counter, total_items, progress_bar_length=20): + gui.EasyProgressMeter(description, iteration_counter, total_items) + +chatterbot.utils.print_progress_bar = print_progress_bar + +chatbot = ChatBot('Ron Obvious', trainer='chatterbot.trainers.ChatterBotCorpusTrainer') + +# Train based on the english corpus +chatbot.train("chatterbot.corpus.english") + +################# GUI ################# +with gui.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + layout = [ [gui.Output(size=(80, 20))], + [gui.Multiline(size=(70, 5), enter_submits=True), + gui.ReadFormButton('SEND', bind_return_key=True), gui.SimpleButton('EXIT')]] + + form.Layout(layout) + # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # + while True: + button, (value,) = form.Read() + if button != 'SEND': + break + print(value.rstrip()) + # send the user input to chatbot to get a response + response = chatbot.get_response(value.rstrip()) + print(response) \ No newline at end of file From 595b3c09938752d82c97e64abdba47dc419315cd Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 24 Aug 2018 12:20:01 -0400 Subject: [PATCH 196/209] Chatterbot front-end. Machine Learning --- Demo_Chatterbot.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Demo_Chatterbot.py diff --git a/Demo_Chatterbot.py b/Demo_Chatterbot.py new file mode 100644 index 000000000..a0e69844f --- /dev/null +++ b/Demo_Chatterbot.py @@ -0,0 +1,38 @@ +import PySimpleGUI as gui +from chatterbot import ChatBot +import chatterbot.utils + +''' +Demo_Chatterbot.py +A GUI wrapped arouind the Chatterbot package. +The GUI is used to show progress bars during the training process and +to collect user input that is sent to the chatbot. The reply is displayed in the GUI window +''' + +# redefine the chatbot text based progress bar with a graphical one +def print_progress_bar(description, iteration_counter, total_items, progress_bar_length=20): + gui.EasyProgressMeter(description, iteration_counter, total_items) + +chatterbot.utils.print_progress_bar = print_progress_bar + +chatbot = ChatBot('Ron Obvious', trainer='chatterbot.trainers.ChatterBotCorpusTrainer') + +# Train based on the english corpus +chatbot.train("chatterbot.corpus.english") + +################# GUI ################# +with gui.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + layout = [ [gui.Output(size=(80, 20))], + [gui.Multiline(size=(70, 5), enter_submits=True), + gui.ReadFormButton('SEND', bind_return_key=True), gui.SimpleButton('EXIT')]] + + form.Layout(layout) + # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # + while True: + button, (value,) = form.Read() + if button != 'SEND': + break + print(value.rstrip()) + # send the user input to chatbot to get a response + response = chatbot.get_response(value.rstrip()) + print(response) \ No newline at end of file From 17d87870e7960d02f3c845125cf9b286d5da2101 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 24 Aug 2018 21:23:57 -0400 Subject: [PATCH 197/209] "Dashboard" design for progress meters. Dashboard type of design that includes 20 Progress Meters. Able to see the progess meters after they have competed. --- Demo_Chatterbot.py | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/Demo_Chatterbot.py b/Demo_Chatterbot.py index a0e69844f..15cfa808d 100644 --- a/Demo_Chatterbot.py +++ b/Demo_Chatterbot.py @@ -1,4 +1,4 @@ -import PySimpleGUI as gui +import PySimpleGUI as g from chatterbot import ChatBot import chatterbot.utils @@ -9,10 +9,34 @@ to collect user input that is sent to the chatbot. The reply is displayed in the GUI window ''' -# redefine the chatbot text based progress bar with a graphical one +# Create the 'Trainer GUI' +MAX_PROG_BARS = 20 +bars = [] +texts = [] +training_layout = [[g.T('TRAINING PROGRESS', size=(20,1), font=('Helvetica', 17))]] +for i in range(MAX_PROG_BARS): + bars.append(g.ProgressBar(100, size=(30, 5))) + texts.append(g.T(' '*20)) + training_layout += [[texts[i], bars[i]]] + +training_form = g.FlexForm('Training') +training_form.Layout(training_layout) +current_bar = 0 + +# callback function for training runs def print_progress_bar(description, iteration_counter, total_items, progress_bar_length=20): - gui.EasyProgressMeter(description, iteration_counter, total_items) + global current_bar + global bars + global texts + global training_form + # update the form and the bars + training_form.ReadNonBlocking() + bars[current_bar].UpdateBar(iteration_counter, max=total_items) + texts[current_bar].Update(description) + if iteration_counter == total_items: + current_bar += 1 +# redefine the chatbot text based progress bar with a graphical one chatterbot.utils.print_progress_bar = print_progress_bar chatbot = ChatBot('Ron Obvious', trainer='chatterbot.trainers.ChatterBotCorpusTrainer') @@ -21,10 +45,10 @@ def print_progress_bar(description, iteration_counter, total_items, progress_bar chatbot.train("chatterbot.corpus.english") ################# GUI ################# -with gui.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: - layout = [ [gui.Output(size=(80, 20))], - [gui.Multiline(size=(70, 5), enter_submits=True), - gui.ReadFormButton('SEND', bind_return_key=True), gui.SimpleButton('EXIT')]] +with g.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + layout = [[g.Output(size=(80, 20))], + [g.Multiline(size=(70, 5), enter_submits=True), + g.ReadFormButton('SEND', bind_return_key=True), g.SimpleButton('EXIT')]] form.Layout(layout) # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # From 4a0d7b815ddb82c8de78258f0d54b7326b765229 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 24 Aug 2018 22:44:52 -0400 Subject: [PATCH 198/209] Correct exiting from application is user closes windows --- Demo_Chatterbot.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Demo_Chatterbot.py b/Demo_Chatterbot.py index 15cfa808d..6697335ba 100644 --- a/Demo_Chatterbot.py +++ b/Demo_Chatterbot.py @@ -30,8 +30,11 @@ def print_progress_bar(description, iteration_counter, total_items, progress_bar global texts global training_form # update the form and the bars - training_form.ReadNonBlocking() - bars[current_bar].UpdateBar(iteration_counter, max=total_items) + button, values = training_form.ReadNonBlocking() + if button is None and values is None: + exit(69) + if bars[current_bar].UpdateBar(iteration_counter, max=total_items) is False: + exit(69) texts[current_bar].Update(description) if iteration_counter == total_items: current_bar += 1 From 4119ea8b5cfb2a077681b0998b8242fef7a5a0d8 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 24 Aug 2018 22:47:21 -0400 Subject: [PATCH 199/209] Slider - range can be changed using Update, Progress Bars - Max value c an be changed on the fly when calling UpdateBar. Fixed bug when multiple bars on one form --- PySimpleGUI.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 0fc5f76a4..0bc75dc52 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -512,24 +512,21 @@ def __init__(self, root, max, length=400, width=DEFAULT_PROGRESS_BAR_SIZE[1], st if orientation[0].lower() == 'h': s = ttk.Style() s.theme_use(style) - s.configure("my.Horizontal.TProgressbar", background=BarColor[0], troughcolor=BarColor[1], troughrelief=relief, borderwidth=border_width, thickness=width) - self.TKProgressBarForReal = ttk.Progressbar(root, maximum=self.Max, style='my.Horizontal.TProgressbar', length=length, orient=tk.HORIZONTAL, mode='determinate') - # self.TKCanvas = tk.Canvas(root, width=length, height=width, highlightt=highlightt, relief=relief, borderwidth=border_width) - # self.TKRect = self.TKCanvas.create_rectangle(0, 0, -(length * 1.5), width * 1.5, fill=BarColor[0], tags='bar') - # self.canvas.pack(padx='10') + s.configure(str(length)+str(width)+"my.Horizontal.TProgressbar", background=BarColor[0], troughcolor=BarColor[1], troughrelief=relief, borderwidth=border_width, thickness=width) + self.TKProgressBarForReal = ttk.Progressbar(root, maximum=self.Max, style=str(length)+str(width)+'my.Horizontal.TProgressbar', length=length, orient=tk.HORIZONTAL, mode='determinate') else: - # s = ttk.Style() - # s.theme_use('clam') - # s.configure('Vertical.mycolor.progbar', forground=BarColor[0], background=BarColor[1]) s = ttk.Style() s.theme_use(style) - s.configure("my.Vertical.TProgressbar", background=BarColor[0], troughcolor=BarColor[1], troughrelief=relief, borderwidth=border_width, thickness=width) - self.TKProgressBarForReal = ttk.Progressbar(root, maximum=self.Max, style='my.Vertical.TProgressbar', length=length, orient=tk.VERTICAL, mode='determinate') - # self.TKCanvas = tk.Canvas(root, width=width, height=length, highlightt=highlightt, relief=relief, borderwidth=border_width) - # self.TKRect = self.TKCanvas.create_rectangle(width * 1.5, 2 * length + 40, 0, length * .5, fill=BarColor[0], tags='bar') - # self.canvas.pack() + s.configure(str(length)+str(width)+"my.Vertical.TProgressbar", background=BarColor[0], troughcolor=BarColor[1], troughrelief=relief, borderwidth=border_width, thickness=width) + self.TKProgressBarForReal = ttk.Progressbar(root, maximum=self.Max, style=str(length)+str(width)+'my.Vertical.TProgressbar', length=length, orient=tk.VERTICAL, mode='determinate') - def Update(self, count): + def Update(self, count, max=None): + if max is not None: + self.Max = max + try: + self.TKProgressBarForReal.config(maximum=max) + except: + return False if count > self.Max: return False try: self.TKProgressBarForReal['value'] = count @@ -757,13 +754,13 @@ def __init__(self, max_value, orientation=None, scale=(None, None), size=(None, self.BorderWidth = border_width if border_width else DEFAULT_PROGRESS_BAR_BORDER_WIDTH self.Relief = relief if relief else DEFAULT_PROGRESS_BAR_RELIEF self.BarExpired = False - super().__init__(ELEM_TYPE_PROGRESS_BAR, scale, size, auto_size_text) + super().__init__(ELEM_TYPE_PROGRESS_BAR, scale=scale, size=size, auto_size_text=auto_size_text) return - def UpdateBar(self, current_count): + def UpdateBar(self, current_count, max=None): if self.ParentForm.TKrootDestroyed: return False - self.TKProgressBar.Update(current_count) + self.TKProgressBar.Update(current_count, max=max) try: self.ParentForm.TKroot.update() except: @@ -840,8 +837,11 @@ def __init__(self, range=(None,None), default_value=None, orientation=None, bord super().__init__(ELEM_TYPE_INPUT_SLIDER, scale=scale, size=size, font=font, background_color=background_color, text_color=text_color, key=key) return - def Update(self, value): + def Update(self, value, range=(None, None)): self.TKIntVar.set(value) + if range != (None, None): + self.TKScale.config(from_ = range[0], to_ = range[1]) + def __del__(self): super().__del__() @@ -1749,6 +1749,7 @@ def CharWidthInPixels(): if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT: tkscale.configure(fg=text_color) tkscale.pack(side=tk.LEFT, padx=element.Pad[0],pady=element.Pad[1]) + element.TKScale = tkscale #............................DONE WITH ROW pack the row of widgets ..........................# # done with row, pack the row of widgets tk_row_frame.grid(row=row_num+2, sticky=tk.NW, padx=DEFAULT_MARGINS[0]) From 60034cd168c575ddb1fcf779e38c269ce14b085c Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 24 Aug 2018 23:32:12 -0400 Subject: [PATCH 200/209] Progress bar - decrement num windows if update fails (RISKY CHANGE) More battling over the number of open windows. Hopefully won't cause lots of problems! --- PySimpleGUI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 0bc75dc52..ba25b2714 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -764,7 +764,7 @@ def UpdateBar(self, current_count, max=None): try: self.ParentForm.TKroot.update() except: - # _my_windows.Decrement() + _my_windows.Decrement() return False return True From 8bf744689faf877f0170e4b6901d84b4d592914b Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 24 Aug 2018 23:40:14 -0400 Subject: [PATCH 201/209] Replace MAster with Dev version.... multiple progress bars --- Demo_Chatterbot.py | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/Demo_Chatterbot.py b/Demo_Chatterbot.py index a0e69844f..6697335ba 100644 --- a/Demo_Chatterbot.py +++ b/Demo_Chatterbot.py @@ -1,4 +1,4 @@ -import PySimpleGUI as gui +import PySimpleGUI as g from chatterbot import ChatBot import chatterbot.utils @@ -9,10 +9,37 @@ to collect user input that is sent to the chatbot. The reply is displayed in the GUI window ''' -# redefine the chatbot text based progress bar with a graphical one +# Create the 'Trainer GUI' +MAX_PROG_BARS = 20 +bars = [] +texts = [] +training_layout = [[g.T('TRAINING PROGRESS', size=(20,1), font=('Helvetica', 17))]] +for i in range(MAX_PROG_BARS): + bars.append(g.ProgressBar(100, size=(30, 5))) + texts.append(g.T(' '*20)) + training_layout += [[texts[i], bars[i]]] + +training_form = g.FlexForm('Training') +training_form.Layout(training_layout) +current_bar = 0 + +# callback function for training runs def print_progress_bar(description, iteration_counter, total_items, progress_bar_length=20): - gui.EasyProgressMeter(description, iteration_counter, total_items) + global current_bar + global bars + global texts + global training_form + # update the form and the bars + button, values = training_form.ReadNonBlocking() + if button is None and values is None: + exit(69) + if bars[current_bar].UpdateBar(iteration_counter, max=total_items) is False: + exit(69) + texts[current_bar].Update(description) + if iteration_counter == total_items: + current_bar += 1 +# redefine the chatbot text based progress bar with a graphical one chatterbot.utils.print_progress_bar = print_progress_bar chatbot = ChatBot('Ron Obvious', trainer='chatterbot.trainers.ChatterBotCorpusTrainer') @@ -21,10 +48,10 @@ def print_progress_bar(description, iteration_counter, total_items, progress_bar chatbot.train("chatterbot.corpus.english") ################# GUI ################# -with gui.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: - layout = [ [gui.Output(size=(80, 20))], - [gui.Multiline(size=(70, 5), enter_submits=True), - gui.ReadFormButton('SEND', bind_return_key=True), gui.SimpleButton('EXIT')]] +with g.FlexForm('Chat Window', auto_size_text=True, default_element_size=(30, 2)) as form: + layout = [[g.Output(size=(80, 20))], + [g.Multiline(size=(70, 5), enter_submits=True), + g.ReadFormButton('SEND', bind_return_key=True), g.SimpleButton('EXIT')]] form.Layout(layout) # ---===--- Loop taking in user input and using it to query HowDoI web oracle --- # From d4f09d367d7867605cc3a070215df2aa20d6bb40 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 25 Aug 2018 20:48:06 -0400 Subject: [PATCH 202/209] Release 2.10 --- docs/index.md | 127 +++++++++++++++++++++++++++++++++++++++++--------- readme.md | 127 +++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 212 insertions(+), 42 deletions(-) diff --git a/docs/index.md b/docs/index.md index 2efe1958f..5745ef057 100644 --- a/docs/index.md +++ b/docs/index.md @@ -10,7 +10,8 @@ # PySimpleGUI - (Ver 2.9) + (Ver 2.10) + ![Documentation Status](https://readthedocs.org/projects/pysimplegui/badge/?version=latest) Lots of documentation available in addition to this Readme File. [Formatted ReadTheDocs Version of this Readme](http://pysimplegui.readthedocs.io/) @@ -114,6 +115,9 @@ The `PySimpleGUI` package is focused on the ***developer***. How can the desire Set focus Bind return key to buttons Group widgets into a column and place into form anywhere + Keyboard low-level key capture + Mouse scroll-wheel support + Update elements in a visible form An example of many widgets used on a single form. A little further down you'll find the TWENTY lines of code required to create this complex form. Try it if you don't believe it. Start Python, copy and paste the code below into the >>> prompt and hit enter. This will pop up... @@ -824,7 +828,7 @@ A summary of the variables that can be changed when a FlexForm is created ## Elements -"Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. +"Elements" are the building blocks used to create forms. Some GUI APIs use the term "Widget" to describe these graphic elements. Text Single Line Input @@ -890,16 +894,19 @@ The default font setting is ("Helvetica", 10) -**Color** in PySimpleGUI are always in this format: +**Color** in PySimpleGUI are in one of two format. They can be a single color or a color pair. Buttons are an example of a color pair. (foreground, background) -The values foreground and background can be the color names or the hex value formatted as a string: + Individual colors are specified using either the color names as defined in tkinter or an RGB string of this format: "#RRGGBB" **auto_size_text** -A `True` value for `auto_size_text`, when placed on any Element, indicates that the width of the Element should be shrunk do the width of the text. This is particularly useful with `Buttons` as fixed-width buttons are somewhat crude looking. The default value is `False`. You will often see this setting on FlexForm definitions. +A `True` value for `auto_size_text`, when placed on Text Elements, indicates that the width of the Element should be shrunk do the width of the text. The default setting is True. + + - [ ] List item + **Shorthand functions** The shorthand functions for `Text` are `Txt` and `T` @@ -950,7 +957,13 @@ Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. scale=(None, None), size=(None, None), auto_size_text=None, - password_char='') + password_char='', + background_color=None, + text_color=None, + do_not_clear=False, + key=None, + focus=False + ) . default_text - Text initially shown in the input box @@ -958,6 +971,17 @@ Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. size - (width, height) of element in characters auto_size_text- Bool. True is element should be sized to fit text password_char - Character that will be used to replace each entered character. Setting to a value indicates this field is a password entry field + background_color - color to use for the input field background + text_color - color to use for the typed text + do_not_clear - Bool. Normally forms clear when read, turn off clearing with this flag. + key = Dictionary key to use for return values + focus = Bool. True if this field should capture the focus (moves cursor to this field) + + There are two methods that can be called: + + InputText.Update(new_Value) - sets the input value + Input.Text(Get() - returns the current value of the field. + Shorthand functions that are equivalent to `InputText` are `Input` and `In` @@ -972,13 +996,20 @@ Also known as a drop-down list. Only required parameter is the list of choices. InputCombo(values, scale=(None, None), size=(None, None), - auto_size_text=None) + auto_size_text=None, + background_color = None, + text_color = None, + key = None) . values - Choices to be displayed. List of strings scale - Amount to scale size by size - (width, height) of element in characters auto_size_text - Bool. True if size should fit the text length + background_color - color to use for the input field background + text_color - color to use for the typed text + key = Dictionary key to use for return values + #### Listbox Element The standard listbox like you'll find in most GUIs. Note that the return values from this element will be a ***list of results, not a single result***. This is because the user can select more than 1 item from the list (if you set the right mode). @@ -993,7 +1024,10 @@ The standard listbox like you'll find in most GUIs. Note that the return values scale=(None, None), size=(None, None), auto_size_text=None, - font=None) + font=None, + background_color = None, + text_color = None, + key = None) . values - Choices to be displayed. List of strings @@ -1012,6 +1046,9 @@ The standard listbox like you'll find in most GUIs. Note that the return values scale - Amount to scale size by size - (width, height) of element in characters auto_size_text - Bool. True if size should fit the text length + background_color - color to use for the input field background + text_color - color to use for the typed text + key = Dictionary key to use for return values The `select_mode` option can be a string or a constant value defined as a variable. Generally speaking strings are used for these kinds of options. @@ -1029,7 +1066,10 @@ Sliders have a couple of slider-specific settings as well as appearance settings relief=None, scale=(None, None), size=(None, None), - font=None): + font=None, + background_color = None, + text_color = None, + key = None) ): . range - (min, max) slider's range @@ -1046,6 +1086,9 @@ Sliders have a couple of slider-specific settings as well as appearance settings scale - Amount to scale size by size - (width, height) of element in characters auto_size_text - Bool. True if size should fit the text + background_color - color to use for the input field background + text_color - color to use for the typed text + key = Dictionary key to use for return values #### Radio Button Element Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. @@ -1060,7 +1103,10 @@ Creates one radio button that is assigned to a group of radio buttons. Only 1 o scale=(None, None), size=(None, None), auto_size_text=None, - font=None) + font=None, + background_color = None, + text_color = None, + key = None) . @@ -1071,6 +1117,9 @@ Creates one radio button that is assigned to a group of radio buttons. Only 1 o size- (width, height) size of element in characters auto_size_text - Bool. True if should size width to fit text font - Font type and size for text display + background_color - color to use for the background + text_color - color to use for the text + key = Dictionary key to use for return values #### Checkbox Element @@ -1086,7 +1135,10 @@ Checkbox elements are like Radio Button elements. They return a bool indicating scale=(None, None), size=(None, None), auto_size_text=None, - font=None): + font=None, + background_color = None, + text_color = None, + key = None): . text - Text to display next to checkbox @@ -1095,6 +1147,9 @@ Checkbox elements are like Radio Button elements. They return a bool indicating size - (width, height) size of element in characters auto_size_text- Bool. True if should size width to fit text font- Font type and size for text display + background_color - color to use for the background + text_color - color to use for the typed text + key = Dictionary key to use for return values #### Spin Element @@ -1109,7 +1164,10 @@ An up/down spinner control. The valid values are passed in as a list. scale=(None, None), size=(None, None), auto_size_text=None, - font=None) + font=None, + background_color = None, + text_color = None, + key = None): . values - List of valid values @@ -1118,6 +1176,9 @@ An up/down spinner control. The valid values are passed in as a list. size - (width, height) size of element in characters auto_size_text - Bool. True if should size width to fit text font - Font type and size for text display + background_color - color to use for the background + text_color - color to use for the typed text + key = Dictionary key to use for return values #### Button Element Buttons are the most important element of all! They cause the majority of the action to happen. After all, it's a button press that will get you out of a form, whether it but Submit or Cancel, one way or another a button is involved in all forms. The only exception is to this is when the user closes the window using the "X" in the upper corner which means no button was involved. @@ -1143,11 +1204,17 @@ Realtime - This is another async form button. Normal button clicks occur after While it's possible to build forms using the Button Element directly, you should never need to do that. There are pre-made buttons and shortcuts that will make life much easier. The most basic Button element call to use is `SimpleButton` SimpleButton(text, + image_filename=None, + image_size=(None, None), + image_subsample=None, + border_width=None, + bind_return_key=False, scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, - font=None) + font=None, + focus=False) These Pre-made buttons are some of the most important elements of all because they are used so much. If you find yourself needing to create a custom button often because it's not on this list, please post a request on GitHub. (hmmm Save already comes to mind). They include: @@ -1157,14 +1224,19 @@ These Pre-made buttons are some of the most important elements of all because th Cancel Yes No + Exit + Quit + Save + SaveAs FileBrowse + FileSaveAs FolderBrowse . layout = [[sg.OK(), sg.Cancel()]] ![ok cancel](https://user-images.githubusercontent.com/13696193/42717733-1803f584-86d1-11e8-9223-36b782971b9f.jpg) -The FileBrowse and FolderBrowse buttons both fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. +The FileBrowse, FolderBrowse, FileSaveAs buttons all fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. The default value for `Target` is `(ThisRow, -1)`. ThisRow is a special value that tells the GUI to use the same row as the button. The Y-value of -1 means the field one value to the left of the button. For a File or Folder Browse button, the field that it fills are generally to the left of the button is most cases. @@ -1189,7 +1261,7 @@ layout = [[sg.SimpleButton('My Button')]] ![singlebutton](https://user-images.githubusercontent.com/13696193/42718281-9453deca-86d5-11e8-83c7-4b6d33720858.jpg) -All buttons can have their text changed by changing the `button_text` variable in the button call. It is this text that is returned when a form is read. This text will be what tells you which button is called so make it unique. Most of the convenience buttons (Submit, Cancel, Yes, etc) are all SimpleButtons. The two that are not are `FileBrowse` and `FolderBrowse`. They clearly do not close the form. Instead they bring up a file or folder browser dialog box. +All buttons can have their text changed by changing the `button_text` variable in the button call. It is this text that is returned when a form is read. This text will be what tells you which button is called so make it unique. Most of the convenience buttons (Submit, Cancel, Yes, etc) are all SimpleButtons. Some that are not are `FileBrowse` , `FolderBrowse`, `FileSaveAs`. They clearly do not close the form. Instead they bring up a file or folder browser dialog box. **Button Images** Now this is an exciting feature not found in many simplified packages.... images on buttons! You can make a pretty spiffy user interface with the help of a few button images. @@ -1255,7 +1327,7 @@ Somewhere later in your code will be your main event loop. This is where you do This loop will read button values and print them. When one of the Realtime buttons is clicked, the call to `form.ReadNonBlocking` will return a button name matching the name on the button that was depressed. It will continue to return values as long as the button remains depressed. Once released, the ReadNonBlocking will return None for buttons until a button is again clicked. **File Types** -The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is +The `FileBrowse` & `SaveAs` buttons have an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is FileTypes=(("ALL Files", "*.*"),) @@ -1264,7 +1336,10 @@ This code produces a form where the Browse button only shows files of type .TXT layout = [[sg.In() ,sg.FileBrowse(file_types=(("Text Files", "*.txt"),))]] ***The ENTER key*** - The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. + The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. + +The Enter Key can be "bound" to a particular button so that when the key is pressed, it causes the form to return as if the button was clicked. This is done using the `bind_return_key` parameter in the button calls. +If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. --- #### ProgressBar @@ -1507,6 +1582,14 @@ These settings apply to all forms `SetOptions`. The Row options and Element opt Each lower level overrides the settings of the higher level. Once settings have been changed, they remain changed for the duration of the program (unless changed again). +## Persistent Forms (Window stays open after button click) + +There are 2 ways to keep a window open after the user has clicked a button. One way is to use non-blocking forms (see the next section). The other way is to use buttons that 'read' the form instead of 'close' the form when clicked. The typical buttons you find in forms, including the shortcut buttons, close the form. These include OK, Cancel, Submit, etc. The SimpleButton Element also closes the form. + +The `ReadFormButton` Element creates a button that when clicked will return control to the user, but will leave the form open and visible. This button is also used in Non-Blocking forms. The difference is in which call is made to read the form. The `Read` call will block, the `ReadNonBlocking` will not block. + + + ## Asynchronous (Non-Blocking) Forms So you want to be a wizard do ya? Well go boldly! While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. With asynchronous forms the form is shown, user input is read, but your code keeps right on chugging. YOUR responsibility is to call `PySimpleGUI.ReadNonBlocking` on a periodic basis. Once a second or more will produce a reasonably snappy GUI. @@ -1530,9 +1613,11 @@ The basic flow and functions you will be calling are: Setup - form = FlexForm() - form_rows = ..... - form.LayoutAndRead(form_rows, non_blocking=True) + + form = FlexForm() + form_rows = ..... + form.LayoutAndRead(form_rows, non_blocking=True) + Periodic refresh @@ -1700,7 +1785,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting | 2.8.0 | Aug 9, 2018 - New None default option for Checkbox element, text color option for all elements, return values as a dictionary, setting focus, binding return key | 2.9.0 | Aug 16,2018 - Screen flash fix, `do_not_clear` input field option, `autosize_text` defaults to `True` now, return values as ordered dict, removed text target from progress bar, rework of return values and initial return values, removed legacy Form.Refresh() method (replaced by Form.ReadNonBlockingForm()), COLUMN elements!!, colored text defaults - +| 2.10.0 | Aug 25, 2018 - Keyboard & Mouse features (Return individual keys as if buttons, return mouse scroll-wheel as button, bind return-key to button, control over keyboard focus), SaveAs Button, Update & Get methods for InputText, Update for Listbox, Update & Get for Checkbox, Get for Multiline, Color options for Text Element Update, Progess bar Update can change max value, Update for Button to change text & colors, Update for Image Element, Update for Slider, Form level text justification, Turn off default focus, scroll bar for Listboxes, Images can be from filename or from in-RAM, Update for Image). Fixes - text wrapping in buttons, msg box, removed slider borders entirely and others ### Release Notes 2.3 - Sliders, Listbox's and Image elements (oh my!) diff --git a/readme.md b/readme.md index 2efe1958f..5745ef057 100644 --- a/readme.md +++ b/readme.md @@ -10,7 +10,8 @@ # PySimpleGUI - (Ver 2.9) + (Ver 2.10) + ![Documentation Status](https://readthedocs.org/projects/pysimplegui/badge/?version=latest) Lots of documentation available in addition to this Readme File. [Formatted ReadTheDocs Version of this Readme](http://pysimplegui.readthedocs.io/) @@ -114,6 +115,9 @@ The `PySimpleGUI` package is focused on the ***developer***. How can the desire Set focus Bind return key to buttons Group widgets into a column and place into form anywhere + Keyboard low-level key capture + Mouse scroll-wheel support + Update elements in a visible form An example of many widgets used on a single form. A little further down you'll find the TWENTY lines of code required to create this complex form. Try it if you don't believe it. Start Python, copy and paste the code below into the >>> prompt and hit enter. This will pop up... @@ -824,7 +828,7 @@ A summary of the variables that can be changed when a FlexForm is created ## Elements -"Elements" are the building blocks used to create forms. Some GUI APIs use the term Widget to describe these graphic elements. +"Elements" are the building blocks used to create forms. Some GUI APIs use the term "Widget" to describe these graphic elements. Text Single Line Input @@ -890,16 +894,19 @@ The default font setting is ("Helvetica", 10) -**Color** in PySimpleGUI are always in this format: +**Color** in PySimpleGUI are in one of two format. They can be a single color or a color pair. Buttons are an example of a color pair. (foreground, background) -The values foreground and background can be the color names or the hex value formatted as a string: + Individual colors are specified using either the color names as defined in tkinter or an RGB string of this format: "#RRGGBB" **auto_size_text** -A `True` value for `auto_size_text`, when placed on any Element, indicates that the width of the Element should be shrunk do the width of the text. This is particularly useful with `Buttons` as fixed-width buttons are somewhat crude looking. The default value is `False`. You will often see this setting on FlexForm definitions. +A `True` value for `auto_size_text`, when placed on Text Elements, indicates that the width of the Element should be shrunk do the width of the text. The default setting is True. + + - [ ] List item + **Shorthand functions** The shorthand functions for `Text` are `Txt` and `T` @@ -950,7 +957,13 @@ Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. scale=(None, None), size=(None, None), auto_size_text=None, - password_char='') + password_char='', + background_color=None, + text_color=None, + do_not_clear=False, + key=None, + focus=False + ) . default_text - Text initially shown in the input box @@ -958,6 +971,17 @@ Output re-routes `Stdout` to a scrolled text box. It's used with Async forms. size - (width, height) of element in characters auto_size_text- Bool. True is element should be sized to fit text password_char - Character that will be used to replace each entered character. Setting to a value indicates this field is a password entry field + background_color - color to use for the input field background + text_color - color to use for the typed text + do_not_clear - Bool. Normally forms clear when read, turn off clearing with this flag. + key = Dictionary key to use for return values + focus = Bool. True if this field should capture the focus (moves cursor to this field) + + There are two methods that can be called: + + InputText.Update(new_Value) - sets the input value + Input.Text(Get() - returns the current value of the field. + Shorthand functions that are equivalent to `InputText` are `Input` and `In` @@ -972,13 +996,20 @@ Also known as a drop-down list. Only required parameter is the list of choices. InputCombo(values, scale=(None, None), size=(None, None), - auto_size_text=None) + auto_size_text=None, + background_color = None, + text_color = None, + key = None) . values - Choices to be displayed. List of strings scale - Amount to scale size by size - (width, height) of element in characters auto_size_text - Bool. True if size should fit the text length + background_color - color to use for the input field background + text_color - color to use for the typed text + key = Dictionary key to use for return values + #### Listbox Element The standard listbox like you'll find in most GUIs. Note that the return values from this element will be a ***list of results, not a single result***. This is because the user can select more than 1 item from the list (if you set the right mode). @@ -993,7 +1024,10 @@ The standard listbox like you'll find in most GUIs. Note that the return values scale=(None, None), size=(None, None), auto_size_text=None, - font=None) + font=None, + background_color = None, + text_color = None, + key = None) . values - Choices to be displayed. List of strings @@ -1012,6 +1046,9 @@ The standard listbox like you'll find in most GUIs. Note that the return values scale - Amount to scale size by size - (width, height) of element in characters auto_size_text - Bool. True if size should fit the text length + background_color - color to use for the input field background + text_color - color to use for the typed text + key = Dictionary key to use for return values The `select_mode` option can be a string or a constant value defined as a variable. Generally speaking strings are used for these kinds of options. @@ -1029,7 +1066,10 @@ Sliders have a couple of slider-specific settings as well as appearance settings relief=None, scale=(None, None), size=(None, None), - font=None): + font=None, + background_color = None, + text_color = None, + key = None) ): . range - (min, max) slider's range @@ -1046,6 +1086,9 @@ Sliders have a couple of slider-specific settings as well as appearance settings scale - Amount to scale size by size - (width, height) of element in characters auto_size_text - Bool. True if size should fit the text + background_color - color to use for the input field background + text_color - color to use for the typed text + key = Dictionary key to use for return values #### Radio Button Element Creates one radio button that is assigned to a group of radio buttons. Only 1 of the buttons in the group can be selected at any one time. @@ -1060,7 +1103,10 @@ Creates one radio button that is assigned to a group of radio buttons. Only 1 o scale=(None, None), size=(None, None), auto_size_text=None, - font=None) + font=None, + background_color = None, + text_color = None, + key = None) . @@ -1071,6 +1117,9 @@ Creates one radio button that is assigned to a group of radio buttons. Only 1 o size- (width, height) size of element in characters auto_size_text - Bool. True if should size width to fit text font - Font type and size for text display + background_color - color to use for the background + text_color - color to use for the text + key = Dictionary key to use for return values #### Checkbox Element @@ -1086,7 +1135,10 @@ Checkbox elements are like Radio Button elements. They return a bool indicating scale=(None, None), size=(None, None), auto_size_text=None, - font=None): + font=None, + background_color = None, + text_color = None, + key = None): . text - Text to display next to checkbox @@ -1095,6 +1147,9 @@ Checkbox elements are like Radio Button elements. They return a bool indicating size - (width, height) size of element in characters auto_size_text- Bool. True if should size width to fit text font- Font type and size for text display + background_color - color to use for the background + text_color - color to use for the typed text + key = Dictionary key to use for return values #### Spin Element @@ -1109,7 +1164,10 @@ An up/down spinner control. The valid values are passed in as a list. scale=(None, None), size=(None, None), auto_size_text=None, - font=None) + font=None, + background_color = None, + text_color = None, + key = None): . values - List of valid values @@ -1118,6 +1176,9 @@ An up/down spinner control. The valid values are passed in as a list. size - (width, height) size of element in characters auto_size_text - Bool. True if should size width to fit text font - Font type and size for text display + background_color - color to use for the background + text_color - color to use for the typed text + key = Dictionary key to use for return values #### Button Element Buttons are the most important element of all! They cause the majority of the action to happen. After all, it's a button press that will get you out of a form, whether it but Submit or Cancel, one way or another a button is involved in all forms. The only exception is to this is when the user closes the window using the "X" in the upper corner which means no button was involved. @@ -1143,11 +1204,17 @@ Realtime - This is another async form button. Normal button clicks occur after While it's possible to build forms using the Button Element directly, you should never need to do that. There are pre-made buttons and shortcuts that will make life much easier. The most basic Button element call to use is `SimpleButton` SimpleButton(text, + image_filename=None, + image_size=(None, None), + image_subsample=None, + border_width=None, + bind_return_key=False, scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, - font=None) + font=None, + focus=False) These Pre-made buttons are some of the most important elements of all because they are used so much. If you find yourself needing to create a custom button often because it's not on this list, please post a request on GitHub. (hmmm Save already comes to mind). They include: @@ -1157,14 +1224,19 @@ These Pre-made buttons are some of the most important elements of all because th Cancel Yes No + Exit + Quit + Save + SaveAs FileBrowse + FileSaveAs FolderBrowse . layout = [[sg.OK(), sg.Cancel()]] ![ok cancel](https://user-images.githubusercontent.com/13696193/42717733-1803f584-86d1-11e8-9223-36b782971b9f.jpg) -The FileBrowse and FolderBrowse buttons both fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. +The FileBrowse, FolderBrowse, FileSaveAs buttons all fill-in values into a text input field somewhere on the form. The location of the TextInput element is specified by the `Target` variable in the function call. The Target is specified using a grid system. The rows in your GUI are numbered starting with 0. The target can be specified as a hard coded grid item or it can be relative to the button. The default value for `Target` is `(ThisRow, -1)`. ThisRow is a special value that tells the GUI to use the same row as the button. The Y-value of -1 means the field one value to the left of the button. For a File or Folder Browse button, the field that it fills are generally to the left of the button is most cases. @@ -1189,7 +1261,7 @@ layout = [[sg.SimpleButton('My Button')]] ![singlebutton](https://user-images.githubusercontent.com/13696193/42718281-9453deca-86d5-11e8-83c7-4b6d33720858.jpg) -All buttons can have their text changed by changing the `button_text` variable in the button call. It is this text that is returned when a form is read. This text will be what tells you which button is called so make it unique. Most of the convenience buttons (Submit, Cancel, Yes, etc) are all SimpleButtons. The two that are not are `FileBrowse` and `FolderBrowse`. They clearly do not close the form. Instead they bring up a file or folder browser dialog box. +All buttons can have their text changed by changing the `button_text` variable in the button call. It is this text that is returned when a form is read. This text will be what tells you which button is called so make it unique. Most of the convenience buttons (Submit, Cancel, Yes, etc) are all SimpleButtons. Some that are not are `FileBrowse` , `FolderBrowse`, `FileSaveAs`. They clearly do not close the form. Instead they bring up a file or folder browser dialog box. **Button Images** Now this is an exciting feature not found in many simplified packages.... images on buttons! You can make a pretty spiffy user interface with the help of a few button images. @@ -1255,7 +1327,7 @@ Somewhere later in your code will be your main event loop. This is where you do This loop will read button values and print them. When one of the Realtime buttons is clicked, the call to `form.ReadNonBlocking` will return a button name matching the name on the button that was depressed. It will continue to return values as long as the button remains depressed. Once released, the ReadNonBlocking will return None for buttons until a button is again clicked. **File Types** -The `FileBrowse` button has an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is +The `FileBrowse` & `SaveAs` buttons have an additional setting named `file_types`. This variable is used to filter the files shown in the file dialog box. The default value for this setting is FileTypes=(("ALL Files", "*.*"),) @@ -1264,7 +1336,10 @@ This code produces a form where the Browse button only shows files of type .TXT layout = [[sg.In() ,sg.FileBrowse(file_types=(("Text Files", "*.txt"),))]] ***The ENTER key*** - The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. + The ENTER key is an important part of data entry for forms. There's a long tradition of the enter key being used to quickly submit forms. PySimpleGUI implements this by tying the ENTER key to the first button that closes or reads a form. + +The Enter Key can be "bound" to a particular button so that when the key is pressed, it causes the form to return as if the button was clicked. This is done using the `bind_return_key` parameter in the button calls. +If there are more than 1 button on a form, the FIRST button that is of type Close Form or Read Form is used. First is determined by scanning the form, top to bottom and left to right. --- #### ProgressBar @@ -1507,6 +1582,14 @@ These settings apply to all forms `SetOptions`. The Row options and Element opt Each lower level overrides the settings of the higher level. Once settings have been changed, they remain changed for the duration of the program (unless changed again). +## Persistent Forms (Window stays open after button click) + +There are 2 ways to keep a window open after the user has clicked a button. One way is to use non-blocking forms (see the next section). The other way is to use buttons that 'read' the form instead of 'close' the form when clicked. The typical buttons you find in forms, including the shortcut buttons, close the form. These include OK, Cancel, Submit, etc. The SimpleButton Element also closes the form. + +The `ReadFormButton` Element creates a button that when clicked will return control to the user, but will leave the form open and visible. This button is also used in Non-Blocking forms. The difference is in which call is made to read the form. The `Read` call will block, the `ReadNonBlocking` will not block. + + + ## Asynchronous (Non-Blocking) Forms So you want to be a wizard do ya? Well go boldly! While the majority of GUIs are a simple exercise to "collect input values and return with them", there are instances where we want to continue executing while the form is open. These are "asynchronous" forms and require special options, new SDK calls, and **great care**. With asynchronous forms the form is shown, user input is read, but your code keeps right on chugging. YOUR responsibility is to call `PySimpleGUI.ReadNonBlocking` on a periodic basis. Once a second or more will produce a reasonably snappy GUI. @@ -1530,9 +1613,11 @@ The basic flow and functions you will be calling are: Setup - form = FlexForm() - form_rows = ..... - form.LayoutAndRead(form_rows, non_blocking=True) + + form = FlexForm() + form_rows = ..... + form.LayoutAndRead(form_rows, non_blocking=True) + Periodic refresh @@ -1700,7 +1785,7 @@ A MikeTheWatchGuy production... entirely responsible for this code.... unless it | 2.7.0 | July 30, 2018 - realtime buttons, window_location default setting | 2.8.0 | Aug 9, 2018 - New None default option for Checkbox element, text color option for all elements, return values as a dictionary, setting focus, binding return key | 2.9.0 | Aug 16,2018 - Screen flash fix, `do_not_clear` input field option, `autosize_text` defaults to `True` now, return values as ordered dict, removed text target from progress bar, rework of return values and initial return values, removed legacy Form.Refresh() method (replaced by Form.ReadNonBlockingForm()), COLUMN elements!!, colored text defaults - +| 2.10.0 | Aug 25, 2018 - Keyboard & Mouse features (Return individual keys as if buttons, return mouse scroll-wheel as button, bind return-key to button, control over keyboard focus), SaveAs Button, Update & Get methods for InputText, Update for Listbox, Update & Get for Checkbox, Get for Multiline, Color options for Text Element Update, Progess bar Update can change max value, Update for Button to change text & colors, Update for Image Element, Update for Slider, Form level text justification, Turn off default focus, scroll bar for Listboxes, Images can be from filename or from in-RAM, Update for Image). Fixes - text wrapping in buttons, msg box, removed slider borders entirely and others ### Release Notes 2.3 - Sliders, Listbox's and Image elements (oh my!) From 07772cb2e7ce8ec092a00b8f5d2c4d4f7c907ef3 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 25 Aug 2018 22:57:15 -0400 Subject: [PATCH 203/209] Exposed 'pad' for ALL ELEMENTS. Touched every Element. Changed how shortcut funcations are made. New demo program Keypad. --- Demo_Keypad.py | 36 ++++++++++++++ PySimpleGUI.py | 128 ++++++++++++++++++++++++------------------------- 2 files changed, 98 insertions(+), 66 deletions(-) create mode 100644 Demo_Keypad.py diff --git a/Demo_Keypad.py b/Demo_Keypad.py new file mode 100644 index 000000000..3ca2afb42 --- /dev/null +++ b/Demo_Keypad.py @@ -0,0 +1,36 @@ +import PySimpleGUI as g + +# g.SetOptions(button_color=g.COLOR_SYSTEM_DEFAULT) # because some people like gray buttons + +# create the 2 Elements we want to control outside the form +out_elem = g.Text('', size=(15, 1), font=('Helvetica', 18), text_color='red') +in_elem = g.Input(size=(10,1), do_not_clear=True, key='input') + +layout = [[g.Text('Choose Test'), g.DropDown(values=['Input', 'Output', 'Some option']), g.ReadFormButton('Input Option', size=(10,1))], + [in_elem], + [g.ReadFormButton('1', size=(5,2)), g.ReadFormButton('2', size=(5,2)), g.ReadFormButton('3', size=(5,2))], + [g.ReadFormButton('4', size=(5,2)), g.ReadFormButton('5', size=(5,2)), g.ReadFormButton('6', size=(5,2))], + [g.ReadFormButton('7', size=(5,2)), g.ReadFormButton('8', size=(5,2)), g.ReadFormButton('9', size=(5,2))], + [g.ReadFormButton('Submit', size=(5,2)),g.ReadFormButton('0', size=(5,2)), g.ReadFormButton('Clear', size=(5,2))], + [out_elem], + ] + +form = g.FlexForm('Keypad', auto_size_buttons=False) +form.Layout(layout) + +keys_entered = '' +while True: + button, values = form.Read() # read the form + if button is None: # if the X button clicked, just exit + break + if button == 'Clear': # clear keys if clear button + keys_entered = '' + elif button in '1234567890': + keys_entered = values['input'] # get what's been entered so far + keys_entered += button # add the new digit + elif button == 'Submit': + keys_entered = in_elem.Get() + out_elem.Update(keys_entered) # output the final string + + in_elem.Update(keys_entered) # change the form to reflect current key string + diff --git a/PySimpleGUI.py b/PySimpleGUI.py index ba25b2714..49ed1e5bc 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1,4 +1,3 @@ - #!/usr/bin/env Python3 import tkinter as tk from tkinter import filedialog @@ -165,12 +164,12 @@ def RGB(red,green,blue): return '#%02x%02x%02x' % (red,green,blue) # Element CLASS # # ------------------------------------------------------------------------- # class Element(): - def __init__(self, type, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None, key=None): + def __init__(self, type, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None, key=None, pad=None): self.Size = size self.Type = type self.AutoSizeText = auto_size_text self.Scale = scale - self.Pad = DEFAULT_ELEMENT_PADDING + self.Pad = DEFAULT_ELEMENT_PADDING if pad is None else pad self.Font = font self.TKStringVar = None @@ -217,7 +216,7 @@ def __del__(self): # Input Class # # ---------------------------------------------------------------------- # class InputText(Element): - def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None, text_color=None, do_not_clear=False, key=None, focus=False): + def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None, text_color=None, do_not_clear=False, key=None, focus=False, pad=None): ''' Input a line of text Element :param default_text: Default value to display @@ -233,7 +232,7 @@ def __init__(self, default_text ='', scale=(None, None), size=(None, None), auto fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR self.Focus = focus self.do_not_clear = do_not_clear - super().__init__(ELEM_TYPE_INPUT_TEXT, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=fg, key=key) + super().__init__(ELEM_TYPE_INPUT_TEXT, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=fg, key=key, pad=pad) def Update(self, new_value): @@ -250,7 +249,7 @@ def __del__(self): # ---------------------------------------------------------------------- # class InputCombo(Element): - def __init__(self, values, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None, key=None): + def __init__(self, values, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None, key=None, pad=None): ''' Input Combo Box Element (also called Dropdown box) :param values: @@ -264,7 +263,7 @@ def __init__(self, values, scale=(None, None), size=(None, None), auto_size_text bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR - super().__init__(ELEM_TYPE_INPUT_COMBO, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=fg, key=key) + super().__init__(ELEM_TYPE_INPUT_COMBO, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=fg, key=key, pad=pad) def __del__(self): try: @@ -278,8 +277,7 @@ def __del__(self): # Listbox # # ---------------------------------------------------------------------- # class Listbox(Element): - - def __init__(self, values, select_mode=None, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None, key=None): + def __init__(self, values, select_mode=None, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None, key=None, pad=None): ''' Listbox Element :param values: @@ -303,7 +301,7 @@ def __init__(self, values, select_mode=None, scale=(None, None), size=(None, Non self.SelectMode = DEFAULT_LISTBOX_SELECT_MODE bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR - super().__init__(ELEM_TYPE_INPUT_LISTBOX, scale=scale, size=size, auto_size_text=auto_size_text, font=font, background_color=bg, text_color=fg, key=key) + super().__init__(ELEM_TYPE_INPUT_LISTBOX, scale=scale, size=size, auto_size_text=auto_size_text, font=font, background_color=bg, text_color=fg, key=key, pad=pad) def Update(self, values): self.TKListbox.delete(0, 'end') @@ -324,7 +322,7 @@ def __del__(self): # Radio # # ---------------------------------------------------------------------- # class Radio(Element): - def __init__(self, text, group_id, default=False, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None, font=None, key=None): + def __init__(self, text, group_id, default=False, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None, font=None, key=None, pad=None): ''' Radio Button Element :param text: @@ -341,7 +339,7 @@ def __init__(self, text, group_id, default=False, scale=(None, None), size=(None self.TKRadio = None self.GroupID = group_id self.Value = None - super().__init__(ELEM_TYPE_INPUT_RADIO, scale=scale , size=size, auto_size_text=auto_size_text, font=font, background_color=background_color, text_color=text_color, key=key) + super().__init__(ELEM_TYPE_INPUT_RADIO, scale=scale , size=size, auto_size_text=auto_size_text, font=font, background_color=background_color, text_color=text_color, key=key, pad=pad) def __del__(self): try: @@ -354,7 +352,7 @@ def __del__(self): # Checkbox # # ---------------------------------------------------------------------- # class Checkbox(Element): - def __init__(self, text, default=False, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None, key=None): + def __init__(self, text, default=False, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None, key=None, pad=None): ''' Check Box Element :param text: @@ -370,7 +368,7 @@ def __init__(self, text, default=False, scale=(None, None), size=(None, None), a self.Value = None self.TKCheckbutton = None - super().__init__(ELEM_TYPE_INPUT_CHECKBOX, scale=scale, size=size, auto_size_text=auto_size_text, font=font, background_color=background_color, text_color=text_color, key=key) + super().__init__(ELEM_TYPE_INPUT_CHECKBOX, scale=scale, size=size, auto_size_text=auto_size_text, font=font, background_color=background_color, text_color=text_color, key=key, pad=pad) def Get(self): return self.TKIntVar.get() @@ -393,7 +391,7 @@ def __del__(self): class Spin(Element): # Values = None # TKSpinBox = None - def __init__(self, values, initial_value=None, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None, key=None): + def __init__(self, values, initial_value=None, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None, key=None, pad=None): ''' Spin Box Element :param values: @@ -410,7 +408,7 @@ def __init__(self, values, initial_value=None, scale=(None, None), size=(None, N bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR - super().__init__(ELEM_TYPE_INPUT_SPIN, scale, size, auto_size_text, font=font,background_color=bg, text_color=fg, key=key) + super().__init__(ELEM_TYPE_INPUT_SPIN, scale, size, auto_size_text, font=font,background_color=bg, text_color=fg, key=key, pad=pad) return def __del__(self): @@ -424,7 +422,7 @@ def __del__(self): # Multiline # # ---------------------------------------------------------------------- # class Multiline(Element): - def __init__(self, default_text='', enter_submits = False, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None, do_not_clear=False, key=None, focus=False): + def __init__(self, default_text='', enter_submits = False, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None, do_not_clear=False, key=None, focus=False, pad=None): ''' Input Multi-line Element :param default_text: @@ -441,7 +439,7 @@ def __init__(self, default_text='', enter_submits = False, scale=(None, None), s self.do_not_clear = do_not_clear fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR - super().__init__(ELEM_TYPE_INPUT_MULTILINE, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=fg, key=key) + super().__init__(ELEM_TYPE_INPUT_MULTILINE, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=fg, key=key, pad=pad) return def Update(self, NewValue): @@ -458,7 +456,7 @@ def __del__(self): # Text # # ---------------------------------------------------------------------- # class Text(Element): - def __init__(self, text, scale=(None, None), size=(None, None), auto_size_text=None, font=None, text_color=None, background_color=None,justification=None): + def __init__(self, text, scale=(None, None), size=(None, None), auto_size_text=None, font=None, text_color=None, background_color=None,justification=None, pad=None): ''' Text Element - Displays text in your form. Can be updated in non-blocking forms :param text: The text to display @@ -477,9 +475,7 @@ def __init__(self, text, scale=(None, None), size=(None, None), auto_size_text=N bg = DEFAULT_TEXT_ELEMENT_BACKGROUND_COLOR else: bg = background_color - # self.Font = Font if Font else DEFAULT_FONT - # i=1/0 - super().__init__(ELEM_TYPE_TEXT, scale, size, auto_size_text, background_color=bg, font=font if font else DEFAULT_FONT, text_color=self.TextColor) + super().__init__(ELEM_TYPE_TEXT, scale, size, auto_size_text, background_color=bg, font=font if font else DEFAULT_FONT, text_color=self.TextColor, pad=pad) return def Update(self, new_value = None, background_color=None, text_color=None): @@ -590,7 +586,7 @@ def __del__(self): # Routes stdout, stderr to a scrolled window # # ---------------------------------------------------------------------- # class Output(Element): - def __init__(self, scale=(None, None), size=(None, None), background_color=None, text_color=None): + def __init__(self, scale=(None, None), size=(None, None), background_color=None, text_color=None, pad=None): ''' Output Element - reroutes stdout, stderr to this window :param scale: Adds multiplier to size (w,h) @@ -601,7 +597,7 @@ def __init__(self, scale=(None, None), size=(None, None), background_color=None, bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR - super().__init__(ELEM_TYPE_OUTPUT, scale=scale, size=size, background_color=bg, text_color=fg) + super().__init__(ELEM_TYPE_OUTPUT, scale=scale, size=size, background_color=bg, text_color=fg, pad=pad) def __del__(self): try: @@ -614,7 +610,7 @@ def __del__(self): # Button Class # # ---------------------------------------------------------------------- # class Button(Element): - def __init__(self, button_type=BUTTON_TYPE_CLOSES_WIN, target=(None, None), button_text='', file_types=(("ALL Files", "*.*"),), image_filename=None, image_size=(None, None), image_subsample=None, border_width=None, scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False): + def __init__(self, button_type=BUTTON_TYPE_CLOSES_WIN, target=(None, None), button_text='', file_types=(("ALL Files", "*.*"),), image_filename=None, image_size=(None, None), image_subsample=None, border_width=None, scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False, pad=None): ''' Button Element - Specifies all types of buttons :param button_type: @@ -645,7 +641,7 @@ def __init__(self, button_type=BUTTON_TYPE_CLOSES_WIN, target=(None, None), butt self.BorderWidth = border_width if border_width is not None else DEFAULT_BORDER_WIDTH self.BindReturnKey = bind_return_key self.Focus = focus - super().__init__(ELEM_TYPE_BUTTON, scale, size, font=font) + super().__init__(ELEM_TYPE_BUTTON, scale=scale, size=size, font=font, pad=pad) return def ButtonReleaseCallBack(self, parm): @@ -731,7 +727,7 @@ def __del__(self): # ProgreessBar # # ---------------------------------------------------------------------- # class ProgressBar(Element): - def __init__(self, max_value, orientation=None, scale=(None, None), size=(None, None), auto_size_text=None, bar_color=(None, None), style=None, border_width=None, relief=None): + def __init__(self, max_value, orientation=None, scale=(None, None), size=(None, None), auto_size_text=None, bar_color=(None, None), style=None, border_width=None, relief=None, pad=None): ''' Progress Bar Element :param max_value: @@ -754,7 +750,7 @@ def __init__(self, max_value, orientation=None, scale=(None, None), size=(None, self.BorderWidth = border_width if border_width else DEFAULT_PROGRESS_BAR_BORDER_WIDTH self.Relief = relief if relief else DEFAULT_PROGRESS_BAR_RELIEF self.BarExpired = False - super().__init__(ELEM_TYPE_PROGRESS_BAR, scale=scale, size=size, auto_size_text=auto_size_text) + super().__init__(ELEM_TYPE_PROGRESS_BAR, scale=scale, size=size, auto_size_text=auto_size_text, pad=pad) return def UpdateBar(self, current_count, max=None): @@ -779,7 +775,7 @@ def __del__(self): # Image # # ---------------------------------------------------------------------- # class Image(Element): - def __init__(self, filename=None, data=None,scale=(None, None), size=(None, None)): + def __init__(self, filename=None, data=None,scale=(None, None), size=(None, None), pad=None): ''' Image Element :param filename: @@ -792,7 +788,7 @@ def __init__(self, filename=None, data=None,scale=(None, None), size=(None, None if data is None and filename is None: print('* Warning... no image specified in Image Element! *') - super().__init__(ELEM_TYPE_IMAGE, scale=scale, size=size) + super().__init__(ELEM_TYPE_IMAGE, scale=scale, size=size, pad=pad) return def Update(self, filename=None, data=None): @@ -815,7 +811,7 @@ def __del__(self): # Slider # # ---------------------------------------------------------------------- # class Slider(Element): - def __init__(self, range=(None,None), default_value=None, orientation=None, border_width=None, relief=None, scale=(None, None), size=(None, None), font=None, background_color=None, text_color=None, key=None): + def __init__(self, range=(None,None), default_value=None, orientation=None, border_width=None, relief=None, scale=(None, None), size=(None, None), font=None, background_color=None, text_color=None, key=None, pad=None): ''' Slider Element :param range: @@ -834,7 +830,7 @@ def __init__(self, range=(None,None), default_value=None, orientation=None, bord self.Orientation = orientation if orientation else DEFAULT_SLIDER_ORIENTATION self.BorderWidth = border_width if border_width else DEFAULT_SLIDER_BORDER_WIDTH self.Relief = relief if relief else DEFAULT_SLIDER_RELIEF - super().__init__(ELEM_TYPE_INPUT_SLIDER, scale=scale, size=size, font=font, background_color=background_color, text_color=text_color, key=key) + super().__init__(ELEM_TYPE_INPUT_SLIDER, scale=scale, size=size, font=font, background_color=background_color, text_color=text_color, key=key, pad=pad) return def Update(self, value, range=(None, None)): @@ -851,7 +847,7 @@ def __del__(self): # Column # # ---------------------------------------------------------------------- # class Column(Element): - def __init__(self, layout, background_color = None): + def __init__(self, layout, background_color = None, pad=None): self.UseDictionary = False self.ReturnValues = None self.ReturnValuesList = [] @@ -865,7 +861,7 @@ def __init__(self, layout, background_color = None): self.Layout(layout) - super().__init__(ELEM_TYPE_COLUMN, background_color=background_color) + super().__init__(ELEM_TYPE_COLUMN, background_color=background_color, pad=pad) return def AddRow(self, *args): @@ -1200,68 +1196,68 @@ def T(display_text, scale=(None, None), size=(None, None), auto_size_text=None, return Text(display_text, scale=scale, size=size, auto_size_text=auto_size_text, font=font, text_color=text_color, justification=justification) # ------------------------- FOLDER BROWSE Element lazy function ------------------------- # -def FolderBrowse(target=(ThisRow, -1), button_text='Browse', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): - return Button(BUTTON_TYPE_BROWSE_FOLDER, target=target, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color) +def FolderBrowse(target=(ThisRow, -1), button_text='Browse', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, pad=None): + return Button(BUTTON_TYPE_BROWSE_FOLDER, target=target, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, pad=pad) # ------------------------- FILE BROWSE Element lazy function ------------------------- # -def FileBrowse(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Browse', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): - return Button(BUTTON_TYPE_BROWSE_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) +def FileBrowse(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Browse', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, pad=None): + return Button(BUTTON_TYPE_BROWSE_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, pad=pad) # ------------------------- FILE BROWSE Element lazy function ------------------------- # -def FileSaveAs(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Save As...', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): - return Button(BUTTON_TYPE_SAVEAS_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) +def FileSaveAs(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Save As...', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, pad=None): + return Button(BUTTON_TYPE_SAVEAS_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, pad=pad) # ------------------------- SAVE AS Element lazy function ------------------------- # -def SaveAs(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Save As...', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None): - return Button(BUTTON_TYPE_SAVEAS_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font) +def SaveAs(target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), button_text='Save As...', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, pad=None): + return Button(BUTTON_TYPE_SAVEAS_FILE, target, button_text=button_text, file_types=file_types, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, pad=pad) # ------------------------- SAVE BUTTON Element lazy function ------------------------- # -def Save(button_text='Save', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True,font=None, focus=False): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color,font=font, bind_return_key=bind_return_key, focus=focus) +def Save(button_text='Save', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True,font=None, focus=False, pad=None): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color,font=font, bind_return_key=bind_return_key, focus=focus, pad=pad) # ------------------------- SUBMIT BUTTON Element lazy function ------------------------- # -def Submit(button_text='Submit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True,font=None, focus=False): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color,font=font, bind_return_key=bind_return_key, focus=focus) +def Submit(button_text='Submit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True,font=None, focus=False, pad=None): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color,font=font, bind_return_key=bind_return_key, focus=focus, pad=pad) # ------------------------- OK BUTTON Element lazy function ------------------------- # -def OK(button_text='OK', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True, font=None,focus=False): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color,font=font, bind_return_key=bind_return_key, focus=focus) +def OK(button_text='OK', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True, font=None,focus=False, pad=None): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color,font=font, bind_return_key=bind_return_key, focus=focus, pad=pad) # ------------------------- YES BUTTON Element lazy function ------------------------- # -def Ok(button_text='Ok', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True, font=None,focus=False): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus) +def Ok(button_text='Ok', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, bind_return_key=True, font=None,focus=False, pad=None): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad) # ------------------------- CANCEL BUTTON Element lazy function ------------------------- # -def Cancel(button_text='Cancel', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus) +def Cancel(button_text='Cancel', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False, pad=None): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad) # ------------------------- QUIT BUTTON Element lazy function ------------------------- # -def Quit(button_text='Quit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus) +def Quit(button_text='Quit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False, pad=None): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad) # ------------------------- Exit BUTTON Element lazy function ------------------------- # -def Exit(button_text='Exit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus) +def Exit(button_text='Exit', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False, pad=None): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad) # ------------------------- YES BUTTON Element lazy function ------------------------- # -def Yes(button_text='Yes', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None,font=None, bind_return_key=True, focus=False): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus) +def Yes(button_text='Yes', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None,font=None, bind_return_key=True, focus=False, pad=None): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad) # ------------------------- NO BUTTON Element lazy function ------------------------- # -def No(button_text='No', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None,font=None, bind_return_key=False, focus=False): - return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus) +def No(button_text='No', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None,font=None, bind_return_key=False, focus=False, pad=None): + return Button(BUTTON_TYPE_CLOSES_WIN, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad) # ------------------------- GENERIC BUTTON Element lazy function ------------------------- # # this is the only button that REQUIRES button text field -def SimpleButton(button_text, image_filename=None, image_size=(None, None), image_subsample=None, border_width=None, scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False): - return Button(BUTTON_TYPE_CLOSES_WIN, image_filename=image_filename, image_size=image_size, image_subsample=image_subsample, button_text=button_text, border_width=border_width, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus) +def SimpleButton(button_text, image_filename=None, image_size=(None, None), image_subsample=None, border_width=None, scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False, pad=None): + return Button(BUTTON_TYPE_CLOSES_WIN, image_filename=image_filename, image_size=image_size, image_subsample=image_subsample, button_text=button_text, border_width=border_width, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad) # ------------------------- GENERIC BUTTON Element lazy function ------------------------- # # this is the only button that REQUIRES button text field -def ReadFormButton(button_text, image_filename=None, image_size=(None, None),image_subsample=None,border_width=None,scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False): - return Button(BUTTON_TYPE_READ_FORM, image_filename=image_filename, image_size=image_size, image_subsample=image_subsample, border_width=border_width, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus) +def ReadFormButton(button_text, image_filename=None, image_size=(None, None),image_subsample=None,border_width=None,scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False, pad=None): + return Button(BUTTON_TYPE_READ_FORM, image_filename=image_filename, image_size=image_size, image_subsample=image_subsample, border_width=border_width, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad) -def RealtimeButton(button_text, image_filename=None, image_size=(None, None),image_subsample=None,border_width=None,scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False): - return Button(BUTTON_TYPE_REALTIME, image_filename=image_filename, image_size=image_size, image_subsample=image_subsample, border_width=border_width, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus) +def RealtimeButton(button_text, image_filename=None, image_size=(None, None),image_subsample=None,border_width=None,scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False, pad=None): + return Button(BUTTON_TYPE_REALTIME, image_filename=image_filename, image_size=image_size, image_subsample=image_subsample, border_width=border_width, button_text=button_text, scale=scale, size=size, auto_size_button=auto_size_button, button_color=button_color, font=font, bind_return_key=bind_return_key, focus=focus, pad=pad) ##################################### ----- RESULTS ------ ################################################## From ddaf87914dec3b28898eca7534cee3c0ce5db1a3 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sun, 26 Aug 2018 10:45:52 -0400 Subject: [PATCH 204/209] Cleanup keypad demo --- Demo_Keypad.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/Demo_Keypad.py b/Demo_Keypad.py index 3ca2afb42..124f34d08 100644 --- a/Demo_Keypad.py +++ b/Demo_Keypad.py @@ -2,22 +2,32 @@ # g.SetOptions(button_color=g.COLOR_SYSTEM_DEFAULT) # because some people like gray buttons +# Demonstrates a number of PySimpleGUI features including: +# Default element size +# auto_size_buttons +# ReadFormButton +# Dictionary return values +# Update of elements in form (Text, Input) +# do_not_clear of Input elements + + # create the 2 Elements we want to control outside the form out_elem = g.Text('', size=(15, 1), font=('Helvetica', 18), text_color='red') in_elem = g.Input(size=(10,1), do_not_clear=True, key='input') -layout = [[g.Text('Choose Test'), g.DropDown(values=['Input', 'Output', 'Some option']), g.ReadFormButton('Input Option', size=(10,1))], +layout = [[g.Text('Choose Test'), g.DropDown(values=['Input', 'Output', 'Some option']), g.ReadFormButton('Input Option', auto_size_button=True)], [in_elem], - [g.ReadFormButton('1', size=(5,2)), g.ReadFormButton('2', size=(5,2)), g.ReadFormButton('3', size=(5,2))], - [g.ReadFormButton('4', size=(5,2)), g.ReadFormButton('5', size=(5,2)), g.ReadFormButton('6', size=(5,2))], - [g.ReadFormButton('7', size=(5,2)), g.ReadFormButton('8', size=(5,2)), g.ReadFormButton('9', size=(5,2))], - [g.ReadFormButton('Submit', size=(5,2)),g.ReadFormButton('0', size=(5,2)), g.ReadFormButton('Clear', size=(5,2))], + [g.ReadFormButton('1'), g.ReadFormButton('2'), g.ReadFormButton('3')], + [g.ReadFormButton('4'), g.ReadFormButton('5'), g.ReadFormButton('6')], + [g.ReadFormButton('7'), g.ReadFormButton('8'), g.ReadFormButton('9')], + [g.ReadFormButton('Submit'),g.ReadFormButton('0'), g.ReadFormButton('Clear')], [out_elem], ] -form = g.FlexForm('Keypad', auto_size_buttons=False) +form = g.FlexForm('Keypad', default_element_size=(5,2), auto_size_buttons=False) form.Layout(layout) +# Loop forever reading the form's values, updating the Input field keys_entered = '' while True: button, values = form.Read() # read the form @@ -26,10 +36,10 @@ if button == 'Clear': # clear keys if clear button keys_entered = '' elif button in '1234567890': - keys_entered = values['input'] # get what's been entered so far + keys_entered = values['input'] # get what's been entered so far keys_entered += button # add the new digit elif button == 'Submit': - keys_entered = in_elem.Get() + keys_entered = values['input'] out_elem.Update(keys_entered) # output the final string in_elem.Update(keys_entered) # change the form to reflect current key string From e7c216dfe11bd5a942a0151f48b9b832d8bc2c7a Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sun, 26 Aug 2018 15:20:54 -0400 Subject: [PATCH 205/209] CANVAS Element! Fixes for autosizing, scroll-bar artifacts on Output, fonts for Output, all shortcut functions using new method --- PySimpleGUI.py | 93 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 68 insertions(+), 25 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 49ed1e5bc..f7103fd7d 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -139,6 +139,7 @@ def RGB(red,green,blue): return '#%02x%02x%02x' % (red,green,blue) ELEM_TYPE_INPUT_SPIN = 9 ELEM_TYPE_BUTTON = 3 ELEM_TYPE_IMAGE = 30 +ELEM_TYPE_CANVAS = 40 ELEM_TYPE_INPUT_SLIDER = 10 ELEM_TYPE_INPUT_LISTBOX = 11 ELEM_TYPE_OUTPUT = 300 @@ -542,12 +543,13 @@ def __del__(self): # Scroll bar will span the length of the frame # # ---------------------------------------------------------------------- # class TKOutput(tk.Frame): - def __init__(self, parent, width, height, bd, background_color=None, text_color=None): - frame = tk.Frame(parent, width=width, height=height) + def __init__(self, parent, width, height, bd, background_color=None, text_color=None, font=None): + frame = tk.Frame(parent) tk.Frame.__init__(self, frame) - self.output = tk.Text(frame, width=width, height=height, bd=bd) + self.output = tk.Text(frame, width=width, height=height, bd=bd, font=font) if background_color and background_color != COLOR_SYSTEM_DEFAULT: self.output.configure(background=background_color) + frame.configure(background=background_color) if text_color and text_color != COLOR_SYSTEM_DEFAULT: self.output.configure(fg=text_color) self.vsb = tk.Scrollbar(frame, orient="vertical", command=self.output.yview) @@ -586,7 +588,7 @@ def __del__(self): # Routes stdout, stderr to a scrolled window # # ---------------------------------------------------------------------- # class Output(Element): - def __init__(self, scale=(None, None), size=(None, None), background_color=None, text_color=None, pad=None): + def __init__(self, scale=(None, None), size=(None, None), background_color=None, text_color=None, pad=None, font=None): ''' Output Element - reroutes stdout, stderr to this window :param scale: Adds multiplier to size (w,h) @@ -597,7 +599,7 @@ def __init__(self, scale=(None, None), size=(None, None), background_color=None, bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR - super().__init__(ELEM_TYPE_OUTPUT, scale=scale, size=size, background_color=bg, text_color=fg, pad=pad) + super().__init__(ELEM_TYPE_OUTPUT, scale=scale, size=size, background_color=bg, text_color=fg, pad=pad, font=font) def __del__(self): try: @@ -807,6 +809,28 @@ def Update(self, filename=None, data=None): def __del__(self): super().__del__() + +# ---------------------------------------------------------------------- # +# Canvas # +# ---------------------------------------------------------------------- # +class Canvas(Element): + def __init__(self, background_color=None, scale=(None, None), size=(None, None), pad=None): + ''' + Image Element + :param filename: + :param scale: Adds multiplier to size (w,h) + :param size: Size of field in characters + ''' + self.BackgroundColor = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR + self.TKCanvas = None + + super().__init__(ELEM_TYPE_CANVAS, background_color=background_color, scale=scale, size=size, pad=pad) + return + + def __del__(self): + super().__del__() + + # ---------------------------------------------------------------------- # # Slider # # ---------------------------------------------------------------------- # @@ -1168,11 +1192,14 @@ def __del__(self): # ====================================================================== # # ------------------------- INPUT TEXT Element lazy functions ------------------------- # -def In(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None, text_color=None, do_not_clear=False, key=None, focus=False): - return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, password_char=password_char, background_color=background_color, text_color=text_color, do_not_clear=do_not_clear, focus=focus, key=key) +In = InputText +Input = InputText +#### TODO REMOVE THESE COMMENTS - was the old way, but want to keep around for a bit just in case +# def In(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None, text_color=None, do_not_clear=False, key=None, focus=False): +# return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, password_char=password_char, background_color=background_color, text_color=text_color, do_not_clear=do_not_clear, focus=focus, key=key) -def Input(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None, text_color=None, do_not_clear=False, key=None, focus=False): - return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, password_char=password_char, background_color=background_color, text_color=text_color, do_not_clear=do_not_clear, focus=focus, key=key) +# def Input(default_text ='', scale=(None, None), size=(None, None), auto_size_text=None, password_char='', background_color=None, text_color=None, do_not_clear=False, key=None, focus=False): +# return InputText(default_text=default_text, scale=scale, size=size, auto_size_text=auto_size_text, password_char=password_char, background_color=background_color, text_color=text_color, do_not_clear=do_not_clear, focus=focus, key=key) # ------------------------- CHECKBOX Element lazy functions ------------------------- # CB = Checkbox @@ -1180,20 +1207,29 @@ def Input(default_text ='', scale=(None, None), size=(None, None), auto_size_tex Check = Checkbox # ------------------------- INPUT COMBO Element lazy functions ------------------------- # -def Combo(values, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None): - return InputCombo(values=values, scale=scale, size=size, auto_size_text=auto_size_text, background_color=background_color) - -def DropDown(values, scale=(None, None), size=(None, None), auto_size_text=None): - return InputCombo(values=values, scale=scale, size=size, auto_size_text=auto_size_text) -def Drop(values, scale=(None, None), size=(None, None), auto_size_text=None): - return InputCombo(values=values, scale=scale, size=size, auto_size_text=auto_size_text) +Combo = InputCombo +DropDown = InputCombo +Drop = InputCombo + +# def Combo(values, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None): +# return InputCombo(values=values, scale=scale, size=size, auto_size_text=auto_size_text, background_color=background_color) +# +# def DropDown(values, scale=(None, None), size=(None, None), auto_size_text=None): +# return InputCombo(values=values, scale=scale, size=size, auto_size_text=auto_size_text) +# +# def Drop(values, scale=(None, None), size=(None, None), auto_size_text=None): +# return InputCombo(values=values, scale=scale, size=size, auto_size_text=auto_size_text) # ------------------------- TEXT Element lazy functions ------------------------- # -def Txt(display_text, scale=(None, None), size=(None, None), auto_size_text=None, font=None, text_color=None, justification=None): - return Text(display_text, scale=scale, size=size, auto_size_text=auto_size_text, font=font, text_color=text_color, justification=justification) -def T(display_text, scale=(None, None), size=(None, None), auto_size_text=None, font=None, text_color=None, justification=None): - return Text(display_text, scale=scale, size=size, auto_size_text=auto_size_text, font=font, text_color=text_color, justification=justification) +Txt = Text +T = Text + +# def Txt(display_text, scale=(None, None), size=(None, None), auto_size_text=None, font=None, text_color=None, justification=None): +# return Text(display_text, scale=scale, size=size, auto_size_text=auto_size_text, font=font, text_color=text_color, justification=justification) +# +# def T(display_text, scale=(None, None), size=(None, None), auto_size_text=None, font=None, text_color=None, justification=None): +# return Text(display_text, scale=scale, size=size, auto_size_text=auto_size_text, font=font, text_color=text_color, justification=justification) # ------------------------- FOLDER BROWSE Element lazy function ------------------------- # def FolderBrowse(target=(ThisRow, -1), button_text='Browse', scale=(None, None), size=(None, None), auto_size_button=None, button_color=None, font=None, pad=None): @@ -1469,7 +1505,7 @@ def CharWidthInPixels(): stringvar = tk.StringVar() element.TKStringVar = stringvar stringvar.set(display_text) - if element.AutoSizeText: + if auto_size_text: width = 0 if element.Justification is not None: justification = element.Justification @@ -1500,7 +1536,7 @@ def CharWidthInPixels(): if element.AutoSizeButton is not None: auto_size = element.AutoSizeButton else: auto_size = toplevel_form.AutoSizeButtons - if auto_size is False: width=element_size[0] + if auto_size is False or element.Size[0] is not None: width=element_size[0] else: width = 0 height=element_size[1] lines = btext.split('\n') @@ -1702,8 +1738,8 @@ def CharWidthInPixels(): # ------------------------- OUTPUT element ------------------------- # elif element_type == ELEM_TYPE_OUTPUT: width, height = element_size - element.TKOut = TKOutput(tk_row_frame, width=width, height=height, bd=border_depth, background_color=element.BackgroundColor, text_color=text_color) - element.TKOut.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) + element.TKOut = TKOutput(tk_row_frame, width=width, height=height, bd=border_depth, background_color=element.BackgroundColor, text_color=text_color, font=font) + element.TKOut.pack(side=tk.LEFT) # ------------------------- IMAGE Box element ------------------------- # elif element_type == ELEM_TYPE_IMAGE: if element.Filename is not None: @@ -1723,6 +1759,13 @@ def CharWidthInPixels(): element.tktext_label.image = photo # tktext_label.configure(anchor=tk.NW, image=photo) element.tktext_label.pack(side=tk.LEFT, padx=element.Pad[0],pady=element.Pad[1]) + # ------------------------- Canvas element ------------------------- # + elif element_type == ELEM_TYPE_CANVAS: + width, height = element_size + element.TKCanvas = tk.Canvas(tk_row_frame, width=width, height=height, bd=border_depth) + if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: + element.TKCanvas.configure(background=element.BackgroundColor) + element.TKCanvas.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) # ------------------------- SLIDER Box element ------------------------- # elif element_type == ELEM_TYPE_INPUT_SLIDER: slider_length = element_size[0] * CharWidthInPixels() @@ -1954,7 +1997,7 @@ def MsgBox(*args, button_color=None, button_type=MSG_BOX_OK, auto_close=False, a # height = _GetNumLinesNeeded(message, width_used) height = message_wrapped_lines # print('Msgbox width, height', width_used, height) - form.AddRow(Text(message_wrapped, auto_size_text=True, size=(width_used, height))) + form.AddRow(Text(message_wrapped, auto_size_text=True)) total_lines += height pad = max_line_total-15 if max_line_total > 15 else 1 From ceafe787b25bcf1a77cbb136bc9cb09a5379329c Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sun, 26 Aug 2018 15:29:12 -0400 Subject: [PATCH 206/209] New CANVAS Demo, updated PNG Viewer Demo --- Demo_Canvas.py | 22 ++++++++++++++++++++++ Demo_PNG_Viewer.py | 38 +++++++++++++++++++++++--------------- 2 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 Demo_Canvas.py diff --git a/Demo_Canvas.py b/Demo_Canvas.py new file mode 100644 index 000000000..35eec4942 --- /dev/null +++ b/Demo_Canvas.py @@ -0,0 +1,22 @@ +import PySimpleGUI as gui + +canvas = gui.Canvas(size=(100,100), background_color='red') + +layout = [ + [canvas], + [gui.T('Change circle color to:'), gui.ReadFormButton('Red'), gui.ReadFormButton('Blue')] + ] + +form = gui.FlexForm('Canvas test') +form.Layout(layout) +form.ReadNonBlocking() + +cir = canvas.TKCanvas.create_oval(50, 50, 100, 100) + +while True: + button, values = form.Read() + if button is None: break + if button is 'Blue': + canvas.TKCanvas.itemconfig(cir, fill = "Blue") + elif button is 'Red': + canvas.TKCanvas.itemconfig(cir, fill = "Red") diff --git a/Demo_PNG_Viewer.py b/Demo_PNG_Viewer.py index 4729d9c3c..7d6bcd7d4 100644 --- a/Demo_PNG_Viewer.py +++ b/Demo_PNG_Viewer.py @@ -4,54 +4,62 @@ # Simple Image Browser based on PySimpleGUI # Get the folder containing the images from the user -rc, folder = sg.GetPathBox('Image Browser', 'Image folder to open', default_path='A:/TEMP/PDFs') +rc, folder = sg.GetPathBox('Image Browser', 'Image folder to open', default_path='') if rc is False or folder is '': sg.MsgBoxCancel('Cancelling') exit(0) # get list of PNG files in folder png_files = [folder + '\\' + f for f in os.listdir(folder) if '.png' in f] +filenames_only = [f for f in os.listdir(folder) if '.png' in f] if len(png_files) == 0: sg.MsgBox('No PNG images in folder') exit(0) # create the form that also returns keyboard events -form = sg.FlexForm('Image Browser', return_keyboard_events=True) +form = sg.FlexForm('Image Browser', return_keyboard_events=True, location=(0,0), use_default_focus=False ) # make these 2 elements outside the layout because want to "update" them later # initialize to the first PNG file in the list image_elem = sg.Image(filename=png_files[0]) filename_display_elem = sg.Text(png_files[0], size=(80, 3)) -file_num_display_elem = sg.Text('File 1 of {}'.format(len(png_files)), size=(10,1)) +file_num_display_elem = sg.Text('File 1 of {}'.format(len(png_files)), size=(15,1)) # define layout, show and read the form -layout = [[filename_display_elem], +col = [[filename_display_elem], [image_elem], [sg.ReadFormButton('Next', size=(8,2)), sg.ReadFormButton('Prev', size=(8,2)), file_num_display_elem]] -form.LayoutAndRead(layout) # Shows form on screen +col_files = [[sg.Listbox(values=filenames_only, size=(60,30), key='listbox')], + [sg.ReadFormButton('Read')]] +layout = [[sg.Column(col_files), sg.Column(col)]] +button, values = form.LayoutAndRead(layout) # Shows form on screen # loop reading the user input and displaying image, filename i=0 while True: - f = png_files[i] - # update window with new image - image_elem.Update(filename=f) - # update window with filename - filename_display_elem.Update(f) - # update page display - file_num_display_elem.Update('File {} of {}'.format(i+1, len(png_files))) - # read the form - button, values = form.Read() # perform button and keyboard operations if button is None: break - elif button in ('Next', 'MouseWheel:Down', 'Down:40', 'Next:34') and i < len(png_files): + elif button in ('Next', 'MouseWheel:Down', 'Down:40', 'Next:34') and i < len(png_files)-1: i += 1 elif button in ('Prev', 'MouseWheel:Up', 'Up:38', 'Prior:33') and i > 0: i -= 1 + if button == 'Read': + filename = folder + '\\' + values['listbox'][0] + # print(filename) + else: + filename = png_files[i] + # update window with new image + image_elem.Update(filename=filename) + # update window with filename + filename_display_elem.Update(filename) + # update page display + file_num_display_elem.Update('File {} of {}'.format(i+1, len(png_files))) + # read the form + button, values = form.Read() From 4062b2b41cc003b34aaccbad2129d2f476baac41 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sun, 26 Aug 2018 16:10:39 -0400 Subject: [PATCH 207/209] Canvas Recipe, Update Input Element Recipe --- docs/cookbook.md | 100 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/docs/cookbook.md b/docs/cookbook.md index 256b2cbfc..4180f7745 100644 --- a/docs/cookbook.md +++ b/docs/cookbook.md @@ -634,3 +634,103 @@ This simple program keep a form open, taking input values until the user termina break + +## tkinter Canvas Widget + +The Canvas Element is one of the few tkinter objects that are directly accessible. The tkinter Canvas widget itself can be retrieved from a Canvas Element like this: + + can = sg.Canvas(size=(100,100)) + tkcanvas = can.TKCanvas + tkcanvas.create_oval(50, 50, 100, 100) + + +![canvas](https://user-images.githubusercontent.com/13696193/44632429-5266ac00-a948-11e8-9ee0-664103c40178.jpg) + + + + + import PySimpleGUI as gui + + canvas = gui.Canvas(size=(100,100), background_color='red') + + layout = [ + [canvas], + [gui.T('Change circle color to:'), gui.ReadFormButton('Red'), gui.ReadFormButton('Blue')] + ] + + form = gui.FlexForm('Canvas test') + form.Layout(layout) + form.ReadNonBlocking() + + cir = canvas.TKCanvas.create_oval(50, 50, 100, 100) + + while True: + button, values = form.Read() + if button is None: + break + if button is 'Blue': + canvas.TKCanvas.itemconfig(cir, fill = "Blue") + elif button is 'Red': + canvas.TKCanvas.itemconfig(cir, fill = "Red") + + +## Input Element Update + +This Recipe implements a Raspberry Pi touchscreen based keypad entry. As the digits are entered using the buttons, the Input Element above it is updated with the input digits. +There are a number of features used in this Recipe including: +* Default Element Size +* auto_size_buttons +* ReadFormButton +* Dictionary Return values +* Update of Elements in form (Input, Text) +* do_not_clear of Input Elements + +. + + + + import PySimpleGUI as g + + # g.SetOptions(button_color=g.COLOR_SYSTEM_DEFAULT) # because some people like gray buttons + + # Demonstrates a number of PySimpleGUI features including: + # Default element size + # auto_size_buttons + # ReadFormButton + # Dictionary return values + # Update of elements in form (Text, Input) + # do_not_clear of Input elements + + + # create the 2 Elements we want to control outside the form + out_elem = g.Text('', size=(15, 1), font=('Helvetica', 18), text_color='red') + in_elem = g.Input(size=(10, 1), do_not_clear=True, key='input') + + layout = [[g.Text('Enter Your Passcode')], + [in_elem], + [g.ReadFormButton('1'), g.ReadFormButton('2'), g.ReadFormButton('3')], + [g.ReadFormButton('4'), g.ReadFormButton('5'), g.ReadFormButton('6')], + [g.ReadFormButton('7'), g.ReadFormButton('8'), g.ReadFormButton('9')], + [g.ReadFormButton('Submit'), g.ReadFormButton('0'), g.ReadFormButton('Clear')], + [out_elem], + ] + + form = g.FlexForm('Keypad', default_element_size=(5, 2), auto_size_buttons=False) + form.Layout(layout) + + # Loop forever reading the form's values, updating the Input field + keys_entered = '' + while True: + button, values = form.Read() # read the form + if button is None: # if the X button clicked, just exit + break + if button is 'Clear': # clear keys if clear button + keys_entered = '' + elif button in '1234567890': + keys_entered = values['input'] # get what's been entered so far + keys_entered += button # add the new digit + elif button is 'Submit': + keys_entered = values['input'] + out_elem.Update(keys_entered) # output the final string + + in_elem.Update(keys_entered) # change the form to reflect current key string From fad8378cb0997dbd7b3c13188079f7a5069f12ef Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sun, 26 Aug 2018 19:58:57 -0400 Subject: [PATCH 208/209] Delete SimScript_.py --- SimScript_.py | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 SimScript_.py diff --git a/SimScript_.py b/SimScript_.py deleted file mode 100644 index 2185935b3..000000000 --- a/SimScript_.py +++ /dev/null @@ -1,4 +0,0 @@ -import time - -for i in range(100): - print(i,'', end='') From 0def4bf436c30ede458b3c612f6118101c621762 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sun, 26 Aug 2018 22:16:54 -0400 Subject: [PATCH 209/209] Demo Matplotlib, Canvas Element changes, new Frame Element, added pad to Text, Slider Plus a few other tweaks & bug fixes --- Demo_Matplotlib.py | 73 +++++++++++++++++++++++++++++++++++++++++ Demo_Script_Launcher.py | 2 +- PySimpleGUI.py | 57 +++++++++++++++++++++----------- SimScript_.py | 4 --- 4 files changed, 111 insertions(+), 25 deletions(-) create mode 100644 Demo_Matplotlib.py delete mode 100644 SimScript_.py diff --git a/Demo_Matplotlib.py b/Demo_Matplotlib.py new file mode 100644 index 000000000..ea6affc3e --- /dev/null +++ b/Demo_Matplotlib.py @@ -0,0 +1,73 @@ +import PySimpleGUI as g +import matplotlib +matplotlib.use('TkAgg') +from numpy import arange, sin, pi +from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, FigureCanvasAgg +from matplotlib.figure import Figure +import matplotlib.backends.tkagg as tkagg +import sys +import tkinter as Tk + +""" +Demonstrates one way of embedding Matplotlib figures into a PySimpleGUI window. + +Basic steps are: + * Create a Canvas Element + * Layout form + * Display form (NON BLOCKING) + * Draw plots onto convas + * Display form (BLOCKING) +""" + + +def draw_figure(canvas, figure, loc=(0, 0)): + """ Draw a matplotlib figure onto a Tk canvas + + loc: location of top-left corner of figure on canvas in pixels. + + Inspired by matplotlib source: lib/matplotlib/backends/backend_tkagg.py + """ + figure_canvas_agg = FigureCanvasAgg(figure) + figure_canvas_agg.draw() + figure_x, figure_y, figure_w, figure_h = figure.bbox.bounds + figure_w, figure_h = int(figure_w), int(figure_h) + photo = Tk.PhotoImage(master=canvas, width=figure_w, height=figure_h) + + # Position: convert from top-left anchor to center anchor + canvas.create_image(loc[0] + figure_w/2, loc[1] + figure_h/2, image=photo) + + # Unfortunately, there's no accessor for the pointer to the native renderer + tkagg.blit(photo, figure_canvas_agg.get_renderer()._renderer, colormode=2) + + # Return a handle which contains a reference to the photo object + # which must be kept live or else the picture disappears + return photo + +f = Figure(figsize=(5, 4), dpi=100) +a = f.add_subplot(111) +t = arange(0.0, 3.0, 0.01) +s = sin(2*pi*t) + +a.plot(t, s) +a.set_title('Tk embedding') +a.set_xlabel('X axis label') +a.set_ylabel('Y label') + +# -------------------------------- GUI Starts Here -------------------------------- +canvas_elem = g.Canvas(size=(500, 400)) # get the canvas we'll be drawing on +# define the form layout +layout = [[g.Text('Plot test')], + [canvas_elem], + [g.OK(pad=((250,0), 3))]] + +# create the form and show it without the plot +form = g.FlexForm('Demo Application - Embedding Matplotlib In PySimpleGUI') +form.Layout(layout) +form.ReadNonBlocking() + +# add the plot to the window +fig_photo = draw_figure(canvas_elem.TKCanvas, f) + +# show it all again and get buttons +button, values = form.Read() + diff --git a/Demo_Script_Launcher.py b/Demo_Script_Launcher.py index 50370a42e..3361023d7 100644 --- a/Demo_Script_Launcher.py +++ b/Demo_Script_Launcher.py @@ -7,7 +7,7 @@ def Launcher(): layout = [ [sg.Text('Script output....', size=(40, 1))], - [sg.Output(size=(88, 20))], + [sg.Output(size=(88, 20), font='Courier 10')], [sg.ReadFormButton('script1'), sg.ReadFormButton('script2'), sg.SimpleButton('EXIT')], [sg.Text('Manual command', size=(15,1)), sg.InputText(focus=True), sg.ReadFormButton('Run', bind_return_key=True)] ] diff --git a/PySimpleGUI.py b/PySimpleGUI.py index f7103fd7d..c26fb7499 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -140,6 +140,7 @@ def RGB(red,green,blue): return '#%02x%02x%02x' % (red,green,blue) ELEM_TYPE_BUTTON = 3 ELEM_TYPE_IMAGE = 30 ELEM_TYPE_CANVAS = 40 +ELEM_TYPE_FRAME = 41 ELEM_TYPE_INPUT_SLIDER = 10 ELEM_TYPE_INPUT_LISTBOX = 11 ELEM_TYPE_OUTPUT = 300 @@ -506,6 +507,7 @@ def __init__(self, root, max, length=400, width=DEFAULT_PROGRESS_BAR_SIZE[1], st self.Orientation = orientation self.Count = None self.PriorCount = 0 + if orientation[0].lower() == 'h': s = ttk.Style() s.theme_use(style) @@ -814,15 +816,9 @@ def __del__(self): # Canvas # # ---------------------------------------------------------------------- # class Canvas(Element): - def __init__(self, background_color=None, scale=(None, None), size=(None, None), pad=None): - ''' - Image Element - :param filename: - :param scale: Adds multiplier to size (w,h) - :param size: Size of field in characters - ''' + def __init__(self, canvas=None, background_color=None, scale=(None, None), size=(None, None), pad=None): self.BackgroundColor = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR - self.TKCanvas = None + self.TKCanvas = canvas super().__init__(ELEM_TYPE_CANVAS, background_color=background_color, scale=scale, size=size, pad=pad) return @@ -831,6 +827,20 @@ def __del__(self): super().__del__() +# ---------------------------------------------------------------------- # +# Frame # +# ---------------------------------------------------------------------- # +class Frame(Element): + def __init__(self, frame=None, background_color=None, scale=(None, None), size=(None, None), pad=None): + self.BackgroundColor = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR + self.TKFrame = frame + + super().__init__(ELEM_TYPE_FRAME, background_color=background_color, scale=scale, size=size, pad=pad) + return + + def __del__(self): + super().__del__() + # ---------------------------------------------------------------------- # # Slider # # ---------------------------------------------------------------------- # @@ -1058,6 +1068,7 @@ def _AutoCloseAlarmCallback(self): pass def Read(self): + self.NonBlocking = False if self.TKrootDestroyed: return None, None if not self.Shown: @@ -1484,7 +1495,7 @@ def CharWidthInPixels(): if element_type == ELEM_TYPE_COLUMN: col_frame = tk.Frame(tk_row_frame) PackFormIntoFrame(element, col_frame, toplevel_form) - col_frame.pack(side=tk.LEFT) + col_frame.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) if element.BackgroundColor != COLOR_SYSTEM_DEFAULT and element.BackgroundColor is not None: col_frame.configure(background=element.BackgroundColor, highlightbackground=element.BackgroundColor, highlightcolor=element.BackgroundColor) # ------------------------- TEXT element ------------------------- # @@ -1515,18 +1526,18 @@ def CharWidthInPixels(): justification = DEFAULT_TEXT_JUSTIFICATION justify = tk.LEFT if justification == 'left' else tk.CENTER if justification == 'center' else tk.RIGHT anchor = tk.NW if justification == 'left' else tk.N if justification == 'center' else tk.NE - tktext_label = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height, justify=justify, bd=border_depth) + tktext_label = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height, justify=justify, bd=border_depth, font=font) # Set wrap-length for text (in PIXELS) == PAIN IN THE ASS wraplen = tktext_label.winfo_reqwidth()+40 # width of widget in Pixels if not auto_size_text: wraplen = 0 # print("wraplen, width, height", wraplen, width, height) - tktext_label.configure(anchor=anchor, font=font, wraplen=wraplen) # set wrap to width of widget + tktext_label.configure(anchor=anchor, wraplen=wraplen) # set wrap to width of widget if element.BackgroundColor is not None: tktext_label.configure(background=element.BackgroundColor) if element.TextColor != COLOR_SYSTEM_DEFAULT and element.TextColor is not None: tktext_label.configure(fg=element.TextColor) - tktext_label.pack(side=tk.LEFT) + tktext_label.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1]) element.TKText = tktext_label # ------------------------- BUTTON element ------------------------- # elif element_type == ELEM_TYPE_BUTTON: @@ -1550,9 +1561,9 @@ def CharWidthInPixels(): bc = DEFAULT_BUTTON_COLOR border_depth = element.BorderWidth if btype != BUTTON_TYPE_REALTIME: - tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height,command=element.ButtonCallBack, justify=tk.LEFT, bd=border_depth) + tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height,command=element.ButtonCallBack, justify=tk.LEFT, bd=border_depth, font=font) else: - tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height, justify=tk.LEFT, bd=border_depth) + tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height, justify=tk.LEFT, bd=border_depth, font=font) tkbutton.bind('', element.ButtonReleaseCallBack) tkbutton.bind('', element.ButtonPressCallBack) if bc != (None, None) and bc != COLOR_SYSTEM_DEFAULT: @@ -1571,9 +1582,7 @@ def CharWidthInPixels(): tkbutton.config(image=photo, width=width, height=height) tkbutton.image = photo if width != 0: - tkbutton.configure(wraplength=wraplen+10, font=font) # set wrap to width of widget - else: - tkbutton.configure(font=font) # only set the font, not wraplength + tkbutton.configure(wraplength=wraplen+10) # set wrap to width of widget tkbutton.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) if element.Focus is True or (toplevel_form.UseDefaultFocus and not focus_set): focus_set = True @@ -1698,7 +1707,6 @@ def CharWidthInPixels(): else: bar_color = DEFAULT_PROGRESS_BAR_COLOR element.TKProgressBar = TKProgressBar(tk_row_frame, element.MaxValue, progress_length, progress_width, orientation=direction, BarColor=bar_color, border_width=element.BorderWidth, relief=element.Relief, style=element.BarStyle ) - # element.TKProgressBar = TKProgressBar(tk_row_frame, element.MaxValue, progress_length, progress_width, orientation=direction, BarColor=bar_color, border_width=element.BorderWidth, relief=element.Relief) element.TKProgressBar.TKProgressBarForReal.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) # ------------------------- INPUT RADIO BUTTON element ------------------------- # elif element_type == ELEM_TYPE_INPUT_RADIO: @@ -1762,10 +1770,19 @@ def CharWidthInPixels(): # ------------------------- Canvas element ------------------------- # elif element_type == ELEM_TYPE_CANVAS: width, height = element_size - element.TKCanvas = tk.Canvas(tk_row_frame, width=width, height=height, bd=border_depth) + if element.TKCanvas is None: + element.TKCanvas = tk.Canvas(tk_row_frame, width=width, height=height, bd=border_depth) if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: element.TKCanvas.configure(background=element.BackgroundColor) element.TKCanvas.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) + # ------------------------- Frame element ------------------------- # + elif element_type == ELEM_TYPE_FRAME: + width, height = element_size + if element.TKFrame is None: + element.TKFrame = tk.Frame(tk_row_frame, width=width, height=height, bd=border_depth) + if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: + element.TKFrame.configure(background=element.BackgroundColor) + element.TKFrame.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1]) # ------------------------- SLIDER Box element ------------------------- # elif element_type == ELEM_TYPE_INPUT_SLIDER: slider_length = element_size[0] * CharWidthInPixels() @@ -2659,7 +2676,7 @@ def SetOptions(icon=None, button_color=None, element_size=(None,None), margins=( ############################################################## def ChangeLookAndFeel(index): # look and feel table - look_and_feel = {'GreenTan': {'BACKGROUND' : '#9FB8AD', 'TEXT': COLOR_SYSTEM_DEFAULT, 'INPUT':'#F7F3EC','TEXT_INPUT' : 'black','SCROLL': '#F7F3EC', 'BUTTON': ('white', '#475841'), 'PROGRESS':DEFAULT_PROGRESS_BAR_COLOR}, + look_and_feel = {'GreenTan': {'BACKGROUND' : '#9FB8AD', 'TEXT': COLOR_SYSTEM_DEFAULT, 'INPUT':'#F7F3EC','TEXT_INPUT' : 'black','SCROLL': '#F7F3EC', 'BUTTON': ('white', '#475841'), 'PROGRESS':('#9FB8AD','#F7F3EC' )}, 'LightGreen' :{'BACKGROUND' : '#B7CECE', 'TEXT': 'black', 'INPUT':'#FDFFF7','TEXT_INPUT' : 'black', 'SCROLL': '#FDFFF7','BUTTON': ('white', '#658268'), 'PROGRESS':('#247BA0','#F8FAF0')}, diff --git a/SimScript_.py b/SimScript_.py deleted file mode 100644 index 2185935b3..000000000 --- a/SimScript_.py +++ /dev/null @@ -1,4 +0,0 @@ -import time - -for i in range(100): - print(i,'', end='')

*{m&S7}@ zr%Y>#+Q%a!AQv1n5Vvc=%c8;=ql!VyrCU%I`yj0w)RnN%yD3IbMwNfU+e87 zy0|s0pEeHx@cWjIN!YKTm2TXWF%82>3`#xsJ3{Xay{q{NTLub^2!f95*XK*? zT3pO+W6ndPpH9R-Enpw{-OranrBRSdHIIHUPYflYGcilzx1?&N$!}_+3kwS~?bWm< z&TRtph5bVd7ow<*o}Qi_jQJ7|4E5j@u>YzM0I(5l#%?#J)RUorv=6CDqji; zdog}18&*L@ZI7eZ)K2yp5%u-;N74Cuo5(M9bs`QKqH;Oi4n_csKbMw{IyC|Ic1T5N zQ=xhXc-ZGkBcjG54pf%xqd1-~dHUGv{Q2|eKOpw4?i+m+(V({jAURI3xw|WK_m7}Z z(vLrTdlPkC&J6&!6-e^95iXnK7{0PKEJX3s@GeId>&k!_|oX~j-BNXiyeP(XmhKuy#oS8@$Nk=7nl-T zj7-~1qTxz0!iHv*wFY+;Uewy!3L_)s8b`j|Lio21Ux zc+gDi=JN!HXg=tioV9llql`dCy>~-;czL;L+*44A8(MeJmSWVB8-=G!hgL-KVC?Md z7UTCI|FK{Gc>9=wpv9Ucrzg3d$@p6aFG~%NdzJ*J@E*-n1~lB_l^ialk1>HgSBxQk z-feoxRqQy)bl!%N(}ORKwRPx4Xb&q=56KzObM~r^A9TsfSD{?&wgvpj_(5p&{jn6{ zR`NGu46Sbd{#VeZ{bQMu*wIaREP684rC#KS?ropxP71li-|}BJ!&cPOG0Ahzk)xX{ z<6-llwPj%r8Eebp9umX4HA;7vLM?Fx%(&;tgf^rQLEVmwEgj+436VsodH^X6SVFx4 zgkISX*FzD>m{p-dTBVgJ2Fc6^b9;Hp250%uGEO!d@`cXiA#TZ`g!f$`ntW*(^%t|z zMfR6nfAb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;cWy05AIP|i? zFI9-ul&1{tp!5TQ5V zHQZz1k{1l9UxL?R{@M8ZZns#?#&ya4t8UBS^;Em5vGL{3&!0ctLXV7^*?EVMIX@3Gqg{z_8E^i(Jn3=gHIrYcR0j~g6b zv@|V%WV=lWx!=8YA^}r9d<=(w`8u~7GUvSKWN$By(-FyUuA!3bu%0XyLX%@7ei=Tw;on-ZyfY{En;pD#g{UfOA}Zu9-u@4Z$ixf) literal 0 HcmV?d00001 diff --git a/ButtonGraphics/Restart.png b/ButtonGraphics/Restart.png new file mode 100644 index 0000000000000000000000000000000000000000..8f30e7cb62104fd585793cdb22699acffb689f8a GIT binary patch literal 8013 zcmV-TAF|+yP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGf5&!@T5&_cPe*6Fc9^y$vK~#8N&7FO) zmQ}gNA2)`gppby{ZTX8jOD4R$xcV- zbf!E`ozh`SZ2Zd4k|fYjL*hgEP(#?TK~XjVTIjidi}!lH_TqWo{j%8`yk@Sw*0Y}V ztaab_^{lm?kN17|LB)F*Lxv0)aL_>qwGACQv~|#+LE{cR^w5)9TU$?vT}KB883zWz zwqU1mV|#o13p;o2T+!LtxoY#~&F$~J^UnG$Tej?oeeX%UX9S7B7ybJ6>py(>@DU?N zj+_=^oE;*Z8Rf09`-osms@QY99o!m%w1+qgLzKtXty?#*qoZTPu3fv{it^pH4loY5 zAQAL_M<0FkgtoS}Ss})ZC>kH^mv#nvJ5UI3*cDtFqTIKB{rWi@H*Q=KVo`R$a6klU zX=yoV#E21XF%muzyyD=44?Zo558J)>T{IG-JE5|`cR|Iz?f>}4Kc0(G^Yh?uHf-3i z{_VHl-tWU^zY7v0;rLTdIpvy|l0FxkLntc?u9qpF*Q*jG54g6yyi61;iy3Xp&z3D) zc1w($m9?_{f<3M31H{_U64TPjfv<)TGsE#C8wHoVwyRR$c}H2`%hIxX0^8C48zIcE zmM>ragP6{i$6CWW)TiibMIRuhropG4dg=`!#Feo*C=a3sI?p@3TzNtHvH+9jd8d~v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