當前位置: 首頁>>代碼示例>>Python>>正文


Python GNUScreen.layout_select_layout方法代碼示例

本文整理匯總了Python中GNUScreen.layout_select_layout方法的典型用法代碼示例。如果您正苦於以下問題:Python GNUScreen.layout_select_layout方法的具體用法?Python GNUScreen.layout_select_layout怎麽用?Python GNUScreen.layout_select_layout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在GNUScreen的用法示例。


在下文中一共展示了GNUScreen.layout_select_layout方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __load_layouts

# 需要導入模塊: import GNUScreen [as 別名]
# 或者: from GNUScreen import layout_select_layout [as 別名]
    def __load_layouts(self):
        cdinfo = map(int, self.dinfo()[0:2])
        out("Terminal size: %s %s" % (cdinfo[0], cdinfo[1]))
        homewindow = self.homewindow
        (homelayout, homelayoutname) = self.get_layout_number()
        layout_trans = {}
        layout_c = len(glob.glob(os.path.join(self.basedir, self.savedir, "winlayout_*")))
        if layout_c > 0:
            self.__layouts_loaded = True
        lc = 0
        layout_file = sc.layout_begin(self.pid)
        while lc < layout_c:
            filename = None
            try:
                filename = glob.glob(os.path.join(self.basedir, self.savedir, "layout_%d" % lc))[0]
                layoutnumber = filename.rsplit("_", 1)[1]
                (head, tail) = os.path.split(filename)

                # the winlayout_NUM files contain "dumpscreen layout" output
                # (see GNUScreen.Regions class)

                filename2 = os.path.join(head, "win" + tail)
                regions = sc.get_regions(filename2)
                status = self.get_layout_new(regions.title)
                if not status:
                    sys.stderr.write(
                        "\nMaximum number of layouts reached. Ignoring layout %s (%s).\n"
                        % (layoutnumber, regions.title)
                    )
                    break
                else:
                    if self.exact:
                        self.layout("number %s" % layoutnumber, False)
                        currentlayout = layoutnumber
                    else:
                        currentlayout = self.get_layout_number()[0]
                    layout_trans[layoutnumber] = currentlayout

                    sc.layout_select_layout(currentlayout)
                    # source the output produced by "layout dump"
                    sc.layout_load_dump(open(filename, "r"))

                    regions_size = []
                    winlist = []

                    for (window, sizex, sizey) in regions.regions:
                        winlist.append(window)
                        regions_size.append((sizex, sizey))
                    sc.layout_load_regions(regions, self.__wins_trans, cdinfo[0], cdinfo[1])
                    # sys.stdout.write(" %s (%s);" % (layoutnumber, regions.title))
            except:
                # import traceback
                # traceback.print_exc(file=sys.stderr)
                # raise
                layout_c += 1
                if layout_c > 2000:
                    sys.stderr.write("\nErrors during layouts loading.\n")
                    break
            lc += 1
        out("")
        if not lc == 0:

            # select last layout

            lastname = None
            lastid_l = None

            if homelayout != -1:
                out("Returning homelayout %s" % homelayout)
                layout_file.write("layout select %s" % homelayout)
            else:
                sys.stderr.write("No homelayout - unable to return.\n")

            if os.path.exists(os.path.join(self.basedir, self.savedir, "last_layout")) and len(layout_trans) > 0:
                last = os.readlink(os.path.join(self.basedir, self.savedir, "last_layout"))
                (lasthead, lasttail) = os.path.split(last)
                last = lasttail.split("_", 2)
                lastid_l = last[1]
                try:
                    out("Selecting last layout: %s (%s)" % (layout_trans[lastid_l], lastid_l))
                    layout_file.write("layout select %s" % layout_trans[lastid_l])
                    # ^^ layout numbering may change, use layout_trans={}
                except:
                    sys.stderr.write("Unable to select last layout %s\n" % lastid_l)
        else:
            self.enable_layout = False
        sc.layout_end()
開發者ID:rlabok,項目名稱:screen-session,代碼行數:89,代碼來源:ScreenSaver.py


注:本文中的GNUScreen.layout_select_layout方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。