can u do a advanced gui project in kivy gui framework
@DJOamen27 күн бұрын
Yes, see below: from kivy.app import App from kivy.uix.boxlayout import BoxLayout from kivy.uix.label import Label from kivy.uix.textinput import TextInput from kivy.uix.button import Button from kivy.uix.scrollview import ScrollView class TimesTableApp(App): def build(self): # Main layout container self.layout = BoxLayout(orientation='vertical', padding=10, spacing=10) # Input box for entering a number self.input_box = TextInput(hint_text="Enter a number", multiline=False, input_filter='int') self.layout.add_widget(self.input_box) # Button to generate the times table self.generate_button = Button(text="Generate Times Table") self.generate_button.bind(on_press=self.generate_table) self.layout.add_widget(self.generate_button) # Scrollable area for displaying the times table self.scroll_view = ScrollView() self.result_layout = BoxLayout(orientation='vertical', size_hint_y=None) self.result_layout.bind(minimum_height=self.result_layout.setter('height')) self.scroll_view.add_widget(self.result_layout) self.layout.add_widget(self.scroll_view) return self.layout def generate_table(self, instance): # Clear the previous results self.result_layout.clear_widgets() # Get the input number try: number = int(self.input_box.text) if number < 0: self.result_layout.add_widget(Label(text="Please enter a positive number.")) return # Generate the times table for i in range(1, 13): result = f"{number} x {i} = {number * i}" self.result_layout.add_widget(Label(text=result, size_hint_y=None, height=30)) except ValueError: self.result_layout.add_widget(Label(text="Invalid input. Please enter a valid number.")) if __name__ == "__main__": TimesTableApp().run()