snakeware

Python-based Linux distro for x86-64 and RPi
git clone git://squid-tech.com/snakeware.git
Log | Files | Refs | README

commit 9a89a1d2d4c19ad2cb9ce90ab663178538b5cfa3
parent 4ee2960ef77684cc232b0d23689f97798e1ba841
Author: Josh Moore <jxm5210@g.rit.edu>
Date:   Fri,  5 Jun 2020 15:20:52 -0400

Merge pull request #78 from joshiemoore/sort

Sort appmenu items alphabetically
Diffstat:
Msnakewm/appmenu/appmenupanel.py | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/snakewm/appmenu/appmenupanel.py b/snakewm/appmenu/appmenupanel.py @@ -49,12 +49,14 @@ class AppMenuPanel(UIPanel): self.elements = elements self.loadfunc = loadfunc + # sorted list of element keys to generate the panel from + self.element_keys = sorted(list(elements.keys())) + # generate buttons - ekeys = list(elements.keys()) - for i in range(len(ekeys)): + for i in range(len(self.element_keys)): UIButton( pygame.Rect((0, i * BUTTON_DIMS[1]), BUTTON_DIMS), - text=ekeys[i], + text=self.element_keys[i], manager=manager, container=self, object_id="menu-" + self.path.replace(".", "-"), @@ -87,7 +89,7 @@ class AppMenuPanel(UIPanel): # next open a new child panel self.child = AppMenuPanel( self.ui_manager, - (self.pos[0] + 1, list(self.elements.keys()).index(uitext)), + (self.pos[0] + 1, self.pos[1] + self.element_keys.index(uitext)), self.path + "." + uitext, self.elements[uitext], self.loadfunc,