Here are the examples of the python api win32gui.ShowWindow taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
14 Examples
4
Example 1
def activate_window(pid):
handles = get_hwnds_for_pid(pid)
if len(handles) > 0:
wnd_handle = handles[0]
win32gui.ShowWindow(wnd_handle, SW_SHOWNORMAL)
win32gui.SetForegroundWindow(wnd_handle)
return True
return False
3
Example 2
Project: pywebview Source File: win32.py
def show(self):
# Show main window
win32gui.ShowWindow(self.hwnd, win32con.SW_SHOWNORMAL)
win32gui.UpdateWindow(self.hwnd)
# Show AtlAx window
win32gui.ShowWindow(self.atlhwnd, win32con.SW_SHOW)
win32gui.UpdateWindow(self.atlhwnd)
win32gui.SetFocus(self.atlhwnd)
# Load URL here instead in CreateWindow to prevent a dead-lock
if self.url:
self.browser.Navigate2(self.url)
# Start sending and receiving messages
win32gui.PumpMessages()
3
Example 3
def show(self):
"""
Puts the window under a shownormal state
Returns true on succes
Returns false on error
"""
try:
win32gui.ShowWindow(self.hWindow, SW_SHOWNORMAL)
return True
except win32gui.error:
logging.exception("Error while showing window")
return False
3
Example 4
def hide(self):
"""
Puts the window under a hidden state
Returns true on succes
Returns false on error
"""
try:
win32gui.ShowWindow(self.hWindow, SW_HIDE)
return True
except win32gui.error:
logging.exception("Error while hiding window")
return False
3
Example 5
def is_visible(self):
try:
return win32gui.ShowWindow(self.hWindow, SW_SHOWNORMAL)
except win32gui.error:
logging.exception("Error while checking visibility")
3
Example 6
def toggle_visibility(self):
"""
Toggles visibility depending on the current state
which is fetched from the return of a first ShowWindow
(doesn't work with getwindowplacement for some reason)
"""
try:
if self.is_visible():
win32gui.ShowWindow(self.hWindow, SW_HIDE)
except win32gui.error:
logging.exception("Error while toggling visibility")
3
Example 7
Project: eavatar-me Source File: console.py
def show(self):
# print("show")
if self.hwnd:
win32gui.ShowWindow(self.hwnd, win32con.SW_NORMAL)
self.hidden = False
self.clear_script()
3
Example 8
Project: eavatar-me Source File: notice_dlg.py
def show(self):
# print("show")
if self.hwnd:
win32gui.ShowWindow(self.hwnd, win32con.SW_NORMAL)
self.hidden = False
self._clear_script()
0
Example 9
Project: dragonfly Source File: window.py
def _win32gui_show_window(state):
return lambda self: win32gui.ShowWindow(self._handle, state)
0
Example 10
def hide():
import win32console,win32gui
window = win32console.GetConsoleWindow()
win32gui.ShowWindow(window,0)
return True
0
Example 11
Project: eavatar-me Source File: console.py
def hide(self):
print("hide")
win32gui.ShowWindow(self.hwnd, win32con.SW_HIDE)
self.hidden = True
0
Example 12
Project: eavatar-me Source File: shell.py
def show(self):
win32gui.ShowWindow(self.hwnd, win32con.SW_NORMAL)
0
Example 13
Project: gns3-gui Source File: main.py
def main():
"""
Entry point for GNS3 GUI.
"""
# Sometimes (for example at first launch) the OSX app service launcher add
# an extra argument starting with -psn_. We filter it
if sys.platform.startswith("darwin"):
sys.argv = [a for a in sys.argv if not a.startswith("-psn_")]
parser = argparse.ArgumentParser()
parser.add_argument("project", help="load a GNS3 project (.gns3)", metavar="path", nargs="?")
parser.add_argument("--version", help="show the version", action="version", version=__version__)
parser.add_argument("--debug", help="print out debug messages", action="store_true", default=False)
parser.add_argument("--config", help="Configuration file")
options = parser.parse_args()
exception_file_path = "exceptions.log"
if options.config:
LocalConfig.instance(config_file=options.config)
else:
LocalConfig.instance()
if options.project:
options.project = os.path.abspath(options.project)
if hasattr(sys, "frozen"):
# We add to the path where the OS search executable our binary location starting by GNS3
# packaged binary
frozen_dir = os.path.dirname(os.path.abspath(sys.executable))
if sys.platform.startswith("darwin"):
frozen_dirs = [
frozen_dir,
os.path.normpath(os.path.join(frozen_dir, '..', 'Resources'))
]
elif sys.platform.startswith("win"):
frozen_dirs = [
frozen_dir,
os.path.normpath(os.path.join(frozen_dir, 'dynamips')),
os.path.normpath(os.path.join(frozen_dir, 'vpcs'))
]
os.environ["PATH"] = os.pathsep.join(frozen_dirs) + os.pathsep + os.environ.get("PATH", "")
if options.project:
os.chdir(frozen_dir)
def exceptionHook(exception, value, tb):
if exception == KeyboardInterrupt:
sys.exit(0)
lines = traceback.format_exception(exception, value, tb)
print("cuem** Exception detected, traceback information saved in {} ******".format(exception_file_path))
print("\nPLEASE REPORT ON https://www.gns3.com\n")
print("".join(lines))
try:
curdate = time.strftime("%d %b %Y %H:%M:%S")
logfile = open(exception_file_path, "a", encoding="utf-8")
logfile.write("=== GNS3 {} traceback on {} ===\n".format(__version__, curdate))
logfile.write("".join(lines))
logfile.close()
except OSError as e:
print("Could not save traceback to {}: {}".format(os.path.normpath(exception_file_path), e))
if not sys.stdout.isatty():
# if stdout is not a tty (redirected to the console view),
# then print the exception on stderr too.
print("".join(lines), file=sys.stderr)
if exception is MemoryError:
print("YOUR SYSTEM IS OUT OF MEMORY!")
else:
CrashReport.instance().captureException(exception, value, tb)
# catch exceptions to write them in a file
sys.excepthook = exceptionHook
current_year = datetime.date.today().year
print("GNS3 GUI version {}".format(__version__))
print("Copyright (c) 2007-{} GNS3 Technologies Inc.".format(current_year))
# we only support Python 3 version >= 3.4
if sys.version_info < (3, 4):
raise SystemExit("Python 3.4 or higher is required")
if parse_version(QtCore.QT_VERSION_STR) < parse_version("5.0.0"):
raise SystemExit("Requirement is PyQt5 version 5.0.0 or higher, got version {}".format(QtCore.QT_VERSION_STR))
if parse_version(psutil.__version__) < parse_version("2.2.1"):
raise SystemExit("Requirement is psutil version 2.2.1 or higher, got version {}".format(psutil.__version__))
# check for the correct locale
# (UNIX/Linux only)
locale_check()
try:
os.getcwd()
except FileNotFoundError:
log.critical("the current working directory doesn't exist")
return
# always use the INI format on Windows and OSX (because we don't like the registry and plist files)
if sys.platform.startswith('win') or sys.platform.startswith('darwin'):
QtCore.QSettings.setDefaultFormat(QtCore.QSettings.IniFormat)
if sys.platform.startswith('win') and hasattr(sys, "frozen"):
try:
import win32console
import win32con
import win32gui
except ImportError:
raise SystemExit("Python for Windows extensions must be installed.")
if not options.debug:
try:
# hide the console
console_window = win32console.GetConsoleWindow()
win32gui.ShowWindow(console_window, win32con.SW_HIDE)
except win32console.error as e:
print("warning: could not allocate console: {}".format(e))
global app
app = Application(sys.argv)
# save client logging info to a file
logfile = os.path.join(LocalConfig.configDirectory(), "gns3_gui.log")
# on debug enable logging to stdout
if options.debug:
root_logger = init_logger(logging.DEBUG, logfile)
else:
root_logger = init_logger(logging.INFO, logfile)
# update the exception file path to have it in the same directory as the settings file.
exception_file_path = os.path.join(LocalConfig.configDirectory(), exception_file_path)
global mainwindow
mainwindow = MainWindow()
# On OSX we can receive the file to open from a system event
# loadPath is smart and will load only if a path is present
mainwindow.ready_signal.connect(lambda: mainwindow.loadPath(app.open_file_at_startup))
mainwindow.ready_signal.connect(lambda: mainwindow.loadPath(options.project))
app.file_open_signal.connect(lambda path: mainwindow.loadPath(path))
# Manage Ctrl + C or kill command
def sigint_handler(*args):
log.info("Signal received exiting the application")
mainwindow.setSoftExit(False)
app.closeAllWindows()
orig_sigint = signal.signal(signal.SIGINT, sigint_handler)
orig_sigterm = signal.signal(signal.SIGTERM, sigint_handler)
mainwindow.show()
exit_code = app.exec_()
signal.signal(signal.SIGINT, orig_sigint)
signal.signal(signal.SIGTERM, orig_sigterm)
delattr(MainWindow, "_instance")
# We force deleting the app object otherwise it's segfault on Fedora
del app
# We force a full garbage collect before exit
# for unknow reason otherwise Qt Segfault on OSX in some
# conditions
import gc
gc.collect()
sys.exit(exit_code)
0
Example 14
Project: socorro Source File: async_processor.py
def Init(self):
win32gui.ShowWindow(self.GetControl(self.statusbar_id), win32con.SW_HIDE)
self.SetStatusText("")