def destroy(self, hwnd, msg, wparam, lparam): if self.on_quit: self.on_quit(self) nid = (self.hwnd, 0) win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid) win32gui.PostQuitMessage(0) # Terminate the app. # Using the included postgres database? if os.path.exists(os.path.join(settings.FREPPLE_HOME, '..', 'pgsql', 'bin', 'pg_ctl.exe')): # Check if the database is running. If so, stop it. os.environ['PATH'] = os.path.join(settings.FREPPLE_HOME, '..', 'pgsql', 'bin') + os.pathsep + os.environ['PATH'] status = call([ os.path.join(settings.FREPPLE_HOME, '..', 'pgsql', 'bin', 'pg_ctl.exe'), "--pgdata", os.path.join(settings.FREPPLE_LOGDIR, 'database'), "--silent", "status" ], stdin=DEVNULL, stdout=DEVNULL, stderr=DEVNULL, creationflags=CREATE_NO_WINDOW ) if not status: call([ os.path.join(settings.FREPPLE_HOME, '..', 'pgsql', 'bin', 'pg_ctl.exe'), "--pgdata", os.path.join(settings.FREPPLE_LOGDIR, 'database'), "--log", os.path.join(settings.FREPPLE_LOGDIR, 'database', 'server.log'), "-w", # Wait till it's down "stop" ], stdin=DEVNULL, stdout=DEVNULL, stderr=DEVNULL, creationflags=CREATE_NO_WINDOW )
def destroy(self, hwnd, msg, wparam, lparam): # called when closed if self.on_quit: self.on_quit(self) nid = (self.hwnd, 0) win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid) win32gui.PostQuitMessage(0) # Terminate the app.
def destroy(self, hwnd, msg, wparam, lparam): logger.info('on destroy') nid = (self.hwnd, 0) try: win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid) except Exception as e: logger.info('exception while destroy icon. ignored.', exc_info=1) win32gui.PostQuitMessage(0) # Terminate the app. # 注销窗口类 tryTimes = 5 for i in range(tryTimes): try: win32gui.UnregisterClass(self.window_class_name, 0) break except Exception as e: if not hasattr(e, '__getitem__') or e[0] == 1412: # (1412, 'UnregisterClass', '\xc0\xe0\xc8\xd4\xd3\xd0\xb4\xf2\xbf\xaa\xb5\xc4\xb4\xb0\xbf\xda\xa1\xa3') # 类仍有打开的窗口。 # 这个情况一般是因为消息传递和窗口关闭的异步延迟 pass else: logger.info('exception when UnregisterClass, ignored.', exc_info=1) time.sleep(0.1)
def destroy(self, hwnd, msg, wparam, lparam): #if self.on_quit: self.on_quit(self) nid = (self.hwnd, 0) if self.apiServer: self.apiServer.kill() win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid) win32gui.PostQuitMessage(0) # Terminate the app.
def destroy(self, hwnd, msg, wparam, lparam): if self.on_quit: self.on_quit(self) nid = (self.hwnd, 0) try: win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid) except: pass win32gui.PostQuitMessage(0) # Terminate the app.
def destroy(self, hwnd, msg, wparam, lparam): if self.on_quit: self.on_quit(self) nid = (self.hwnd, 0) win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid) win32gui.PostQuitMessage(0) # Terminate the app. # Using the included postgres database? if os.path.exists( os.path.join(settings.FREPPLE_HOME, "..", "pgsql", "bin", "pg_ctl.exe") ): # Check if the database is running. If so, stop it. os.environ["PATH"] = ( os.path.join(settings.FREPPLE_HOME, "..", "pgsql", "bin") + os.pathsep + os.environ["PATH"] ) status = subprocess.call( [ os.path.join( settings.FREPPLE_HOME, "..", "pgsql", "bin", "pg_ctl.exe" ), "--pgdata", os.path.join(settings.FREPPLE_LOGDIR, "database"), "--silent", "status", ], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, creationflags=CREATE_NO_WINDOW, ) if not status: subprocess.call( [ os.path.join( settings.FREPPLE_HOME, "..", "pgsql", "bin", "pg_ctl.exe" ), "--pgdata", os.path.join(settings.FREPPLE_LOGDIR, "database"), "--log", os.path.join(settings.FREPPLE_LOGDIR, "database", "server.log"), "-w", # Wait till it's down "stop", ], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, creationflags=CREATE_NO_WINDOW, )
def window_process(self, hwnd, msg, wparam, lparam): if msg == win32con.WM_PAINT: self.OnPaint(hwnd, msg, wparam, lparam) elif msg == win32con.WM_ERASEBKGND: return True elif msg == win32con.WM_KEYDOWN: self.OnKeyDown(hwnd, msg, wparam, lparam) elif msg == win32con.WM_KEYUP: self.OnKeyUp(hwnd, msg, wparam, lparam) elif msg == win32con.WM_DESTROY: win32gui.DestroyWindow(hwnd) elif msg == win32con.WM_CLOSE: win32gui.PostQuitMessage(0) elif msg == win32con.WM_ENDSESSION: win32gui.PostQuitMessage(0) else: return win32gui.DefWindowProc(hwnd, msg, wparam, lparam)
def on_destroy(self, hwnd, msg, wparam, lparam): if callable(self.on_quit): self.on_quit() nid = (self.hwnd, 0) win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid) win32gui.PostQuitMessage(0) # Terminate the app.
def quit(self, *args): win32gui.DestroyWindow(self.hwnd) win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, (self.hwnd, 0)) win32gui.PostQuitMessage(0)
def OnKeyDown(self, hwnd, msg, wparam, lparam): if self._first_keydown: # only update once, ignore keyboard autorepeat self._first_keydown = False self._display_string = "" if wparam == win32con.VK_UP: self._pixels[self._selected_pixel][0] -= self._increment elif wparam == win32con.VK_DOWN: self._pixels[self._selected_pixel][0] += self._increment elif wparam == win32con.VK_LEFT: self._pixels[self._selected_pixel][1] -= self._increment elif wparam == win32con.VK_RIGHT: self._pixels[self._selected_pixel][1] += self._increment elif wparam == VK_1: self._selected_pixel = 0 self._display_string = "Pixel " + str(self._selected_pixel + 1) elif wparam == VK_2: self._selected_pixel = 1 self._display_string = "Pixel " + str(self._selected_pixel + 1) elif wparam == VK_3: self._selected_pixel = 2 self._display_string = "Pixel " + str(self._selected_pixel + 1) elif wparam == VK_4: self._selected_pixel = 3 self._display_string = "Pixel " + str(self._selected_pixel + 1) elif wparam == VK_5: self._selected_pixel = 4 self._display_string = "Pixel " + str(self._selected_pixel + 1) elif wparam == VK_6: self._selected_pixel = 5 self._display_string = "Pixel " + str(self._selected_pixel + 1) elif wparam == VK_7: self._selected_pixel = 6 self._display_string = "Pixel " + str(self._selected_pixel + 1) elif wparam == VK_8: self._selected_pixel = 7 self._display_string = "Pixel " + str(self._selected_pixel + 1) elif wparam == VK_9: self._selected_pixel = 8 self._display_string = "Pixel " + str(self._selected_pixel + 1) elif wparam == win32con.VK_CONTROL: self._display_string = "increment = %d" % self._increment elif wparam == win32con.VK_SHIFT: self._display_string = "Pixel " + str(self._selected_pixel + 1) elif wparam == VK_F: if self._fullscreen: self.exitFullscreen() else: self.enterFullscreen() elif wparam == VK_N: if self._selected_pixel == len(self._pixels) - 1: self._selected_pixel = 0 else: self._selected_pixel += 1 self._display_string = "Pixel " + str(self._selected_pixel + 1) elif wparam == VK_O: # read parameters and pixels from a file self.openParameterFile(hwnd) # redraw the screen using the new pixels win32gui.RedrawWindow( hwnd, None, None, win32con.RDW_INVALIDATE | win32con.RDW_INTERNALPAINT) elif wparam == VK_P: if self._selected_pixel == 0: self._selected_pixel = len(self._pixels) - 1 else: self._selected_pixel -= 1 self._display_string = "Pixel " + str(self._selected_pixel + 1) elif wparam == VK_Q: win32gui.PostQuitMessage(0) elif wparam == VK_S: self.saveParameterFile(hwnd) elif wparam == VK_ESCAPE: self.exitFullscreen() elif wparam == VK_OEM_PLUS: self._increment = 10 self._display_string = "increment = %d" % self._increment elif wparam == VK_OEM_MINUS: self._increment = 1 self._display_string = "increment = %d" % self._increment else: self._show_help = True dc = win32gui.GetDC(hwnd) brush = win32gui.CreateSolidBrush(BLACK) win32gui.SelectObject(dc, brush) win32gui.SetTextColor(dc, WHITE) win32gui.SetBkColor(dc, BLACK) debug = win32gui.DrawText( dc, self._display_string, len(self._display_string), self._onscreen_display, win32con.DT_SINGLELINE | win32con.DT_CENTER | win32con.DT_VCENTER) win32gui.ReleaseDC(hwnd, dc)
def close(self): win32gui.PostQuitMessage(0)
def quit(self): win32gui.PostQuitMessage(0)
def destory(sysTrayIcon): nid = (sysTrayIcon.hwnd, 0) win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid) win32gui.PostQuitMessage(0) # Terminate the app.
def destroy(self, hwnd, msg, wparam, lparam): if self.on_quit: self.on_quit(self) nid = (self.hwnd, 0) win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid) win32gui.PostQuitMessage(0)
def destroy(self): if self.on_quit: self.on_quit() nid = (self.hwnd, 0) win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid) win32gui.PostQuitMessage(0) # Terminate the app.
def OnDestroy(self, hwnd, msg, wparam, lparam): nid = (self.main_frame.hwnd, 0) win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid) win32gui.PostQuitMessage(0) # Terminate the app.
def _on_destroy(self, hwnd, msg, wparam, lparam): win32gui.PostQuitMessage(0)
def _on_close(self, hwnd, msg, wparam, lparam): win32gui.PostQuitMessage(0)
def on_destroy(self, hwnd, msg, wparam, lparam): if not self._dialog_modal: win32gui.PostQuitMessage(0)
def destroy(self, hwnd, msg, wparam, lparam,kill_program=True): nid = (self.hwnd, 0) win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, nid) win32gui.PostQuitMessage(0) # Terminate the app. if self.on_quit and kill_program: self.on_quit()
def destroy(self, hwnd, msg, wparam, lparam): if self.on_quit: self.on_quit(self) self.notify_icon.hide() win32gui.PostQuitMessage(0) # Terminate the app.