鱼C论坛

 找回密码
 立即注册
查看: 1157|回复: 2

[已解决]35课 EasyGui学习文档:Settings()报错

[复制链接]
发表于 2018-1-16 20:18:41 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
执行下面的代码
import os

settingsFilename = os.path.join("C:", "FishCApp", "settings.txt")  
settings = Settings(settingsFilename)

报错
NameError: name 'Settings' is not defined


1. 请问Settings()如何导入?
2. os.path.join("C:", "FishCApp", "settings.txt")    具体有什么用?创建一个txt文件?



最佳答案
2018-1-16 22:59:50
这个没玩过
第二个我知道 是路径拼接
会自动补充路径分隔符 把参数字符串拼接成一个路径字符串
Settings应该是一个类吧

找了一下文档

http://easygui.sourceforge.net/t ... ering-user-settings
  1. #-----------------------------------------------------------------------
  2. # define a class named Settings as a subclass of EgStore
  3. #-----------------------------------------------------------------------
  4. class Settings(EgStore):

  5.     def __init__(self, filename):  # filename is required
  6.         #-------------------------------------------------
  7.         # Specify default/initial values for variables that
  8.         # this particular application wants to remember.
  9.         #-------------------------------------------------
  10.         self.userId = ""
  11.         self.targetServer = ""

  12.         #-------------------------------------------------
  13.         # For subclasses of EgStore, these must be
  14.         # the last two statements in  __init__
  15.         #-------------------------------------------------
  16.         self.filename = filename  # this is required
  17.         self.restore()            # restore values from the storage file if possible
复制代码


要自己写这个类 小甲鱼的帖子里提了 但没给代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2018-1-16 22:59:50 | 显示全部楼层    本楼为最佳答案   
这个没玩过
第二个我知道 是路径拼接
会自动补充路径分隔符 把参数字符串拼接成一个路径字符串
Settings应该是一个类吧

找了一下文档

http://easygui.sourceforge.net/t ... ering-user-settings
  1. #-----------------------------------------------------------------------
  2. # define a class named Settings as a subclass of EgStore
  3. #-----------------------------------------------------------------------
  4. class Settings(EgStore):

  5.     def __init__(self, filename):  # filename is required
  6.         #-------------------------------------------------
  7.         # Specify default/initial values for variables that
  8.         # this particular application wants to remember.
  9.         #-------------------------------------------------
  10.         self.userId = ""
  11.         self.targetServer = ""

  12.         #-------------------------------------------------
  13.         # For subclasses of EgStore, these must be
  14.         # the last two statements in  __init__
  15.         #-------------------------------------------------
  16.         self.filename = filename  # this is required
  17.         self.restore()            # restore values from the storage file if possible
复制代码


要自己写这个类 小甲鱼的帖子里提了 但没给代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-1-17 08:55:29 | 显示全部楼层
sky 发表于 2018-1-16 22:59
这个没玩过
第二个我知道 是路径拼接
会自动补充路径分隔符 把参数字符串拼接成一个路径字符串

谢谢
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-3-28 23:27

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表