Example #1
0
 def _build_state_display(self, position):
     state_field = LabelFrame(self,
                              text=s.language.cards,
                              relief=RAISED,
                              width=self.master.width - 31)
     state_slots_per_row = int((self.master.width - 31) / 32)
     state_slot_height = 24 + (
         (int(len(self._current_player.states) / state_slots_per_row) + 1) *
         32)
     if self._current_player.states:
         for index, state in enumerate(self._current_player.states):
             if state not in self._main_window.engine.nemKartyaStatusz:
                 if state in self._main_window.engine.eventszotar.keys():
                     origin = self._main_window.engine.eventszotar
                     prefix = "event"
                 else:
                     origin = self._main_window.engine.kincsszotar
                     prefix = "treasure"
                 icon = f"{prefix}_{self._main_window.engine.eventszotar[state].kep}_i"
                 icon = icon[(icon.find('_') + 1):]
                 button = Button(
                     state_field,
                     image=Gallery.get(icon),
                     command=lambda s=state: origin[s].megjelenik(1))
                 button.grid(row=int(index / state_slots_per_row),
                             column=index % state_slots_per_row)
         state_field.config(height=state_slot_height)
         if state_field.winfo_children():
             state_field.grid(row=position, column=0)
         state_field.grid_propagate(False)