예제 #1
0
파일: container.py 프로젝트: Darriall/idle
 def create_statusbar(self):
     self.statusbar = Statusbar(self.w)
     self.statusbar.pack(side=BOTTOM, fill=X)
예제 #2
0
 def create_statusbar(self):
     self.statusbar = Statusbar(self.w)
     self.statusbar.pack(side=BOTTOM, fill=X)
예제 #3
0
파일: container.py 프로젝트: Darriall/idle
class Container(object):
    def __init__(self, flist):
        self.flist = flist
        self.component = None               # caller sets via add_component
        self.w = self.make_widget()         # w: widget component packs into
        self.top = self.w.winfo_toplevel()  # top: toplevel for this container
        self.statusbar = None
        if self.flist:
            self.flist.add_container(self)

    def make_widget(self):
        t = Toplevel(self.flist.root)
        t.protocol('WM_DELETE_WINDOW', self._close)
        t.bind("<<close-window>>", lambda e: self._close())
        return t

    def add_component(self, component):
        self.component = component
        self.w.after_idle(self.title_changed)

    def _close(self):
        if self.component is not None:
            try:
                self.component.close()
                self.w.destroy()
                self.w = None
                self.component = None
                if self.flist:
                    self.flist.delete_container(self)
            except Exception:       # if file needs saving, user may abort
                pass

    def title_changed(self):
        if self.component is not None:
            short = self.component.short_title()
            long = self.component.long_title()
            if short and long:
                title = short + " - " + long + _py_version
            elif short:
                title = short
            elif long:
                title = long
            else:
                title = "Untitled"
            icon = short or long or title
            if not self.component.get_saved():
                title = "*%s*" % title
                icon = "*%s" % icon
            self.w.wm_title(title)
            self.w.wm_iconname(icon)
            self.flist.filenames_changed()  # to update window list

    def get_title(self):
        return self.w.wm_title()

    def set_menubar(self, menu):
        self.w['menu'] = menu

    def setup_statusbar(self):
        self.create_statusbar()
        self.statusbar.observe(self.component)

    def create_statusbar(self):
        self.statusbar = Statusbar(self.w)
        self.statusbar.pack(side=BOTTOM, fill=X)

    def ping_statusbar(self):   #  later - 'metadata_changed'?
        if self.statusbar is not None:
            self.statusbar.update()

    def move_to_front(self, component): 
        "Adjust the container so the given component is brought forward."
        # we can ignore component parameter for now, as base container
        # supports only a single component
        try:
            if self.w.wm_state() == "iconic":
                self.w.wm_withdraw()
                self.w.wm_deiconify()
            self.w.tkraise()
        except TclError:
            # This can happen when the window menu was torn off.
            # Simply ignore it.
            pass
예제 #4
0
class Container(object):
    def __init__(self, flist):
        self.flist = flist
        self.component = None  # caller sets via add_component
        self.w = self.make_widget()  # w: widget component packs into
        self.top = self.w.winfo_toplevel()  # top: toplevel for this container
        self.statusbar = None
        if self.flist:
            self.flist.add_container(self)

    def make_widget(self):
        t = Toplevel(self.flist.root)
        t.protocol('WM_DELETE_WINDOW', self._close)
        t.bind("<<close-window>>", lambda e: self._close())
        return t

    def add_component(self, component):
        self.component = component
        self.w.after_idle(self.title_changed)

    def _close(self):
        if self.component is not None:
            try:
                self.component.close()
                self.w.destroy()
                self.w = None
                self.component = None
                if self.flist:
                    self.flist.delete_container(self)
            except Exception:  # if file needs saving, user may abort
                pass

    def title_changed(self):
        if self.component is not None:
            short = self.component.short_title()
            long = self.component.long_title()
            if short and long:
                title = short + " - " + long + _py_version
            elif short:
                title = short
            elif long:
                title = long
            else:
                title = "Untitled"
            icon = short or long or title
            if not self.component.get_saved():
                title = "*%s*" % title
                icon = "*%s" % icon
            self.w.wm_title(title)
            self.w.wm_iconname(icon)
            self.flist.filenames_changed()  # to update window list

    def get_title(self):
        return self.w.wm_title()

    def set_menubar(self, menu):
        self.w['menu'] = menu

    def setup_statusbar(self):
        self.create_statusbar()
        self.statusbar.observe(self.component)

    def create_statusbar(self):
        self.statusbar = Statusbar(self.w)
        self.statusbar.pack(side=BOTTOM, fill=X)

    def ping_statusbar(self):  #  later - 'metadata_changed'?
        if self.statusbar is not None:
            self.statusbar.update()

    def move_to_front(self, component):
        "Adjust the container so the given component is brought forward."
        # we can ignore component parameter for now, as base container
        # supports only a single component
        try:
            if self.w.wm_state() == "iconic":
                self.w.wm_withdraw()
                self.w.wm_deiconify()
            self.w.tkraise()
        except TclError:
            # This can happen when the window menu was torn off.
            # Simply ignore it.
            pass