鱼C论坛

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

[已解决]关于textbox的输出问题

[复制链接]
发表于 2017-12-2 22:07:23 | 显示全部楼层 |阅读模式

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

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

x
做习题时发现,textbox的text部分,既可以是读出来的字符串,也可以是文本本身。

import easygui as g
file_path = g.fileopenbox(default='*.txt')
with open(file_path) as f:
##    f = f.read()                      #此句不输出,照样可以正常显示,请问是否可以省略,使得执行更高效一些呢?
    g.textbox(text=f)


按照逻辑,一般打开文档,需要将文档内容读出来,然后再输出,但是textbox本身貌似已经做了处理。
查了一下help命令,没有明确提出,鉴于还是新手,不知道怎么查找textbox里面的源代码是否已经做了相应的处理,使得文件本身也可以直接放进去。
谁能指点一下呢?谢谢。
----------------------------------------------------------------------------------------------
Help on function textbox in module easygui:

textbox(msg='', title=' ', text='', codebox=0)
    Display some text in a proportional font with line wrapping at word breaks.
    This function is suitable for displaying general written text.
   
    The text parameter should be a string, or a list or tuple of lines to be
    displayed in the textbox.
   
    :param str msg: the msg to be displayed
    :param str title: the window title
    :param str text: what to display in the textbox
    :param str codebox: if 1, act as a codebox
----------------------------------------------------------------------------------------------
最佳答案
2017-12-2 22:24:56
跟textbox无关,因为打开文件f不进行read操作那么f可以被当做是read后的结果
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2017-12-2 22:24:56 From FishC Mobile | 显示全部楼层    本楼为最佳答案   
跟textbox无关,因为打开文件f不进行read操作那么f可以被当做是read后的结果
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2017-12-3 11:15:07 | 显示全部楼层
谢谢,跟我预想中差不多。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-4 11:24

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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