浏览代码

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

Maarten van den Berg 3 年之前
父节点
当前提交
58527e9901
共有 1 个文件被更改,包括 3 次插入1 次删除
  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())