diff --git a/.gitignore b/.gitignore index f8b73e7..0e0ad79 100644 --- a/.gitignore +++ b/.gitignore @@ -138,3 +138,9 @@ dmypy.json # Cython debug symbols cython_debug/ + +*_creations/ +*.exe +*.zip +*.csv +*.txt diff --git a/pictionnary.ico b/pictionnary.ico new file mode 100644 index 0000000..160cae6 Binary files /dev/null and b/pictionnary.ico differ diff --git a/test_kivy_draw.py b/test_kivy_draw.py index 94612ef..2ec99fa 100755 --- a/test_kivy_draw.py +++ b/test_kivy_draw.py @@ -67,6 +67,7 @@ class MyPaintWidget(Label): pen_characteristics = {"current_color": (0,0,0,1), "current_width": 4 } + bg = None current_round = 0 current_word = "" message_label = None @@ -77,6 +78,7 @@ class MyPaintWidget(Label): super().__init__(**kwargs) self._keyboard = None + self._load_words() with self.canvas.before: Color(1,1,1, mode='rgb') self.bg = Rectangle(pos=self.pos, size=self.size) @@ -86,7 +88,6 @@ class MyPaintWidget(Label): self.bind(size=resize_bg, pos=resize_bg) self._get_keyboard() - self._load_words() self._output_dir = datetime.now().isoformat(timespec='minutes').replace(":","-") + "_creations" self._fullscreen = False self.reset_game() @@ -105,7 +106,11 @@ class MyPaintWidget(Label): self._wordlist = (word.strip() for word in wordfile.readlines()) self._game_wordlists["possible_wordlist"] = dict.fromkeys(self._wordlist) except OSError: - Popup(title="Error", content=Label(text=f"Erreur de lecture du fichier '{WORDS_FILE}'")).open() + errmsg = f"Erreur de lecture du fichier '{WORDS_FILE}'" + if self.bg: + Popup(title="Error", content=Label(text=errmsg)).open() + else: + print(errmsg) self._game_wordlists["possible_wordlist"] = dict() @@ -374,22 +379,25 @@ class GuessWhatIDrawApp(App): size_button = SizeButton(self.set_cursor_size, 2*i) self.right_row.add_widget(size_button) - middle_row = BoxLayout(orientation="horizontal", size_hint=(1, 0.8)) + middle_row = BoxLayout(orientation="horizontal", size_hint=(1, 0.75)) middle_row.add_widget(self.painter) middle_row.add_widget(self.right_row) - bottom_row = BoxLayout(orientation='horizontal', spacing=5, size_hint=(1, .1)) + bottom_row = BoxLayout(orientation='horizontal', spacing=5, size_hint=(1, .05)) bottom_row.add_widget(togglebtn) bottom_row.add_widget(clearbtn) - top_row = BoxLayout(orientation='horizontal', spacing=5, size_hint=(1, .1)) - self.word_label = Label(text="Mot:", color=[0,0,0,1], halign="left", valign="top") + top_row = BoxLayout(orientation='horizontal', spacing=5, size_hint=(1, .2)) + self.word_label = Label(text="Mot:", color=[0,0,0,1], halign="left", valign="top", size_hint=(0.2,1)) def redraw(self, obj): - self.text_size = obj + self.text_size = self.size self.word_label.bind(size=redraw) - self.time_label = Label(text=f"{self.painter.time}", color=[0,0,0,1]) - message_label = Label(color=[0,0,0,1], halign="center") + self.time_label = Label(text=f"{self.painter.time}", color=[0,0,0,1], + font_size='50pt', size_hint=(0.2,1)) + message_label = Label(color=[0,0,0,1], halign="center", valign="top", + font_size='40pt', size_hint=(0.6,1)) + message_label.bind(size=redraw) top_row.add_widget(self.word_label) top_row.add_widget(message_label) top_row.add_widget(self.time_label) @@ -424,7 +432,7 @@ class GuessWhatIDrawApp(App): else: self.painter.game_finished() - self.time_label.text = f"{self.painter.time}" + self.time_label.text = f"{formatTimedelta(self.painter.time)}" def toggle_background(self, obj): @@ -453,6 +461,13 @@ class GuessWhatIDrawApp(App): def clear_canvas(self, _): self.painter.clear_drawing() +def formatTimedelta(time:timedelta): + seconds = int(time.total_seconds()) + minutes, reminder = divmod(seconds, 60) + + return f"{minutes:02}:{reminder:02}.{int(time.microseconds/10000):02}" + + if __name__ == '__main__': GuessWhatIDrawApp().run()