当前位置: 首页>>代码示例>>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;未经允许,请勿转载。