Форум программистов, компьютерный форум, киберфорум
Python: GUI, графика
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
0 / 0 / 0
Регистрация: 18.12.2023
Сообщений: 1
Kivy

Высвечивается просто белый экран

18.12.2023, 06:22. Показов 685. Ответов 0

Студворк — интернет-сервис помощи студентам
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
import json
from kivymd.app import MDApp
from kivy.lang.builder import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivymd.uix.button import MDIconButton, MDRaisedButton
from kivymd.uix.card import MDCard
from kivymd.uix.textfield import MDTextField
from kivymd.uix.gridlayout import MDGridLayout
from kivymd.uix.label import MDLabel
from kivymd.uix.list import MDList, TwoLineListItem
from kivy.metrics import dp
from kivy.properties import ObjectProperty
from kivy.uix.boxlayout import BoxLayout
from functools import partial
import traceback
 
screen_helper = """ 
ScreenManager:
    MenuScreen:
    CreateScreen:
    StatsScreen:
    FlashcardsScreen:
 
<MenuScreen>:
    name: 'menu'
    MDGridLayout:
        id: group_list_layout
        cols: 1
        size_hint_y: None
        height: self.minimum_height
        pos_hint: {"top": 0.9}
    MDTopAppBar:
        title: "Answa"
        pos_hint: {"top": 1}
        elevation: 0
        md_bg_color: (34 / 255, 139 / 255, 34 / 255) 
        right_action_items: [["chart-bar-stacked", lambda x: root.on_right_action_items(x)]]
    MDFloatingActionButton:
        icon: "note-plus"
        md_bg_color: (34 / 255, 139 / 255, 34 / 255)
        pos: root.width - self.width - dp(16), dp(16)
        elevation: 0
        on_press: root.manager.current = 'create'
 
<CreateScreen>:
    name: 'create'
    MDTopAppBar:
        title: "Answa"
        pos_hint: {"top": 1}
        elevation: 0
        left_action_items: [["chevron-left", lambda x: root.on_left_action_items(x)]]
        right_action_items: [["content-save-check-outline", lambda x: root.save_to_json()]]
        md_bg_color: (34 / 255, 139 / 255, 34 / 255)
    MDTextField:
        id: group_name
        hint_text: "Enter name group..."
        mode: "fill"
        pos_hint: {"top": 0.9}
    ScrollView:
        size_hint: (1, 1)
        pos_hint: {"top": 0.8}
        GridLayout:
            id: card_container
            cols: 1
            size_hint_y: None
            height: self.minimum_height
    MDIconButton:
        icon: "plus-circle-outline"
        theme_icon_color: "Custom"
        icon_color: (34 / 255, 139 / 255, 34 / 255)
        icon_size: "54sp"
        pos: root.width - self.width - dp(16), dp(16)
        on_release: root.add_card()
 
<StatsScreen>:
    name: 'stats'
    MDTopAppBar:
        title: "Answa"
        pos_hint: {"top": 1}
        elevation: 0
        left_action_items: [["chevron-left", lambda x: root.on_left_action_items(x)]]  
        md_bg_color: (34 / 255, 139 / 255, 34 / 255)
    MDLabel:
        text: 'Upload'
        halign: 'center'
 
<FlashcardsScreen>:
    name: 'flashcards'
    MDTopAppBar:
        title: "Answa"
        pos_hint: {"top": 1}
        elevation: 0
        left_action_items: [["chevron-left", lambda x: root.on_left_action_items(x)]]  
        md_bg_color: (34 / 255, 139 / 255, 34 / 255)
    MDLabel:
        text: 'Upload'
        halign: 'center'
"""
 
