Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def run_standalone(self):
from mayavi.core.engine import Engine
from mayavi.plugins.script import Script
from pyface.api import ApplicationWindow, GUI
self.setup_logger()
if self.offscreen:
engine = Engine(scene_factory=off_screen_viewer)
else:
engine = Engine()
engine.start()
self.exception_info = None
self.script = Script(engine=engine)
self.gui = g = GUI()
self.app_window = a = ApplicationWindow()
a.open()
a.show(False)
g.invoke_later(self.run)
g.start_event_loop()
if self.exception_info is not None:
type, value, tb = self.exception_info
if sys.version_info[0] > 2:
raise type(value).with_traceback(tb)
else:
raise type(value)
def wrapper(*args, **kw):
"""Wrapper function to run given function inside the GUI event
loop.
"""
global _gui, _stop_show
tk = ETSConfig.toolkit
if is_ui_running():
# In this case we should not pop up the UI since we likely
# don't want to stop the mainloop.
return func(*args, **kw)
else:
g = GUI()
if tk == 'wx':
# Create a dummy app so invoke later works on wx.
a = ApplicationWindow(size=(1, 1))
GUI.invoke_later(lambda: a.close())
a.open()
GUI.invoke_later(func, *args, **kw)
_gui = g
if stop:
# Pop up the UI to stop the mainloop.
_stop_show = StopShow()
g.start_event_loop()
def draw(self):
try:
#if self.figure.canvas is not None:
GUI.invoke_later(self.figure.canvas.draw)
except:
pass
def _loaded_changed(self, value):
if value:
n = self.dname
if ' [Active]' not in n:
self.dname = "%s [Loaded]" % n
if not self.window is None:
#from pyface.timer.api import do_later
from pyface.api import GUI
GUI.invoke_later(self.window.status_bar_manager.set, message = '')
else:
self.dname = self.dname.replace(' [Loaded]', '')
# ------------------------------------------------------------------------
# Trait event handlers -------------------------------------------------
def _on_tree_anytrait_changed(self, tree, trait_name, old, new):
""" Called when any trait on the tree has changed. """
print("trait", trait_name, "value", new)
return
# Application entry point.
if __name__ == "__main__":
# Create the GUI (this does NOT start the GUI event loop).
gui = GUI()
# Create and open the main window.
window = MainWindow()
window.open()
# Start the GUI event loop.
gui.start_event_loop()
def __call__(self, fname):
""" Pops up the dialogs required for the import of the
CSV to happen.
"""
self.csv_loader = CSVLoader(filename=fname)
self.csv_loader.guess_defaults()
controller = CallbackCSVLoader(model=self.csv_loader,
callback=self.csv_loaded_callback)
controller.edit_traits()
if __name__ == '__main__':
from pyface.api import GUI
source_factory = CSVSourceFactory()
source_factory('mydata.csv')
GUI().start_event_loop()
# mpl.rcParams['backend.qt4']='PySide'
from little_helpers import find_data_file, find_possible_sums, find_grid_connections
from bisect import bisect
# mpl.rc('font',**{'size': 22, 'family':'serif','serif':['Palatino']})
# mpl.rc('text', usetex=True)
mpl.rc('font', **{'size': 22})
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar
import matplotlib.pyplot as plt
import random
_gui = GUI()
bohr = 0.52917721
from abinit_handler import hartree
cov_radii = np.loadtxt(find_data_file('/data/cov_radii.dat')) / bohr
colors = {1: (0.8, 0.8, 0.8), 3: (0, 0.75, 0.75), 11: (0, 0.75, 0.75), 19: (0, 0.75, 0.75), 37: (0, 0.75, 0.75),
5: (0.78, 0.329, 0.1176), 7: (0, 0, 1),
6: (0.25, .25, .25), 8: (1, 0, 0), 9: (0, 1, 0), 17: (0, 1, 0), 35: (0, 1, 0), 16: (1, 1, 0),
13: (0.68, 0.229, 0.1176), 31: (0.58, 0.15, 0.07), 15: (0, 0, 0.8), 33: (48 / 255, 139 / 255, 229 / 255)}
for i in range(21, 31):
colors[i] = (0, 1, 1)
for i in range(39, 49):
colors[i] = (0, 1, 1)
super(MainWindow, self).__init__(**traits)
# Add a menu bar.
self.menu_bar_manager = MenuBarManager(
MenuManager(
Action(name="E&xit", on_perform=self.close),
Action(name="DoIt", on_perform=_main),
name="&File",
)
)
return
if __name__ == "__main__":
gui = GUI()
# Create and open the main window.
window = MainWindow()
window.open()
_main()
# Start the GUI event loop!
gui.start_event_loop()
def _pos_llh_callback(self, data):
# Updating an ArrayPlotData isn't thread safe (see chaco issue #9), so
# actually perform the update in the UI thread.
if self.running:
GUI.invoke_later(self.pos_llh_callback, data)
ToolBarManager(Action(name="Baz"), orientation="vertical"),
location="left",
)
self.add_tool_bar(
ToolBarManager(Action(name="Buz"), orientation="vertical"),
location="right",
)
return
# Application entry point.
if __name__ == "__main__":
# Create the GUI (this does NOT start the GUI event loop).
gui = GUI()
# Create and open the main window.
window = MainWindow()
window.open()
# Start the GUI event loop.
gui.start_event_loop()