From c450344fc2a155f1bf09873582efaa4d0211d735 Mon Sep 17 00:00:00 2001 From: cxykevin Date: Wed, 1 May 2024 13:45:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9select?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- magictk/select.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/magictk/select.py b/magictk/select.py index 1b9bbf3..7b1b534 100644 --- a/magictk/select.py +++ b/magictk/select.py @@ -61,7 +61,7 @@ class Select(button.Button): super().__init__(master=master, root_anim=root_anim, w=w, h=h, text=text, color_list=color_list, _set_defaultcolor=True) self.__menuobj = submenu.MenuObjs() - self.__last = 0 + self.__last = -1 for i in self.items: self.__menuobj.addmenu(i, self._callback_menu) @@ -71,9 +71,11 @@ class Select(button.Button): def change_menu(self, items): self.items = items self.__menuobj = submenu.MenuObjs() - self.__last = 0 + self.__last = -1 for i in self.items: self.__menuobj.addmenu(i, self._callback_menu) + self.canvas.itemconfigure(self.__text_obj, text=self.text) + self.canvas.moveto(self.__text_obj, 16, self.h//2-10) def _draw(self): super()._draw(True) @@ -170,3 +172,6 @@ class Select(button.Button): ) self._update_color() self.canvas.bind("", pressrelease_v) + + def get(self): + return self.__last