Merge pull request #682 from MikeTheWatchGuy/Dev-latest

Grab Anywhere for windows works!
This commit is contained in:
MikeTheWatchGuy 2018-11-09 09:14:48 -05:00 committed by GitHub
commit 4997864236
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 39 additions and 18 deletions

View File

@ -1276,9 +1276,10 @@ class Button(Element):
self.ParentForm.QTApplication.exit() self.ParentForm.QTApplication.exit()
elif self.BType == BUTTON_TYPE_CLOSES_WIN_ONLY: # special kind of button that does not exit main loop elif self.BType == BUTTON_TYPE_CLOSES_WIN_ONLY: # special kind of button that does not exit main loop
self.ParentForm._Close() self.ParentForm._Close()
if self.ParentForm.NonBlocking: # if self.ParentForm.NonBlocking:
pass # TODO destroy window if self.ParentForm.CurrentlyRunningMainloop: # if this window is running the mainloop, kick out
_my_windows.Decrement() self.ParentForm.QTApplication.exit()
_my_windows.Decrement()
elif self.BType == BUTTON_TYPE_CALENDAR_CHOOSER: # this is a return type button so GET RESULTS and destroy window elif self.BType == BUTTON_TYPE_CALENDAR_CHOOSER: # this is a return type button so GET RESULTS and destroy window
should_submit_window = False should_submit_window = False
@ -2853,19 +2854,34 @@ class Window:
def CurrentLocation(self): def CurrentLocation(self):
return int(self.TKroot.winfo_x()), int(self.TKroot.winfo_y()) return int(self.TKroot.winfo_x()), int(self.TKroot.winfo_y())
# @property class QTMainWindow(QWidget):
# def Size(self): def __init__(self,enable_key_events, window):
# win_width = self.TKroot.winfo_width() self.KeyEventsEnabled = enable_key_events
# win_height = self.TKroot.winfo_height() self.Window = window
# return win_width, win_height super().__init__()
#
# @Size.setter def eventFilter(self, widget, event):
# def Size(self, size): # print(event.type())
# try: if event.type() == QEvent.MouseButtonPress and self.Window.GrabAnywhere:
# self.TKroot.geometry("%sx%s" % (size[0], size[1])) self.mouse_offset = event.pos()
# self.TKroot.update_idletasks() if event.type() == QEvent.MouseMove and self.Window.GrabAnywhere:
# except: x = event.globalX()
# pass y = event.globalY()
x_w = self.mouse_offset.x()
y_w = self.mouse_offset.y()
self.move(x - x_w, y - y_w)
if event.type() == QEvent.KeyRelease and self.KeyEventsEnabled:
# print("got key event")
key = event.key()
try:
self.Window.LastButtonClicked = chr(key).lower()
except:
self.Window.LastButtonClicked = "special %s" % key
self.Window.FormRemainedOpen = True
if self.Window.CurrentlyRunningMainloop:
self.Window.QTApplication.exit()
return QWidget.eventFilter(self, widget, event)
def __enter__(self): def __enter__(self):
return self return self
@ -4014,6 +4030,7 @@ def ConvertFlexToTK(window):
screen_width = 000000 # get window info to move to middle of screen screen_width = 000000 # get window info to move to middle of screen
screen_height = 000000 screen_height = 000000
if window.Location != (None, None): if window.Location != (None, None):
window.QTWindow.move(window.Location[0], window.Location[1])
x, y = window.Location x, y = window.Location
elif DEFAULT_WINDOW_LOCATION != (None, None): elif DEFAULT_WINDOW_LOCATION != (None, None):
x, y = DEFAULT_WINDOW_LOCATION x, y = DEFAULT_WINDOW_LOCATION
@ -4027,7 +4044,7 @@ def ConvertFlexToTK(window):
if x + win_width > screen_width: if x + win_width > screen_width:
x = screen_width - win_width x = screen_width - win_width
pass
return return
@ -4050,7 +4067,11 @@ def StartupTK(window):
window.QTApplication = _my_windows.QTApplication window.QTApplication = _my_windows.QTApplication
window.QTWindow = QWidget() # window.QTWindow = QWidget()
window.QTWindow = window.QTMainWindow(window.ReturnKeyboardEvents, window)
window.QTWindow.installEventFilter(window.QTWindow)
window.QTApplication.setActiveWindow(window.QTWindow)
flags = 0 flags = 0
if window.NoTitleBar: if window.NoTitleBar: