Merge pull request #1045 from PySimpleGUI/Dev-latest

Borderless window, Title for grabanywhere windows, Mouse events
This commit is contained in:
MikeTheWatchGuy 2019-01-06 16:03:53 -05:00 committed by GitHub
commit 6729f0eb5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 40 deletions

View File

@ -1144,10 +1144,6 @@ class MultilineOutput(Element):
super().__del__() super().__del__()
# ---------------------------------------------------------------------- # # ---------------------------------------------------------------------- #
# Text # # Text #
# ---------------------------------------------------------------------- # # ---------------------------------------------------------------------- #
@ -1303,6 +1299,7 @@ class Output(Element):
bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR 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 fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR
self.WxTextControl = None self.WxTextControl = None
self.redir = None
tsize = convert_tkinter_size_to_Wx(size) if size[0] is not None and size[0] < 100 else size tsize = convert_tkinter_size_to_Wx(size) if size[0] is not None and size[0] < 100 else size
@ -1317,14 +1314,16 @@ class Output(Element):
self.out.AppendText(string) self.out.AppendText(string)
def reroute_stdout(self): def reroute_stdout(self):
self.redir = self.RedirectText(self.WxTextControl)
print('Redirecting', self.WxTextControl)
self.my_stdout = sys.stdout self.my_stdout = sys.stdout
self.my_stderr = sys.stderr self.my_stderr = sys.stderr
self.redir = self.RedirectText(self.WxTextControl)
print('Redirecting', self.WxTextControl)
sys.stdout = self.redir sys.stdout = self.redir
# sys.stderr = self.WxTextControl sys.stderr = self.redir
print('REDIRECT complete')
print('REDIRECT complete')
#
# def write(self, m): # def write(self, m):
# # print('in the ') # # print('in the ')
# if m is not None: # if m is not None:
@ -1338,6 +1337,7 @@ class Output(Element):
def __del__(self): def __del__(self):
print('Deleting Output Element')
sys.stdout = self.my_stdout sys.stdout = self.my_stdout
sys.stderr = self.my_stderr sys.stderr = self.my_stderr
super().__del__() super().__del__()
@ -2889,8 +2889,8 @@ class SystemTray:
class DragFrame(wx.Frame): class DragFrame(wx.Frame):
def __init__(self): def __init__(self, title=''):
wx.Frame.__init__(self, None) wx.Frame.__init__(self, None, title=title)
def on_mouse(self, event): def on_mouse(self, event):
''' '''
@ -3167,7 +3167,8 @@ class Window:
BuildResults(self, False, self) BuildResults(self, False, self)
if self.CurrentlyRunningMainloop: # quit if this is the current mainloop, otherwise don't quit! if self.CurrentlyRunningMainloop: # quit if this is the current mainloop, otherwise don't quit!
self.App.ExitMainLoop() # kick the users out of the mainloop self.App.ExitMainLoop() # kick the users out of the mainloop
event.DoAllowNextEvent() if event.ClassName != 'wxMouseEvent':
event.DoAllowNextEvent()
def Read(self, timeout=None, timeout_key=TIMEOUT_KEY): def Read(self, timeout=None, timeout_key=TIMEOUT_KEY):
if timeout == 0: # timeout of zero runs the old readnonblocking if timeout == 0: # timeout of zero runs the old readnonblocking
@ -4363,7 +4364,6 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
# *********** ------- Loop through ELEMENTS ------- ***********# # *********** ------- Loop through ELEMENTS ------- ***********#
# *********** Make TK Row ***********# # *********** Make TK Row ***********#
hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer = wx.BoxSizer(wx.HORIZONTAL)
tk_row_frame = 00000 # TODO Get horizontal ROW widget to put others into
for col_num, element in enumerate(flex_row): for col_num, element in enumerate(flex_row):
element.ParentForm = toplevel_form # save the button's parent form object element.ParentForm = toplevel_form # save the button's parent form object
if toplevel_form.Font and (element.Font == DEFAULT_FONT or not element.Font): if toplevel_form.Font and (element.Font == DEFAULT_FONT or not element.Font):
@ -5330,7 +5330,7 @@ def StartupTK(window:Window):
app = Window.highest_level_app app = Window.highest_level_app
# -------- grab anywhere -------- # -------- grab anywhere --------
if window.GrabAnywhere: if window.GrabAnywhere:
frame = DragFrame() frame = DragFrame(title=window.Title)
else: else:
frame = wx.Frame(None, title=window.Title) frame = wx.Frame(None, title=window.Title)
@ -5364,23 +5364,23 @@ def StartupTK(window:Window):
InitializeResults(window) InitializeResults(window)
# ----------------------------- handle settings using Style Flags ----------------------------- # ----------------------------- handle settings using Style Flags -----------------------------
style = window.MasterFrame.GetWindowStyle() style = 0
if window.NoTitleBar: if window.NoTitleBar:
style |= wx.NO_BORDER style |= wx.BORDER_NONE
if window.KeepOnTop: if window.KeepOnTop:
style |= wx.STAY_ON_TOP style |= wx.STAY_ON_TOP
if window.ReturnKeyboardEvents: if window.ReturnKeyboardEvents:
style |= wx.WANTS_CHARS style |= wx.WANTS_CHARS
window.App.Bind(wx.EVT_CHAR_HOOK, window.callback_keyboard_char) # would be nice if it were key-UP window.App.Bind(wx.EVT_CHAR_HOOK, window.callback_keyboard_char) # would be nice if it were key-UP
window.App.Bind(wx.EVT_MOUSEWHEEL, window.callback_keyboard_char) # would be nice if it were key-UP window.App.Bind(wx.EVT_MOUSEWHEEL, window.callback_keyboard_char) # would be nice if it were key-UP
if style: if style:
window.MasterFrame.SetWindowStyleFlag(style) window.MasterFrame.SetWindowStyleFlag(style)
# ----------------------------- Sizer creation and PACK FORM -----------------------------
vsizer = wx.BoxSizer(wx.VERTICAL) vsizer = wx.BoxSizer(wx.VERTICAL)
PackFormIntoFrame(window, vsizer, window) PackFormIntoFrame(window, vsizer, window)
# ----------------------------- Sizers to create margins -----------------------------
outersizer = wx.BoxSizer(wx.VERTICAL) outersizer = wx.BoxSizer(wx.VERTICAL)
outersizer.Fit(window.MasterFrame) outersizer.Fit(window.MasterFrame)
outersizer.Add(vsizer, 1, wx.TOP|wx.BOTTOM|wx.EXPAND, border=DEFAULT_MARGINS[1]) outersizer.Add(vsizer, 1, wx.TOP|wx.BOTTOM|wx.EXPAND, border=DEFAULT_MARGINS[1])
@ -5393,6 +5393,7 @@ def StartupTK(window:Window):
window.OuterSizer.Fit(window.MasterFrame) window.OuterSizer.Fit(window.MasterFrame)
# ----------------------------- window location, size and alpha -----------------------------
if window.Location != (None, None): if window.Location != (None, None):
window.MasterFrame.Move(window.Location[0], window.Location[1]) window.MasterFrame.Move(window.Location[0], window.Location[1])
else: else:
@ -5404,11 +5405,11 @@ def StartupTK(window:Window):
if window._AlphaChannel is not None: if window._AlphaChannel is not None:
window.SetAlpha(window._AlphaChannel) window.SetAlpha(window._AlphaChannel)
# ----------------------------- DISPLAY the window -----------------------------
window.MasterFrame.Show() window.MasterFrame.Show()
# ....................................... DONE creating and laying out window ..........................# # ....................................... DONE creating and laying out window ..........................#
if RUN_INSPECTION_TOOL: if RUN_INSPECTION_TOOL:
wx.lib.inspection.InspectionTool().Show() wx.lib.inspection.InspectionTool().Show()
window.CurrentlyRunningMainloop = True window.CurrentlyRunningMainloop = True
@ -5437,27 +5438,6 @@ def StartupTK(window:Window):
if timer: if timer:
timer.Stop() timer.Stop()
# root.attributes('-alpha', window.AlphaChannel) # Make window visible again
# if window.AutoClose:
# duration = DEFAULT_AUTOCLOSE_TIME if window.AutoCloseDuration is None else window.AutoCloseDuration
# window.TKAfterID = root.after(duration * 1000, window._AutoCloseAlarmCallback)
#
# if window.Timeout != None:
# window.TKAfterID = root.after(window.Timeout, window._TimeoutAlarmCallback)
# if window.NonBlocking:
# window.TKroot.protocol("WM_DESTROY_WINDOW", window.OnClosingCallback)
# window.TKroot.protocol("WM_DELETE_WINDOW", window.OnClosingCallback)
# else: # it's a blocking form
# print('..... CALLING MainLoop')
# window.CurrentlyRunningMainloop = True
# window.TKroot.protocol("WM_DESTROY_WINDOW", window.OnClosingCallback)
# window.TKroot.protocol("WM_DELETE_WINDOW", window.OnClosingCallback)
# window.TKroot.mainloop()
# window.CurrentlyRunningMainloop = False
# window.TimerCancelled = True
# print('..... BACK from MainLoop')
# if not window.FormRemainedOpen: # if not window.FormRemainedOpen:
# _my_windows.Decrement() # _my_windows.Decrement()
# if window.RootNeedsDestroying: # if window.RootNeedsDestroying: