1 1.1.1.3 christos # Copyright (C) 2020-2024 Free Software Foundation, Inc. 2 1.1 christos # 3 1.1 christos # This program is free software; you can redistribute it and/or modify 4 1.1 christos # it under the terms of the GNU General Public License as published by 5 1.1 christos # the Free Software Foundation; either version 3 of the License, or 6 1.1 christos # (at your option) any later version. 7 1.1 christos # 8 1.1 christos # This program is distributed in the hope that it will be useful, 9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 1.1 christos # GNU General Public License for more details. 12 1.1 christos # 13 1.1 christos # You should have received a copy of the GNU General Public License 14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 1.1 christos 16 1.1 christos # A TUI window implemented in Python. 17 1.1 christos 18 1.1 christos import gdb 19 1.1 christos 20 1.1 christos the_window = None 21 1.1 christos 22 1.1.1.2 christos 23 1.1 christos class TestWindow: 24 1.1 christos def __init__(self, win): 25 1.1 christos global the_window 26 1.1.1.2 christos the_window = self 27 1.1 christos self.count = 0 28 1.1 christos self.win = win 29 1.1 christos win.title = "This Is The Title" 30 1.1 christos 31 1.1 christos def render(self): 32 1.1 christos self.win.erase() 33 1.1 christos w = self.win.width 34 1.1 christos h = self.win.height 35 1.1.1.3 christos self.win.write( 36 1.1.1.3 christos string="Test: " + str(self.count) + " " + str(w) + "x" + str(h), 37 1.1.1.3 christos full_window=False, 38 1.1.1.3 christos ) 39 1.1 christos self.count = self.count + 1 40 1.1 christos 41 1.1.1.2 christos # Tries to delete the title attribute. GDB will throw an error. 42 1.1.1.2 christos def remove_title(self): 43 1.1.1.2 christos del self.win.title 44 1.1.1.2 christos 45 1.1.1.2 christos 46 1.1 christos gdb.register_window_type("test", TestWindow) 47 1.1 christos 48 1.1.1.3 christos 49 1.1.1.2 christos # Call REMOVE_TITLE on the global window object. 50 1.1.1.2 christos def delete_window_title(): 51 1.1.1.2 christos the_window.remove_title() 52 1.1.1.2 christos 53 1.1.1.2 christos 54 1.1 christos # A TUI window "constructor" that always fails. 55 1.1 christos def failwin(win): 56 1.1 christos raise RuntimeError("Whoops") 57 1.1 christos 58 1.1.1.2 christos 59 1.1.1.3 christos # Change the title of the window. 60 1.1.1.3 christos def change_window_title(): 61 1.1.1.3 christos the_window.win.title = "New Title" 62 1.1.1.3 christos 63 1.1.1.3 christos 64 1.1 christos gdb.register_window_type("fail", failwin) 65