class MenuScreen(Screen):
    group_list_layout = ObjectProperty()
 
    def __init__(self, **kwargs):
        super(MenuScreen, self).__init__(**kwargs)
        self.group_list_layout = MDGridLayout(cols=1, size_hint_y=None, height=dp(0))
 
    def on_pre_enter(self, *args):
        self.update_group_list()
 
    def on_right_action_items(self, instance):
        self.manager.current = 'stats'
 
    def update_group_list(self):
        self.group_list_layout.clear_widgets()
 
        try:
            with open("user_data.json", "r") as file:
                data = json.load(file)
 
            for group_data in data:
                group_name = group_data.get("group_name", "")
                if group_name:
                    card = MDCard(
                        orientation='vertical',
                        size_hint_y=None,
                        height=dp(80),
                        elevation=1,
                        on_release=partial(self.show_flashcards_screen, group_data)
                    )
 
                    box_layout = BoxLayout(padding=(dp(16), 0))
                    label = MDLabel(
                        text=group_name,
                        theme_text_color="Primary",
                        halign="left",
                        valign="center",
                    )
 
                    box_layout.add_widget(label)
                    card.add_widget(box_layout)
 
                    self.group_list_layout.add_widget(card)
 
        except FileNotFoundError as e:
            print(f"Error: {e}")
        except Exception as e:
            print(f"An error occurred: {traceback.format_exc()}")
 
    def show_flashcards_screen(self, group_data, *args):
        self.manager.current = 'flashcards'
        flashcards_screen = self.manager.get_screen('flashcards')
        flashcards_screen.group_data = group_data
        flashcards_screen.load_flashcards()
 
class CreateScreen(Screen):
    card_list_layout = ObjectProperty()
 
    def on_left_action_items(self, instance):
        self.manager.current = 'menu'
 
    def __init__(self, **kwargs):
        super(CreateScreen, self).__init__(**kwargs)
        self.card_data = []
 
    def add_card(self):
        card_container = self.ids.card_container
 
        new_card = MDCard(
            orientation='vertical',
            size_hint_y=None,
            height="80dp",
            elevation=1,
        )
 
        new_box_layout = MDGridLayout(
            cols=2,
            row_default_height="40dp",
            row_force_default=True,
            spacing='10dp',
            padding='10dp',
        )
 
        new_question_field = MDTextField(hint_text='Question')
        new_answer_field = MDTextField(hint_text='Answer')
 
        new_box_layout.add_widget(new_question_field)
        new_box_layout.add_widget(new_answer_field)
 
        close_button = MDIconButton(
            icon="close",
            theme_text_color="Custom",
            text_color=(1, 0, 0, 1),
            pos_hint={"center_x": 0.95, "center_y": 0.9},
        )
 
        close_button.bind(on_release=lambda x: self.remove_card(new_card, new_question_field, new_answer_field))
 
        new_card.add_widget(new_box_layout)
        new_card.add_widget(close_button)
 
        self.card_data.insert(0, {"question": new_question_field.text, "answer": new_answer_field.text})
 
        card_container.add_widget(new_card, index=0)
 
        new_question_field.text = ''
        new_answer_field.text = ''
 
    def update_card_container(self):
        card_container = self.ids.card_container
        card_container.clear_widgets()
 
        for card_data in self.card_data:
            new_card = MDCard(
                orientation='vertical',
                size_hint_y=None,
                height="80dp",
                elevation=1,
            )
 
            new_box_layout = MDGridLayout(
                cols=2,
                row_default_height="40dp",
                row_force_default=True,
                spacing='10dp',
                padding='10dp',
            )
 
            new_question_field = MDTextField(hint_text='Question', text=card_data.get('question', ''))
            new_answer_field = MDTextField(hint_text='Answer', text=card_data.get('answer', ''))
 
            new_box_layout.add_widget(new_question_field)
            new_box_layout.add_widget(new_answer_field)
 
            close_button = MDIconButton(
                icon="close",
                theme_text_color="Custom",
                text_color=(1, 0, 0, 1),
                pos_hint={"center_x": 0.95, "center_y": 0.9},
            )
 
            close_button.bind(on_release=lambda x: self.remove_card(new_card, new_question_field, new_answer_field))
 
            new_card.add_widget(new_box_layout)
            new_card.add_widget(close_button)
 
            card_container.add_widget(new_card, index=0)
 
    def remove_card(self, card, question_field, answer_field):
        card_container = self.ids.card_container
        card_container.remove_widget(card)
 
        for item in self.card_data:
            if item["question"] == question_field.text and item["answer"] == answer_field.text:
                self.card_data.remove(item)
                break
 
