def __init__(self): self._ROOT_MIN_SIZE = (600, 408) self.config = coreaux_api.get_interface_configuration('wxgui') confsize = [int(s) for s in self.config['initial_geometry'].split('x')] clarea = wx.Display().GetClientArea() initsize = [ min((confsize[0], clarea.GetWidth())), min((confsize[1], clarea.GetHeight())) ] wx.Frame.__init__(self, None, title='Outspline', size=initsize) self.SetMinSize(self._ROOT_MIN_SIZE) if self.config.get_bool('maximized'): self.Maximize() self.SetIcons( wx.GetApp().artprovider.get_frame_icon_bundle("&outspline")) self.menu = menubar.RootMenu(self) self.SetMenuBar(self.menu) self._init_accelerators() self.mainpanes = MainPanes(self, self.menu) self.close_handler = False self.Bind(wx.EVT_WINDOW_CREATE, self._handle_creation) self.bind_to_close_event(wx.GetApp().exit_app) coreaux_api.bind_to_external_nudge(self._handle_external_nudge)
def __init__(self): self._ROOT_MIN_SIZE = (600, 408) self.config = coreaux_api.get_interface_configuration('wxgui') confsize = [int(s) for s in self.config['initial_geometry'].split('x')] clarea = wx.Display().GetClientArea() initsize = [min((confsize[0], clarea.GetWidth())), min((confsize[1], clarea.GetHeight()))] wx.Frame.__init__(self, None, title='Outspline', size=initsize) self.SetMinSize(self._ROOT_MIN_SIZE) if self.config.get_bool('maximized'): self.Maximize() self.SetIcons(wx.GetApp().artprovider.get_frame_icon_bundle( "&outspline")) self.menu = menubar.RootMenu(self) self.SetMenuBar(self.menu) self._init_accelerators() self.mainpanes = MainPanes(self, self.menu) self.close_handler = False self.Bind(wx.EVT_WINDOW_CREATE, self._handle_creation) self.bind_to_close_event(wx.GetApp().exit_app) coreaux_api.bind_to_external_nudge(self._handle_external_nudge)
def __init__(self, parent, filename): self.filename = filename self.panel = wx.Panel(parent) self.box = wx.BoxSizer(wx.HORIZONTAL) self.panel.SetSizer(self.box) # The tools are not TAB-traversable (bug #335) self.toolbar = wx.ToolBar(self.panel, style=wx.TB_VERTICAL) self.box.Add(self.toolbar, flag=wx.EXPAND) self.logviews = [] config = coreaux_api.get_interface_configuration('wxgui')( "ContextualShortcuts")("LeftNotebook")("Logs") wx.GetApp().root.accmanager.create_manager( self.panel, { config["cycle"]: lambda event: self.advance_selection(), config["cycle_reverse"]: lambda event: self.reverse_selection(), }) # Hide, otherwise the children windows will be shown even if panel is # hidden in the configuration self.panel.Show(False) self.toolbar.Bind(wx.EVT_TOOL, self._handle_tool)
def __init__(self): self.config = coreaux_api.get_interface_configuration('wxgui') wx.App.__init__(self, False) self.artprovider = art.ArtProvider() self.root = MainFrame() self.logs_configuration = logs.LogsConfiguration() self.menu = self.root.menu self.nb_left = self.root.mainpanes.nb_left self.nb_right = self.root.mainpanes.nb_right self.uncaught_max = self.config.get_int('max_exceptions') self.uncaught_counter = 0 self.uncaught_event = threading.Event() core_api.bind_to_blocked_databases(self._handle_blocked_databases) if self.uncaught_max > 0: coreaux_api.bind_to_uncaught_exception( self._handle_uncaught_exception) # Window managers like i3 and awesome need MainFrame to be shown here, # not at the end of its constructor, or EVT_WINDOW_CREATE will be sent # too early (bug #366) self.root.Centre() self.root.Show(True)
def __init__(self, parent, frame, menu): Notebook.__init__(self, parent) self.imagelist = wx.ImageList(16, 16) self.AssignImageList(self.imagelist) self.editors = editor.Editors(self) config = coreaux_api.get_interface_configuration('wxgui')( "ContextualShortcuts")("RightNotebook") self.genaccels = { config["cycle"]: menu.view.rightnb_submenu.ID_CYCLE, config["cycle_reverse"]: menu.view.rightnb_submenu.ID_RCYCLE, config["focus_first"]: menu.view.rightnb_submenu.ID_FOCUS_1, config["focus_last"]: menu.view.rightnb_submenu.ID_FOCUS_LAST, config["close"]: menu.view.rightnb_submenu.ID_CLOSE, } self.accmanager = frame.accmanager.create_manager(self, {}) self.Bind(flatnotebook.EVT_FLATNOTEBOOK_PAGE_CHANGED, self._handle_page_changed) self.Bind(flatnotebook.EVT_FLATNOTEBOOK_PAGE_CLOSING, self._handle_page_closing) self.Bind(flatnotebook.EVT_FLATNOTEBOOK_PAGE_CLOSED, self._handle_page_closed)
def __init__(self, parent, filename): self.filename = filename self.panel = wx.Panel(parent) self.box = wx.BoxSizer(wx.HORIZONTAL) self.panel.SetSizer(self.box) # The tools are not TAB-traversable (bug #335) self.toolbar = wx.ToolBar(self.panel, style=wx.TB_VERTICAL) self.box.Add(self.toolbar, flag=wx.EXPAND) self.logviews = [] config = coreaux_api.get_interface_configuration('wxgui')( "ContextualShortcuts")("LeftNotebook")("Logs") wx.GetApp().root.accmanager.create_manager(self.panel, { config["cycle"]: lambda event: self.advance_selection(), config["cycle_reverse"]: lambda event: self.reverse_selection(), }) # Hide, otherwise the children windows will be shown even if panel is # hidden in the configuration self.panel.Show(False) self.toolbar.Bind(wx.EVT_TOOL, self._handle_tool)
def _init_accelerators(self): config = coreaux_api.get_interface_configuration("wxgui")( "ContextualShortcuts")("LeftNotebook")("Database") self.accelerators.update({ config["expand"]: lambda event: self.expand_focused_item(), config["collapse"]: lambda event: self.collapse_focused_item(), config["select"]: lambda event: self.add_focused_item_to_selection(), config["unselect"]: lambda event: self.remove_focused_item_from_selection(), config["undo"]: lambda event: self.undo(), config["redo"]: lambda event: self.redo(), config["create_sibling"]: lambda event: self.create_sibling(), config["create_child"]: lambda event: self.create_child(), config["move_up"]: lambda event: self.move_item_up(), config["move_down"]: lambda event: self.move_item_down(), config["move_to_parent"]: lambda event: self.move_item_to_parent(), config["edit"]: lambda event: self.edit_item(), config["delete"]: lambda event: self.delete_selected_items(), }) wx.GetApp().root.accmanager.create_manager(self.treec, self.accelerators)
def __init__(self): config = coreaux_api.get_interface_configuration('wxgui') # Use a copy of the original constant, so that every time a database is # opened it reads the current value, and not the one stored in the # configuration # Do not put this into the DatabaseHistory class, since it must be a # database-independent value self.show_status = config.get_bool('show_logs')
def __init__(self, tree, logspanel, parent, filename, bgcolor): self.tree = tree self.logspanel = logspanel self.filename = filename self.config = coreaux_api.get_interface_configuration('wxgui') statusflags = 0 if self.config('History').get_bool('debug') else \ wx.dataview.DATAVIEW_COL_HIDDEN self.view = wx.dataview.DataViewCtrl(parent, style=wx.dataview.DV_SINGLE | wx.dataview.DV_ROW_LINES | wx.dataview.DV_NO_HEADER) self.data = [] self.dvmodel = DatabaseHistoryModel(self.data) self.view.AssociateModel(self.dvmodel) # According to DataViewModel's documentation (as of September 2014) # its reference count must be decreased explicitly to avoid memory # leaks; the wxPython demo, however, doesn't do it, and if done here, # the application crashes with a segfault when closing all databases # See also bug #104 #self.dvmodel.DecRef() self.view.AppendBitmapColumn('Icon', 0, width=wx.COL_WIDTH_AUTOSIZE) self.view.AppendTextColumn('Status', 1, width=wx.COL_WIDTH_AUTOSIZE, flags=statusflags) self.view.AppendTextColumn('Timestamp', 2, width=wx.COL_WIDTH_AUTOSIZE) self.view.AppendTextColumn('Description', 3) self._make_icons(bgcolor) aconfig = self.config("ContextualShortcuts")("LeftNotebook")("Logs")( "History") wx.GetApp().root.accmanager.create_manager( self.view, { aconfig["undo"]: lambda event: self.tree.undo(), aconfig["redo"]: lambda event: self.tree.redo(), }) self.tool_id, menu_items, popup_cmenu = self.logspanel.add_log( self.view, "Items", wx.GetApp().artprovider.get_log_icon('@edit'), self._init_context_menu_items(), self._update_context_menu) self._store_context_menu_items(menu_items) self.view.Bind(wx.dataview.EVT_DATAVIEW_ITEM_CONTEXT_MENU, popup_cmenu) self.view.Bind(wx.dataview.EVT_DATAVIEW_SELECTION_CHANGED, self._handle_selection) self.refresh()
def __init__(self, properties): config = coreaux_api.get_interface_configuration('wxgui')('TreeIcons') multichar = config['symbol'] if multichar != '': bits_to_color = { 1: wx.Colour(), } bits_to_color[1].SetFromString(config['color']) self.multiline_shift, self.multiline_mask = properties.add(1, multichar, bits_to_color)
def __init__(self, filename, id_, item, text): self.filename = filename self.id_ = id_ self.item = item self.original = text self.mtimer = None self.tmrunning = False config = coreaux_api.get_interface_configuration('wxgui') self.DELAY = config.get_int('text_min_upd_time') # Do not set the text now, otherwise for example URLs won't be # highlighted in blue # wx.TE_PROCESS_TAB seems to have no effect... self.area = TextUrlCtrl(editor.tabs[item].panel, value='', style=wx.TE_MULTILINE | wx.TE_DONTWRAP | wx.TE_NOHIDESEL) font = self.area.GetFont() font = wx.Font(font.GetPointSize(), wx.FONTFAMILY_TELETYPE, font.GetStyle(), font.GetWeight(), font.GetUnderlined()) self.area.SetFont(font) # Set the text after setting the font, so for example URLs will be # correctly highlighted in blue self.area.SetValue(text) wx.GetApp().root.accmanager.register_text_ctrl(self.area) self.textctrl_nav_keys = { # The Ctrl+Enter in the menu isn't processed when the TextCtrl is # focused; wx.TE_PROCESS_ENTER seems to have no effect either... wx.WXK_RETURN: self._handle_enter_on_textctrl, wx.WXK_ESCAPE: self._navigate_textctrl_backward, } # wx.TE_PROCESS_TAB seems to have no effect... if not config.get_bool('text_process_tab'): # Note that this natively still lets Ctrl+(Shift+)Tab navigate as # expected self.textctrl_nav_keys[wx.WXK_TAB] = self._handle_tab_on_textctrl self.area.Bind(wx.EVT_KEY_DOWN, self._handle_key_down) self.area.Bind(wx.EVT_TEXT, self._handle_text) editor.apply_editor_event.bind(self._handle_apply) editor.check_modified_state_event.bind( self._handle_check_editor_modified) editor.close_editor_event.bind(self._handle_close)
def __init__(self, tree, logspanel, parent, filename, bgcolor): self.tree = tree self.logspanel = logspanel self.filename = filename self.config = coreaux_api.get_interface_configuration('wxgui') statusflags = 0 if self.config('History').get_bool('debug') else \ wx.dataview.DATAVIEW_COL_HIDDEN self.view = wx.dataview.DataViewCtrl(parent, style=wx.dataview.DV_SINGLE | wx.dataview.DV_ROW_LINES | wx.dataview.DV_NO_HEADER) self.data = [] self.dvmodel = DatabaseHistoryModel(self.data) self.view.AssociateModel(self.dvmodel) # According to DataViewModel's documentation (as of September 2014) # its reference count must be decreased explicitly to avoid memory # leaks; the wxPython demo, however, doesn't do it, and if done here, # the application crashes with a segfault when closing all databases # See also bug #104 #self.dvmodel.DecRef() self.view.AppendBitmapColumn('Icon', 0, width=wx.COL_WIDTH_AUTOSIZE) self.view.AppendTextColumn('Status', 1, width=wx.COL_WIDTH_AUTOSIZE, flags=statusflags) self.view.AppendTextColumn('Timestamp', 2, width=wx.COL_WIDTH_AUTOSIZE) self.view.AppendTextColumn('Description', 3) self._make_icons(bgcolor) aconfig = self.config("ContextualShortcuts")("LeftNotebook")("Logs")( "History") wx.GetApp().root.accmanager.create_manager(self.view, { aconfig["undo"]: lambda event: self.tree.undo(), aconfig["redo"]: lambda event: self.tree.redo(), }) self.tool_id, menu_items, popup_cmenu = self.logspanel.add_log( self.view, "Items", wx.GetApp().artprovider.get_log_icon('@edit'), self._init_context_menu_items(), self._update_context_menu) self._store_context_menu_items(menu_items) self.view.Bind(wx.dataview.EVT_DATAVIEW_ITEM_CONTEXT_MENU, popup_cmenu) self.view.Bind(wx.dataview.EVT_DATAVIEW_SELECTION_CHANGED, self._handle_selection) self.refresh()
def __init__(self, filename): super(Database, self).__init__(wx.GetApp().nb_left, style=wx.SP_LIVE_UPDATE) self.config = coreaux_api.get_interface_configuration('wxgui') self.sash_position = self.config.get_float("logs_sash_position") self.sash_gravity = 1.0 - 1.0 / self.sash_position if \ self.config.get_bool("logs_auto_sash_gravity") else 1 # Prevent the window from unsplitting when dragging the sash to the # border self.SetMinimumPaneSize(20) self.filename = filename self.data = {}
def __init__(self): # This object shouldn't store any references to windows or tables, # otherwise it will prevent them from being garbage-collected when # destroyed config = coreaux_api.get_interface_configuration('wxgui') if config.get_bool('contextual_shortcuts'): self.generate_table = self._generate_table self.accelclass = _WindowAccelerators else: self.generate_table = self._noop self.accelclass = _WindowAcceleratorsNoOp self.EnableAcceleratorsEvent, self.EVT_ENABLE_ACCELERATORS = \ wx.lib.newevent.NewCommandEvent() self.DisableAcceleratorsEvent, self.EVT_DISABLE_ACCELERATORS = \ wx.lib.newevent.NewCommandEvent()
def __init__(self, parent, frame, menu): Notebook.__init__(self, parent) config = coreaux_api.get_interface_configuration('wxgui')( "ContextualShortcuts")("LeftNotebook") frame.accmanager.create_manager(self, { config["cycle"]: menu.view.databases_submenu.ID_CYCLE, config["cycle_reverse"]: menu.view.databases_submenu.ID_RCYCLE, config["focus_first"]: menu.view.databases_submenu.ID_FOCUS_1, config["focus_last"]: menu.view.databases_submenu.ID_FOCUS_LAST, config["show_logs"]: menu.view.logs_submenu.ID_SHOW, config["save"]: menu.file.ID_SAVE, config["save_all"]: menu.file.ID_SAVE_ALL, config["close"]: menu.file.ID_CLOSE_DB, config["close_all"]: menu.file.ID_CLOSE_DB_ALL, }) self.Bind(flatnotebook.EVT_FLATNOTEBOOK_PAGE_CLOSING, self._handle_page_closing) self.Bind(flatnotebook.EVT_FLATNOTEBOOK_PAGE_CLOSED, self._handle_page_closed)
def __init__(self, parent, menu): wx.SplitterWindow.__init__(self, parent, style=wx.SP_LIVE_UPDATE) self.config = coreaux_api.get_interface_configuration('wxgui') self.sash_position = self.config.get_float("tree_sash_position") self.sash_gravity = 1.0 / self.sash_position if \ self.config.get_bool("tree_auto_sash_gravity") else 0 # Prevent the window from unsplitting when dragging the sash to the # border self.SetMinimumPaneSize(20) self.parent = parent self.nb_left = notebooks.LeftNotebook(self, parent, menu) self.nb_right = notebooks.RightNotebook(self, parent, menu) self.Initialize(self.nb_left) # Hide the notebooks *after* self.Initialize, which would instead show # them again implicitly self.nb_left.Show(False) self.nb_right.Show(False) self.Bind(wx.EVT_SPLITTER_DCLICK, self._veto_dclick)
from wx.lib.agw.foldpanelbar import FoldPanelBar from outspline.coreaux_api import Event import outspline.coreaux_api as coreaux_api import outspline.core_api as core_api import msgboxes import textarea import tree open_editor_event = Event() apply_editor_event = Event() check_modified_state_event = Event() close_editor_event = Event() config = coreaux_api.get_interface_configuration('wxgui') tabs = {} class Editors(object): def __init__(self, nb): self.icon_index = nb.add_image( wx.GetApp().artprovider.get_notebook_icon('@edit')) class EditorPanel(wx.Panel): def __init__(self, parent, editor, item): wx.Panel.__init__(self, parent) self.editor = editor self.ctabmenu = TabContextMenu(item)
def __init__(self): self.savedession = coreaux_api.get_interface_configuration('wxgui')( 'SessionFiles') # Use CallAfter in order to let the interface be completely drawn, # before e.g. showing the database upgrade dialog wx.CallAfter(self._post_init)