예제 #1
0
    def __action_help(self):
        _file = "dshelp_%s.html" % self.options["lang"]
        if not os.path.exists(_file):
            _file = "dshelp.html"

        if os.path.exists(_file):
            webbrowser.open(_file)
        else:
            tkMessageBox.showinfo(
                title=about.get_product_info("AppName"),
                message=_("No help file is installed."),
                )
예제 #2
0
 def __action_close(self):
     _savechanged = False
     if self.editor.edit_modified():
         _answer = tkMessageBox.askyesnocancel(
             parent=self.master,
             title=about.get_product_info("AppName"),
             message=_("The text in the file has changed. "
                       "Do you want to save it?"),
             )
         if _answer is None:
             return False
         elif _answer:
             _savechanged = True
         else:
             _savechanged = False
     if self.__close_algorithm(_savechanged):
         self.__set_status("none")
         return True
     return False
예제 #3
0
def main():
    os.chdir(os.path.normpath(os.path.dirname(sys.argv[0])))
    # 读取配置文件
    try:
        f = open("algorithm-elf.pycfg")
        options = eval(f.read())
        lang = options["lang"]               # 检查配置文件是否是字典类型
    except Exception, inst:
        sys.stderr.write("Warning: reading configure file failed: " + str(inst))
        lang = None
        options = {}
    mysite.set_locale("algorithm-elf", lang=lang)
    root = Tix.Tk()
    try:
        w = AlgorithmElf(root, options)        
        root.title(about.get_product_info("AppName"))
        # 默认图标和最大化窗口
        try:
            # Windows 和 MacOS,使用设置 state 的方式
            if sys.platform == 'win32':
                root.state("zoomed")
                root.iconbitmap(default="main.ico")
            # On X11, 使用修改属性的方式最大化
            elif sys.platform == 'linux2':                
                root.attributes("-zoomed", True)
                root.iconbitmap("main.ico")
        except (KeyError, Tkinter.TclError):
            pass
        
        root.focus_set()        
        w.grid(sticky="nesw")