def __init__(self, *args, **kwargs): self.app = kwargs.pop('app', None) wx.Frame.__init__(self, *args, **kwargs) # =============== Logging Text Control ================ self.log_ctrl = log_ctrl(self, style=wx.TE_MULTILINE, add_to_file=True) sys.stdout = self.log_ctrl sys.stderr = self.log_ctrl self.log = wx.LogTextCtrl(self.log_ctrl) self.log.SetLogLevel(wx.LOG_Error) #~ wx.Log_SetActiveTarget(self.log) # =============== player Control ================ self.player = player_ctrl(self) # =============== StatusBar ================ statusbar = self.CreateStatusBar(2) statusbar.SetStatusWidths([-1, -1]) statusbar.SetStatusText(_('Welcome into application!'), 0) # =============== AuiManager ================ self.aui_manager = AuiManager() self.aui_manager.SetManagedWindow(self) self.aui_manager.AddPane(self.player, AuiPaneInfo().Name('player').CenterPane()) self.aui_manager.AddPane( self.log_ctrl, AuiPaneInfo().Name('log_ctrl').Bottom().Layer(0).BestSize( (100, 100)).Hide()) if self.log_ctrl.GetValue() != '': self.aui_manager.GetPane('log_ctrl').Show() self.aui_manager.Update()
def setUp(self): settings = FakeSettings() self.app = wx.App() self.frame = wx.Frame(None) self.frame.tree = Tree( self.frame, ActionRegisterer(AuiManager(self.frame), MenuBar(self.frame), ToolBar(self.frame), ShortcutRegistry(self.frame)), settings) self.frame.Show() self._tags_list = utils.NormalizedDict() self._tags_list = { "tag-11": [1, 2], "tag-02": [3], "tag-12": [4, 8, 12], "tag-2": [5, 6, 7], "tag-3": [9], "tag-21": [10, 11, 12], "tag-22": [10], "tag-1": [14], "tag-03": [15], "a-01-a2": [1], "08-b": [2], "3-2-1-tag-2c": [3, 6, 8], "8-B-1": [3, 4, 5], "2-b": [7, 3], "a-1-a3": [8, 9, 10, 11], "3-2-03-tag-2a": [12], "a-01-a03": [1], "b-1-a01": [2], "b-01-a01": [15] } self.model = self._create_model() self._tagsdialog = _ViewAllTagsDialog(self.frame, self.model)
def __init__(self, session): wx.Frame.__init__(self, None, title="ChimeraX", size=(1000,700)) from wx.lib.agw.aui import AuiManager, AuiPaneInfo self.aui_mgr = AuiManager(self) self.aui_mgr.SetManagedWindow(self) from .graphics import GraphicsWindow # View is a base class of Graphics Window self.graphics_window = g = GraphicsWindow(session, self) self.view = g.view self.aui_mgr.AddPane(g, AuiPaneInfo().Name("GL").CenterPane()) session.main_window = self # needed for ToolWindow init from ..tool_api import ToolWindow self._text_window = ToolWindow("Messages", "General", session, destroy_hides=True) from wx.html2 import WebView, EVT_WEBVIEW_NAVIGATING self._text = WebView.New(self._text_window.ui_area, size=(250,500)) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self._text, 1, wx.EXPAND) self._text_window.ui_area.SetSizerAndFit(sizer) self.text_id = None self._text_window.manage("right") self._text_window.shown = False self.Bind(EVT_WEBVIEW_NAVIGATING, self.OnWebViewNavigating, self._text) self._anchor_cb = None self.status_bar = self.CreateStatusBar(3, wx.STB_SIZEGRIP| wx.STB_SHOW_TIPS|wx.STB_ELLIPSIZE_MIDDLE|wx.FULL_REPAINT_ON_RESIZE) self.status_bar.SetStatusWidths([-24, -30, -2]) self.status_bar.SetStatusText("Status", 0) self.status_bar.SetStatusText("Welcome to ChimeraX", 1) self.status_bar.SetStatusText("", 2) self._shortcuts_enabled = False from .cmd_line import CmdLine self._command_line = CmdLine(session) self.Bind(wx.EVT_CLOSE, self.OnClose) self.SetDropTarget(_FileDrop(session))
def setUp(self): frame = _FakeMainFrame(None) self._model = self._create_model() self._tree = Tree( frame, ActionRegisterer(AuiManager(frame), MenuBar(frame), ToolBar(frame), ShortcutRegistry(frame))) images = TreeImageList() self._tree._images = images self._tree.SetImageList(images) self._tree.populate(self._model) self._expand_all()
class MainWindow(wx.Frame): def __init__(self, session): wx.Frame.__init__(self, None, title="ChimeraX", size=(1000,700)) from wx.lib.agw.aui import AuiManager, AuiPaneInfo self.aui_mgr = AuiManager(self) self.aui_mgr.SetManagedWindow(self) from .graphics import GraphicsWindow # View is a base class of Graphics Window self.graphics_window = g = GraphicsWindow(session, self) self.view = g.view self.aui_mgr.AddPane(g, AuiPaneInfo().Name("GL").CenterPane()) session.main_window = self # needed for ToolWindow init from ..tool_api import ToolWindow self._text_window = ToolWindow("Messages", "General", session, destroy_hides=True) from wx.html2 import WebView, EVT_WEBVIEW_NAVIGATING self._text = WebView.New(self._text_window.ui_area, size=(250,500)) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self._text, 1, wx.EXPAND) self._text_window.ui_area.SetSizerAndFit(sizer) self.text_id = None self._text_window.manage("right") self._text_window.shown = False self.Bind(EVT_WEBVIEW_NAVIGATING, self.OnWebViewNavigating, self._text) self._anchor_cb = None self.status_bar = self.CreateStatusBar(3, wx.STB_SIZEGRIP| wx.STB_SHOW_TIPS|wx.STB_ELLIPSIZE_MIDDLE|wx.FULL_REPAINT_ON_RESIZE) self.status_bar.SetStatusWidths([-24, -30, -2]) self.status_bar.SetStatusText("Status", 0) self.status_bar.SetStatusText("Welcome to ChimeraX", 1) self.status_bar.SetStatusText("", 2) self._shortcuts_enabled = False from .cmd_line import CmdLine self._command_line = CmdLine(session) self.Bind(wx.EVT_CLOSE, self.OnClose) self.SetDropTarget(_FileDrop(session)) def OnClose(self, event): self.aui_mgr.UnInit() del self.aui_mgr self.graphics_window.timer = None self.Destroy() def OnWebViewNavigating(self, event): url = event.GetURL() fn = wx.FileSystem.URLToFileName(url) if len(fn) > 1: event.Veto() if self._anchor_cb: self._anchor_cb(fn) def register_html_image_identifier(self, uri, qimage): pass # used by unimplemented Hydra model panel def show(self): self.Show() def show_graphics(self): """implicitly also means "hide log" """ self._text_window.shown = False def show_status(self, text, append=False): if append: text = self.status_bar.GetStatusText(1) + text self.status_bar.SetStatusText(text, 1) def showing_graphics(self): return True def showing_text(self): return self._text_window.shown def show_text(self, text=None, url=None, html=False, id=None, anchor_callback=None, open_links=False, scroll_to_end=False): t = self._text if text is not None: t.SetPage(text, "") elif url is not None: t.LoadPage(url) self._anchor_cb = anchor_callback self.text_id = id self._text_window.shown = True if scroll_to_end: while t.ScrollPages(1): pass