Created
May 18, 2020 18:49
-
-
Save ryanbugden/96b63c589996612da5be092e4bfa033e to your computer and use it in GitHub Desktop.
A little vanilla window to help drastically change size, line-height, left padding, top padding
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 CurrentSpaceCenter | |
from vanilla import FloatingWindow, Slider, TextBox | |
class SpaceCenterTuner(): | |
""" | |
Fine-tune Space Center sizing and spacing. | |
Ryan Bugden | |
2020.05.18 | |
2019.06.02 | |
""" | |
def __init__(self): | |
window_width = 250 | |
window_height = 114 | |
margin = 10 | |
gutter_horiz = 5 | |
gutter_vert = 15 | |
text_width = 70 | |
slider_height = 10 | |
text_height = 20 | |
self.csc = CurrentSpaceCenter() | |
self.lv = self.csc.glyphLineView | |
self.ps = self.lv.getPosSize() | |
self.lp = 0 | |
self.tp = 40 | |
current_size = self.csc.getPointSize() | |
current_lh = self.csc.getLineHeight() | |
self.w = FloatingWindow((50,-600,window_width,window_height),"Space Center Tuner") | |
self.w.size_text = TextBox( | |
((margin,margin,text_width,text_height)), | |
text='SIZE', | |
alignment='left', | |
selectable=False, | |
sizeStyle='mini') | |
self.w.size_slider = Slider( | |
((margin + text_width + gutter_horiz, margin, window_width-margin*2 - gutter_horiz - text_width, margin)), | |
minValue=0, | |
maxValue=300, | |
value=current_size, | |
continuous=True, | |
callback=self.sizeCallback, | |
sizeStyle='regular' | |
) | |
self.w.lh_text = TextBox( | |
((margin, margin + slider_height + gutter_vert, text_width, text_height)), | |
text='LINE-HEIGHT', | |
alignment='left', | |
selectable=False, | |
sizeStyle='mini') | |
self.w.lh_slider = Slider( | |
((margin + text_width + gutter_horiz,margin + slider_height + gutter_vert,window_width-margin*2 - gutter_horiz - text_width,margin)), | |
minValue=-500, | |
maxValue=1000, | |
value=current_lh, | |
continuous=True, | |
callback=self.lineHeightCallback, | |
sizeStyle='regular' | |
) | |
self.w.tp_text = TextBox( | |
((margin, margin + slider_height*2 + gutter_vert*2, text_width, text_height)), | |
text='TOP-PAD', | |
alignment='left', | |
selectable=False, | |
sizeStyle='mini') | |
self.w.tp_slider = Slider( | |
((margin + text_width + gutter_horiz, margin + slider_height*2 + gutter_vert*2,window_width-margin*2 - gutter_horiz - text_width,margin)), | |
minValue=40, | |
maxValue=400, | |
value=current_lh, | |
continuous=True, | |
callback=self.topPaddingCallback, | |
sizeStyle='regular' | |
) | |
self.w.lp_text = TextBox( | |
((margin, margin + slider_height*3 + gutter_vert*3, text_width, text_height)), | |
text='LEFT-PAD', | |
alignment='left', | |
selectable=False, | |
sizeStyle='mini') | |
self.w.lp_slider = Slider( | |
((margin + text_width + gutter_horiz, margin + slider_height*3 + gutter_vert*3, window_width-margin*2 - gutter_horiz - text_width,margin)), | |
minValue=0, | |
maxValue=1000, | |
value=current_lh, | |
continuous=True, | |
callback=self.leftPaddingCallback, | |
sizeStyle='regular' | |
) | |
self.w.open() | |
def lineHeightCallback(self, sender): | |
self.des_lh = sender.get() | |
self.csc.setLineHeight(self.des_lh) | |
def sizeCallback(self, sender): | |
self.des_size = sender.get() | |
self.csc.setPointSize(self.des_size) | |
def topPaddingCallback(self, sender): | |
self.tp = sender.get() | |
self.lv.setPosSize((self.lp, self.tp, self.ps[2], self.ps[3])) | |
def leftPaddingCallback(self, sender): | |
self.lp = sender.get() | |
self.lv.setPosSize((self.lp, self.tp, self.ps[2], self.ps[3])) | |
SpaceCenterTuner() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment