Created
May 19, 2020 17:11
-
-
Save ryanbugden/6c4048f3199fba63204df6eb357d9e00 to your computer and use it in GitHub Desktop.
try to fit 16 columns perfectly into font overview, resize window accordingly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mojo.UI import CurrentFontWindow | |
from lib.tools.defaults import getDefault | |
''' | |
trying to perfectly fit 16 columns of cells across the font overview | |
''' | |
fo = CurrentFontWindow().fontOverview | |
gc = fo.getGlyphCollection() | |
v = gc.getGlyphCellView() | |
# get the width of the cell view | |
vw = v.frameSize().width | |
cells_across = 16 | |
cw = vw / cells_across | |
print("frame width is ", vw) | |
print("and the amount of cells I want across is ", cells_across) | |
print("so: ") | |
print("desired cell size is ", cw) | |
# do it | |
v.setCellSize_([cw, cw]) | |
new_cw = gc.getCellSize()[0] | |
print("but resulting cell size is ", new_cw) | |
print("so: ") | |
print("leftover padding on right side of font overview is ", ((cw - new_cw) * cells_across)) | |
vw = new_cw * cells_across | |
print("new desired frame width is ", vw) | |
# set frame size | |
if getDefault("singleWindowMode") == 1: | |
v.recalculateFrame() | |
x, y, w, h = fo.getPosSize() | |
fo.setPosSize((x, y, vw, h)) | |
else: | |
windows = NSApp().orderedWindows() | |
(x, y), (w, h) = windows[0].frame() | |
x_diff = w - vw | |
windows[0].setFrame_display_animate_(((x + x_diff, y), (vw, h)), True, False) | |
print("final frame width is ", v.frameSize().width) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment