Calculate all offsets from main window size.
Calculate all offsets from main window size.
diff --git a/qwerty.py b/qwerty.py
index 6d39445..a102923 100755
--- a/qwerty.py
+++ b/qwerty.py
@@ -27,13 +27,13 @@ OK = True
CANCEL = False
PADDING = 4
-ICON_TOP_MARGIN = 35
-LABEL_LEFT, LABEL_TOP = 15,25
-LABEL_FONT_SIZE_COEF = 0.019
-DESC_TOP = 110
-DESC_FONT_SIZE_COEF = 0.014
-KEY_BOTTOM = 35
-KEY_FONT_SIZE_COEF = 0.039
+ICON_TOP_COEF = 0.043
+LABEL_LEFT_COEF, LABEL_TOP_COEF = 0.012, 0.04
+LABEL_FONT_SIZE_COEF = 0.021
+DESC_TOP_COEF = 0.12
+DESC_FONT_SIZE_COEF = 0.016
+KEY_BOTTOM_COEF = 0.034
+KEY_FONT_SIZE_COEF = 0.045
LINEHEIGHT = 1.2
@@ -103,7 +103,7 @@ class SuperButton(gtk.DrawingArea):
self.connect('enter-notify-event', self.on_mouse_over)
self.connect('leave-notify-event', self.on_mouse_out)
- self.set_size_request(90,120)
+ self.set_size_request(50,100)
self.fg = BUTTON_BORDER
@@ -147,7 +147,7 @@ class SuperButton(gtk.DrawingArea):
x = (self.width - w)/2
- cr.set_source_surface(IS,x,ICON_TOP_MARGIN)
+ cr.set_source_surface(IS,x,ICON_TOP)
cr.paint()
def draw_button(self,cr):
@@ -244,7 +244,7 @@ class SectionButton(SuperButton):
def draw_label(self,cr):
if self.label:
cr.set_source_rgb(*BUTTON_BORDER_ACTIVE)
- cr.move_to(20,30)
+ cr.move_to(LABEL_LEFT, LABEL_TOP)
cr.set_font_size(LABEL_FONT_SIZE)
cr.show_text(self.label)
@@ -580,7 +580,7 @@ class GUI(object):
self.window.connect('size-allocate', self.on_resize)
self.window.set_decorated(decorate)
- self.calc_font_sizes()
+ self.calc_sizes()
for c in ALPHABET:
self.buttons[c] = SuperButton(c)
@@ -637,15 +637,26 @@ class GUI(object):
self.collect_windows()
- def calc_font_sizes(self):
+ def calc_sizes(self):
global LABEL_FONT_SIZE
global DESC_FONT_SIZE
global KEY_FONT_SIZE
+ global LABEL_LEFT, LABEL_TOP
+ global KEY_BOTTOM
+ global ICON_TOP
+ global DESC_TOP
LABEL_FONT_SIZE = LABEL_FONT_SIZE_COEF * self.height
DESC_FONT_SIZE = DESC_FONT_SIZE_COEF * self.height
KEY_FONT_SIZE = KEY_FONT_SIZE_COEF * self.height
+ LABEL_LEFT = LABEL_LEFT_COEF * self.width
+ LABEL_TOP = LABEL_TOP_COEF * self.height
+
+ KEY_BOTTOM = KEY_BOTTOM_COEF * self.height
+ ICON_TOP = ICON_TOP_COEF * self.height
+ DESC_TOP = DESC_TOP_COEF * self.height
+
def convert_class(self,clss):
if isinstance(clss, tuple):
@@ -674,7 +685,7 @@ class GUI(object):
def on_resize(self,widget, rect):
self.width, self.height = rect.width, rect.height
- self.calc_font_sizes()
+ self.calc_sizes()
def fill_taskbar(self):
def rm(widget):