class FlashcardsScreen(Screen):
    def __init__(self, group_data=None, **kwargs):
        super().__init__(**kwargs)
        self.group_data = group_data
        self.layout = BoxLayout(orientation='vertical')
        self.flashcard_list = MDList()
        self.edit_button = MDRaisedButton(text='Edit Flashcards', on_release=self.edit_flashcards)
        self.study_button = MDRaisedButton(text='Study', on_release=self.study_flashcards)
        self.layout.add_widget(self.flashcard_list)
        self.layout.add_widget(self.edit_button)
        self.layout.add_widget(self.study_button)
        self.add_widget(self.layout)
 
    def on_pre_enter(self, *args):
        if self.group_data:
            self.load_flashcards()
 
    def load_flashcards(self):
        self.flashcard_list.clear_widgets()
        flashcards = self.group_data.get('flashcards', [])
        for flashcard in flashcards:
            text = f"Question: {flashcard['question']}\nAnswer: {flashcard['answer']}"
            item = TwoLineListItem(text=text)
            self.flashcard_list.add_widget(item)
 
    def edit_flashcards(self, instance):
        self.manager.current = 'create'
        create_screen = self.manager.get_screen('create')
        create_screen.group_name.text = self.group_data.get('group_name', '')
        create_screen.card_data = self.group_data.get('flashcards', [])
        create_screen.update_card_container()
 
    def study_flashcards(self, instance):
        if not self.group_data:
            return
 
        self.start_study(self.group_data['group_name'])
 
        if not self.flashcards:
            self.show_error_popup("No flashcards available for study.")
            return
 
        self.show_current_flashcard()
        self.study_button.text = 'Next Flashcard'
 
        self.study_button.unbind(on_release=self.study_flashcards)
        self.study_button.bind(on_release=self.show_next_flashcard)
 
    def show_current_flashcard(self):
        if 0 <= self.current_card_index < len(self.flashcards):
            card = self.flashcards[self.current_card_index]
            text = f"Question: {card['question']}\nAnswer: {card['answer']}"
            self.flashcard_list.clear_widgets()
            item = TwoLineListItem(text=text)
            self.flashcard_list.add_widget(item)
 
    def show_next_flashcard(self, instance):
        if 0 <= self.current_card_index < len(self.flashcards) - 1:
            self.current_card_index += 1
            self.show_current_flashcard()
        else:
            self.show_success_popup("Congratulations! You've studied all flashcards.")
            self.reset_study_session()
 
    def reset_study_session(self):
        self.current_card_index = 0
        self.study_button.text = 'Study'
        self.study_button.unbind(on_release=self.show_next_flashcard)
        self.study_button.bind(on_release=self.study_flashcards)
        self.flashcard_list.clear_widgets()
 
class StatsScreen(Screen):
    def on_left_action_items(self, instance):
        self.manager.current = 'menu'
 
class Answa(MDApp):
    def build(self):
        sm = ScreenManager()
        sm.add_widget(MenuScreen(name='menu'))
        sm.add_widget(CreateScreen(name='create'))
        sm.add_widget(StatsScreen(name='stats'))
        sm.add_widget(FlashcardsScreen(name='flashcards'))
        return sm
 
if __name__ == '__main__':
    Answa().run()
0
IT_Exp
Эксперт
34794 / 4073 / 2104
Регистрация: 17.06.2006
Сообщений: 32,602
Блог
18.12.2023, 06:22
Ответы с готовыми решениями:

Черно-белый экран (задача)
Компания начала выпускать черно-белые квадратные экраны размером n * n пикселей. Для экономии трафика был разработан специальный режим...

Выводит просто белый экран
Подскажите, пожалуйста, что в данной программе не так? Ибо выводит только белый экран и ничего более. Там по идее должна быть картинка из...

Почему отображается просто белый экран
Почему отображается просто белый экран) #include &quot;MyGLWidget.h&quot; #include &lt;QtOpenGL&gt; #include &lt;QtWidgets&gt; ...

0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
BasicMan
Эксперт
29316 / 5623 / 2384
Регистрация: 17.02.2009
Сообщений: 30,364
Блог
18.12.2023, 06:22
Помогаю со студенческими работами здесь

Не рисуется куб, просто белый экран
#include &quot;stdafx.h&quot; #include &lt;tchar.h&gt; #include &lt;windows.h&gt; #include &lt;GL/glut.h&gt; #include &lt;iostream&gt; #include &lt;conio.h&gt; #pragma...

