Skip to content

Commit

Permalink
partial fix to #55 --> Prevent blocking app when lib is not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
Srinivas11789 committed Aug 4, 2020
1 parent d0e299a commit 0566135
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
Binary file removed Samples/.DS_Store
Binary file not shown.
26 changes: 17 additions & 9 deletions Source/Module/interactive_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
import matplotlib
matplotlib.use('TkAgg')

interactive_graph_support = False
try:
from cefpython3 import cefpython as cef
interactive_graph_support = True
except:
print("Interactive graph in app wont work as py/platform is not supported")
pass

import memory

# This implementation is a modified version of the example of
Expand All @@ -24,7 +32,6 @@
# entry widget otherwise keyboard focus is lost (Issue #255
# and Issue #284).

from cefpython3 import cefpython as cef
import ctypes
try:
# for Python2
Expand Down Expand Up @@ -68,14 +75,15 @@ def gimmick_initialize(window, map):
formatter = _logging.Formatter("[%(filename)s] %(message)s")
stream_handler.setFormatter(formatter)
logger.addHandler(stream_handler)
logger.info("CEF Python {ver}".format(ver=cef.__version__))
logger.info("Python {ver} {arch}".format(
ver=platform.python_version(), arch=platform.architecture()[0]))
logger.info("Tk {ver}".format(ver=tk.Tcl().eval('info patchlevel')))
assert cef.__version__ >= "55.3", "CEF Python v55.3+ required to run this"
sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error

if not MAC:
if interactive_graph_support:
logger.info("CEF Python {ver}".format(ver=cef.__version__))
logger.info("Python {ver} {arch}".format(
ver=platform.python_version(), arch=platform.architecture()[0]))
logger.info("Tk {ver}".format(ver=tk.Tcl().eval('info patchlevel')))
assert cef.__version__ >= "55.3", "CEF Python v55.3+ required to run this"
sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error

if not MAC and interactive_graph_support:
FourthFrame = ttk.Frame(window, width=500, height=500, padding="10 10 10 10",relief= GROOVE)
FourthFrame.grid(column=50, row=10, sticky=(N, W, E, S), columnspan=200, rowspan=200, padx=5, pady=5)

Expand Down
14 changes: 11 additions & 3 deletions Source/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
import matplotlib
matplotlib.use('TkAgg')

from cefpython3 import cefpython as cef
interactive_graph_support = False
try:
from cefpython3 import cefpython as cef
interactive_graph_support = True
except:
print("Interactive graph in app wont work as py/platform is not supported")
pass

try:
# for Python2
Expand Down Expand Up @@ -37,9 +43,11 @@ def main():
icon = PhotoImage(file=logo_file)
base.tk.call('wm','iconphoto',base._w,icon)
user_interface.pcapXrayGui(base)
cef.Initialize()
if interactive_graph_support:
cef.Initialize()
base.mainloop()
cef.Shutdown()
if interactive_graph_support:
cef.Shutdown()

main()

0 comments on commit 0566135

Please sign in to comment.