⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 splitter_window.py

📁 用python写的ide开发环境,巨强大,不过需要wxpython的支持
💻 PY
📖 第 1 页 / 共 2 页
字号:
# splitter_window.py: wxSplitterWindow objects# $Id: splitter_window.py,v 1.28 2007/08/07 12:15:21 agriggio Exp $## Copyright (c) 2002-2007 Alberto Griggio <agriggio@users.sourceforge.net># License: MIT (see license.txt)# THIS PROGRAM COMES WITH NO WARRANTYimport wximport common, miscfrom tree import Treefrom widget_properties import *from edit_windows import ManagedBase, WindowBase, EditBasefrom edit_sizers.edit_sizers import Sizer, SizerSlotclass SplitterWindowSizer(Sizer):    """\    "Virtual sizer" responsible for the management of a SplitterWindow.    """    def set_item(self, pos, option=None, flag=None, border=None, size=None,                 force_layout=True):        """\        Updates the layout of the item at the given pos.        """        #print 'set_item'        if self.window.widget and \                self.window.window_old and self.window.window_old.widget:            self.window.widget.Unsplit(self.window.window_old.widget)            self.window.window_old = None        if self.window.window_1 and self.window.window_2:            self.window.split()        def add_item(self, item, pos=None, option=0, flag=0, border=0, size=None,                 force_layout=True):        """\        Adds an item to self.window.        """        #print 'add_item', item.name        if pos == 1:            self.window.window_old = self.window.window_1            self.window.window_1 = item            self.window.properties['window_1'].set_value(item.name)        else:            self.window.window_old = self.window.window_2            self.window.window_2 = item            self.window.properties['window_2'].set_value(item.name)        def free_slot(self, pos, force_layout=True):        """\        Replaces the element at pos with an empty slot        """        if pos == 1:            if self.window.widget and \                    self.window.window_1 and self.window.window_1.widget:                self.window.widget.Unsplit(self.window.window_1.widget)            self.window.window_1 = SizerSlot(self.window, self, pos)            w = self.window.window_1        else:            if self.window.widget and \                    self.window.window_2 and self.window.window_2.widget:                self.window.widget.Unsplit()            self.window.window_2 = SizerSlot(self.window, self, pos)            w = self.window.window_2        self.window.split()        w.widget.SetFocus()            def get_itempos(self, attrs):        """\        Get position of sizer item (used in xml_parse)        """        if hasattr(self.window.properties['window_1'], 'value') and \                attrs['name'] == self.window.properties['window_1'].value:            pos = 1        else:            pos = 2        return pos        def is_virtual(self):        return True# end of class SplitterWindowSizerclass EditSplitterWindow(ManagedBase):    _custom_base_classes = True    events = [        'EVT_SPLITTER_SASH_POS_CHANGING',        'EVT_SPLITTER_SASH_POS_CHANGED',        'EVT_SPLITTER_UNSPLIT',        'EVT_SPLITTER_DCLICK',        ]        def __init__(self, name, parent, id, style, win_1, win_2, orientation,                 sizer, pos, property_window, show=True):        """\        Class to handle wxSplitterWindow objects        """        ManagedBase.__init__(self, name, 'wxSplitterWindow', parent, id, sizer,                             pos, property_window, show=show)        self.virtual_sizer = SplitterWindowSizer(self)        if style is None: style = wx.SP_3D        self.style = style        self.window_1 = win_1         self.window_2 = win_2         self.orientation = orientation        self.sash_pos = 0        self.access_functions['style'] = (self.get_style, self.set_style)        self.access_functions['sash_pos'] = (self.get_sash_pos,                                             self.set_sash_pos)        self.style_pos  = (wx.SP_3D, wx.SP_3DSASH, wx.SP_3DBORDER,                           #wx.SP_FULLSASH,                           wx.SP_BORDER, wx.SP_NOBORDER,                           wx.SP_PERMIT_UNSPLIT, wx.SP_LIVE_UPDATE,                           wx.CLIP_CHILDREN)        style_labels = ('#section#' + _('Style'), 'wxSP_3D', 'wxSP_3DSASH',                        'wxSP_3DBORDER', #'wxSP_FULLSASH',                        'wxSP_BORDER',                        'wxSP_NOBORDER', 'wxSP_PERMIT_UNSPLIT',                        'wxSP_LIVE_UPDATE', 'wxCLIP_CHILDREN')        self.properties['style'] = CheckListProperty(self, 'style', None,                                                     style_labels)        if self.orientation == wx.SPLIT_HORIZONTAL:            od = 'wxSPLIT_HORIZONTAL'        else: od = 'wxSPLIT_VERTICAL'        self.access_functions['orientation'] = (self.get_orientation,                                                self.set_orientation)        self.properties['orientation'] = HiddenProperty(self, 'orientation', label=_("orientation"))        self.access_functions['window_1'] = (self.get_win_1, lambda v: None)        self.access_functions['window_2'] = (self.get_win_2, lambda v: None)        self.properties['window_1'] = HiddenProperty(self, 'window_1')        self.properties['window_2'] = HiddenProperty(self, 'window_2')        self.window_1 = SizerSlot(self, self.virtual_sizer, 1)        self.window_2 = SizerSlot(self, self.virtual_sizer, 2)        self.properties['sash_pos'] = SpinProperty(self, 'sash_pos', None,                                                   r=(0, 20),                                                   can_disable=True, label=_("sash_pos"))         self.no_custom_class = False        self.access_functions['no_custom_class'] = (self.get_no_custom_class,                                                    self.set_no_custom_class)        self.properties['no_custom_class'] = CheckBoxProperty(            self, 'no_custom_class',            label=_("Don't generate code for this custom class"))    def create_widget(self):        self.widget = wx.SplitterWindow(self.parent.widget, self.id,                                        style=self.style)        self.split()    def finish_widget_creation(self):        ManagedBase.finish_widget_creation(self, sel_marker_parent=self.widget)        sp = self.properties['sash_pos']        if sp.is_active():            sp.set_value(self.sash_pos)            self.widget.SetSashPosition(self.sash_pos)        else:            sp.set_value(self.widget.GetSashPosition())                wx.EVT_SPLITTER_SASH_POS_CHANGED(self.widget, self.widget.GetId(),                                         self.on_sash_pos_changed)            def on_set_focus(self, event):        self.show_properties()        # here we must call event.Skip() also on Win32 as this we should be        # able to move the sash        event.Skip()    def create_properties(self):        ManagedBase.create_properties(self)        panel = wx.ScrolledWindow(self.notebook, -1, style=wx.TAB_TRAVERSAL)        sizer = wx.BoxSizer(wx.VERTICAL)        self.properties['no_custom_class'].display(panel)        self.properties['style'].display(panel)        self.properties['sash_pos'].display(panel)        sizer.Add(self.properties['no_custom_class'].panel, 0,                  wx.ALL|wx.EXPAND, 3)        sizer.Add(self.properties['style'].panel, 0, wx.EXPAND)        sizer.Add(self.properties['sash_pos'].panel, 0, wx.EXPAND)        panel.SetAutoLayout(True)        panel.SetSizer(sizer)        sizer.Fit(panel)        self.notebook.AddPage(panel, 'Widget')            def split(self):        if not self.widget: return        if self.window_1 and self.window_2:            self.window_1.show_widget(True)            self.window_2.show_widget(True)            sp = self.properties['sash_pos'].get_value()            if not self.properties['sash_pos'].is_active():                if self.orientation == wx.SPLIT_VERTICAL:                    max_pos = self.widget.GetClientSize()[0]                else: max_pos = self.widget.GetClientSize()[1]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -