Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 我正在用python制作一个文本框';s拱廊图书馆。我能';当文本长度增加超过允许的宽度时,不能处理滚动_Python 3.x - Fatal编程技术网

Python 3.x 我正在用python制作一个文本框';s拱廊图书馆。我能';当文本长度增加超过允许的宽度时,不能处理滚动

Python 3.x 我正在用python制作一个文本框';s拱廊图书馆。我能';当文本长度增加超过允许的宽度时,不能处理滚动,python-3.x,Python 3.x,我正在python的arcade库中制作一个文本框。我有一个基本的硬编码实现,这是一个文本框类,它存储按下的键并在文本框中显示,但当文本长度大于框的宽度时,它只显示在框的外面,而不是将其放入框中并使用箭头键左右滚动文本 我曾尝试将文本的存储和文本的显示分离在不同的类中,但由于我不知道如何移动光标,也不知道如何实现滚动等基本功能,所以无法实现 文本框类更新方法 文本存储类更新方法 文本显示类draw\u Text方法 我希望它在按向左或向右箭头键时滚动文本,或者当文本长度增加超过文本框的宽度时滚动

我正在python的arcade库中制作一个文本框。我有一个基本的硬编码实现,这是一个文本框类,它存储按下的键并在文本框中显示,但当文本长度大于框的宽度时,它只显示在框的外面,而不是将其放入框中并使用箭头键左右滚动文本

我曾尝试将文本的存储和文本的显示分离在不同的类中,但由于我不知道如何移动光标,也不知道如何实现滚动等基本功能,所以无法实现

文本框类更新方法 文本存储类更新方法 文本显示类draw\u Text方法 我希望它在按向左或向右箭头键时滚动文本,或者当文本长度增加超过文本框的宽度时滚动文本,但我似乎无法实现

def update(self, delta_time, keys_pressed):
    if self.text_display.highlighted:
        text, symbol = self.text_storage.update(delta_time, keys_pressed)
        self.text_display.update(delta_time, text, symbol)
def update(self, delta_time, keys_pressed):
    self.time += delta_time
    self.blink_cursor()
    for key in keys_pressed:
        if key == arcade.key.BACKSPACE:
            self.text = self.text[:-1]
        elif key == arcade.key.LEFT:
            if self.cursor_index > 0:
                self.cursor_index -= 1
        elif key == arcade.key.RIGHT:
            if self.cursor_index < self.char_limit:
                self.cursor_index += 1
        else:
            if len(self.text) < self.char_limit:
                self.text += chr(key)
    return self.text, self.cursor_symbol
def update(self, delta_time, text, symbol):
    self.text = text
    self.symbol = symbol
def draw_text(self):
    if self.highlighted:
        arcade.draw_text(self.text + self.symbol, self.x-self.width/2, 
        self.y, arcade.color.BLACK, font_size=24, anchor_y="center")
    else:
        arcade.draw_text(self.text, self.x-self.width/2, self.y, 
        arcade.color.BLACK, font_size=24, anchor_y="center")