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


Python Project.show方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: from Project import Project [as 別名]
# 或者: from Project.Project import show [as 別名]
class StoryDNA:
    def __init__(self):
        self.project = None
        self.secureQuit = True  # attribute to know if script have to ask to save current project before quitting

        # create the app main window
        self.window = Tk(className="StoryDNA")
        self.window.option_add("*Font", "arial 12")
        self.window.geometry(
            str(self.window.winfo_screenwidth()) + "x" + str(self.window.winfo_screenheight()) + "+0+0"
        )

        # activate general shortcut for menu and mouse scrolling
        self.window.bind("<Control-KeyPress>", self.shortcut)
        self.window.bind_all("<Button-5>", mouseScroll)
        self.window.bind_all("<Button-4>", mouseScroll)

        # create the menu of the software
        self.menubar = Menu(self.window)
        menu = Menu(self.menubar, tearoff=0)

        # submenu of File menu
        menu.add_command(label="New", command=self.new)
        menu.add_command(label="Open", command=self.open)
        menu.add_command(label="Save", command=self.save, state=DISABLED)
        menu.add_command(label="Save As", command=self.saveAs, state=DISABLED)
        menu.add_command(label="Quit", command=self.quit)
        self.window.protocol("WM_DELETE_WINDOW", self.quit)

        self.menubar.add_cascade(label="File", menu=menu)

        # Settings menu and submenu
        menu = Menu(self.menubar, tearoff=0)
        menu.add_command(label="Archetypes", command=lambda win=self.window: Character.setArchetypesList(win))
        self.menubar.add_cascade(label="Settings", menu=menu)

        self.window.config(menu=self.menubar)

        # create content of starting window :
        #    button to open a project or create a new one
        fr = Frame(self.window, pady=300)
        fr.pack()

        button = Button(fr, text="NEW PROJECT", command=self.new, pady=5, justify=CENTER)
        button.pack(pady=5)

        button = Button(fr, text="OPEN A PROJECT", command=self.open, pady=5, justify=CENTER)
        button.pack(pady=5)

        # warning message
        label = Label(
            fr,
            text="This soft is still in development and is not ready to use!",
            foreground="#ff0000",
            pady=50,
            font=("Arial", 50),
            wraplength=800,
            justify=LEFT,
        )
        label.pack()

        # treat the app argument
        argv = sys.argv
        while len(argv) > 1:
            arg = argv.pop()
            if arg == "--no-secure-quit":
                # disabled the safe quitting mode
                self.secureQuit = False
            else:
                path = os.path.abspath(arg)

                # check the path given and open it as a project
                if not os.access(path, os.F_OK):
                    showerror("Load error", "«" + path + "» didn't exist or is not a file!")
                elif not (os.access(path, os.R_OK) and os.access(path, os.W_OK)):
                    showerror("Load error", "you don't have permission to read or write in «" + path + "» file!")
                elif path[-5:] != ".sdna" or not tarfile.is_tarfile(path):
                    showerror("Load error", "«" + path + "» don't seemed to be a valid Story DNA file!")
                else:
                    fr.destroy()  # erase content of starting window
                    self.open(path=path)  # open the project

        self.window.mainloop()

        # erase the temporary directory before quitting
        if self.project is not None:
            self.project.__del__()

    def shortcut(self, event):
        """call action corresponding to a shortcut"""
        if event.keysym == "q":
            self.quit()
        elif event.keysym == "Q":
            self.quit(True)  # quit app directly without saving
        elif event.keysym == "n":
            self.new()
        elif event.keysym == "o":
            self.open()
        elif event.keysym == "s" and self.project is not None:
            focus = self.window.focus_displayof()
#.........這裏部分代碼省略.........
開發者ID:CaptainDesAstres,項目名稱:StoryDNA-on-TKinter-abandoned-version,代碼行數:103,代碼來源:main.py


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