Высвечивается чёрный экран и все( не высвечивается сам текст программы и возможность кликать и тд, и тп
program Prog2; uses crt; var c: char; glb: set of char; letts: array of integer; arr: array of boolean; words: integer; t:...

Ошибка открытия файла robots.txt на локалке ошибка 500, а на хостинге просто белый экран
Создаю файл robots.txt В контролере написал: public class SeoController : Controller { // GET: Seo ...

на веб странице ничего не отображает просто белый квадрат вместо аплета, без ошибок просто ничего не выводит
Всем привет ! ! ! :drink: Создаю applet с jfreechart: import org.jfree.chart.JFreeChart; import org.jfree.chart.ChartFactory; ...

Белый экран PHP / пустой белый экран
Доброго времени суток! У меня тут такая проблема: решил изучить верстку под Wordpress, скачал OpenServer(настроил Apache и PHP - выставил...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
1
Ответ Создать тему
Новые блоги и статьи
Советы по крайней бережливости. Внимание, это ОЧЕНЬ длинный пост.
Programma_Boinc 28.12.2025
Советы по крайней бережливости. Внимание, это ОЧЕНЬ длинный пост. Налог на собак: https:/ / **********/ gallery/ V06K53e Финансовый отчет в Excel: https:/ / **********/ gallery/ bKBkQFf Пост отсюда. . .
Кто-нибудь знает, где можно бесплатно получить настольный компьютер или ноутбук? США.
Programma_Boinc 26.12.2025
Нашел на реддите интересную статью под названием Anyone know where to get a free Desktop or Laptop? Ниже её машинный перевод. После долгих разбирательств я наконец-то вернула себе. . .
Thinkpad X220 Tablet — это лучший бюджетный ноутбук для учёбы, точка.
Programma_Boinc 23.12.2025
Рецензия / Мнение/ Перевод Нашел на реддите интересную статью под названием The Thinkpad X220 Tablet is the best budget school laptop period . Ниже её машинный перевод. Thinkpad X220 Tablet —. . .
PhpStorm 2025.3: WSL Terminal всегда стартует в ~
and_y87 14.12.2025
PhpStorm 2025. 3: WSL Terminal всегда стартует в ~ (home), игнорируя директорию проекта Симптом: После обновления до PhpStorm 2025. 3 встроенный терминал WSL открывается в домашней директории. . .
Как объединить две одинаковые БД Access с разными данными
VikBal 11.12.2025
Помогите пожалуйста !! Как объединить 2 одинаковые БД Access с разными данными.
Новый ноутбук
volvo 07.12.2025
Всем привет. По скидке в "черную пятницу" взял себе новый ноутбук Lenovo ThinkBook 16 G7 на Амазоне: Ryzen 5 7533HS 64 Gb DDR5 1Tb NVMe 16" Full HD Display Win11 Pro
Музыка, написанная Искусственным Интеллектом
volvo 04.12.2025
Всем привет. Некоторое время назад меня заинтересовало, что уже умеет ИИ в плане написания музыки для песен, и, собственно, исполнения этих самых песен. Стихов у нас много, уже вышли 4 книги, еще 3. . .
От async/await к виртуальным потокам в Python
IndentationError 23.11.2025
Армин Ронахер поставил под сомнение async/ await. Создатель Flask заявляет: цветные функции - провал, виртуальные потоки - решение. Не threading-динозавры, а новое поколение лёгких потоков. Откат?. . .
Поиск "дружественных имён" СОМ портов
Argus19 22.11.2025
Поиск "дружественных имён" СОМ портов На странице: https:/ / norseev. ru/ 2018/ 01/ 04/ comportlist_windows/ нашёл схожую тему. Там приведён код на С++, который показывает только имена СОМ портов, типа,. . .
Сколько Государство потратило денег на меня, обеспечивая инсулином.
Programma_Boinc 20.11.2025
Сколько Государство потратило денег на меня, обеспечивая инсулином. Вот решила сделать интересный приблизительный подсчет, сколько государство потратило на меня денег на покупку инсулинов. . . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2025, CyberForum.ru