【问题标题】:If Statement with OnScreenText带有 OnScreenText 的 If 语句
【发布时间】:2014-10-26 04:54:26
【问题描述】:

我想做一个代码,如果某个屏幕上的文本正在显示,那么我希望它隐藏。我打算尝试做类似的事情:

TTCloadingText = OnscreenText(text = "Heading to Toontown Central...", scale = .08, pos =     (-1.065, -.775, -.775), align=TextNode.ALeft, font = MickeyFont, fg=(0, 0, 0.5176470588235293,  1))
TTCloadingText.show()
if TTCloadingText.show = True Then
    TTCloadingText.hide()

请帮忙?

【问题讨论】:

    标签: python text hide show visible


    【解决方案1】:

    好吧,我认为您需要查看您的 python 系统税。 “那么”不是附加条件“if”语句的合适关键字。另外,请确保包含“:”。

    【讨论】:

      【解决方案2】:

      好的,下面我相信我已经修复了您提供的代码。我会记下我更改的内容。

      TTCloadingText = OnscreenText(text = "Heading to Toontown Central...", scale = .08, pos = (-1.065, -.775, -.775), align=TextNode.ALeft, font = MickeyFont, fg=(0, 0, 0.5176470588235293,  1))
      TTCloadingText.show()
      if TTCloadingText.show:
          TTCloadingText.hide()
      

      我把if TTCloadingText.show = True Then改成了if TTCloadingText.show:,因为python没有“Then”关键字;要获得“然后”,请使用 :

      在您的版本中,您有if thing = True,它需要是if thing == True。使用== 测试变量/属性。

      另外,您不需要使用== True,因为if something: 在python 中与if something == True: 一样。

      这可能不是完美的答案,但绝对可以。我已经使用 Toontown 编码多年,并且以前使用过这样的方法。祝你好运!

      【讨论】:

        猜你喜欢
        • 2012-01-27
        • 2016-08-15
        • 2018-02-20
        • 2018-09-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多