Browse Source

piket_client.gui: Set maximum number of columns, use sqrt

Maarten van den Berg 3 years ago
parent
commit
58527e9901
1 changed files with 3 additions and 1 deletions
  1. 3 1
      piket_client/gui.py

+ 3 - 1
piket_client/gui.py

5
 import logging
5
 import logging
6
 import os
6
 import os
7
 import sys
7
 import sys
8
+from math import ceil, sqrt
8
 
9
 
9
 import qdarkstyle
10
 import qdarkstyle
10
 
11
 
148
         LOG.debug("Initializing NameButtons.")
149
         LOG.debug("Initializing NameButtons.")
149
 
150
 
150
         ps = Person.get_all(True)
151
         ps = Person.get_all(True)
151
-        num_columns = round(len(ps) / 10) + 1
152
+        # num_columns = round(len(ps) / 10) + 1
153
+        num_columns = min(5, ceil(sqrt(len(ps))))
152
 
154
 
153
         if self.layout:
155
         if self.layout:
154
             LOG.debug("Removing %s widgets for rebuild", self.layout.count())
156
             LOG.debug("Removing %s widgets for rebuild", self.layout.count())