Пример #1
0
def make_symbols():

    buf = ""
    x0 = y0 = 10
    dx = dy = 35
    ty = 17
    n = 7
    xsep = 15
    ysep = 5

    w = 2 * x0 + n * dx + (n - 1) * xsep
    print("w", w)
    tmpval = not (N % n)
    h = 2 * y0 + (1 + N // n - int(tmpval)) * (dy + ty + ysep)
    print("h", h)
    pform = xfl.fl_bgn_form(xfl.FL_FLAT_BOX, w, h)

    pobj0 = xfl.fl_add_button(xfl.FL_HIDDEN_BUTTON, 0, 0, w, h, "")
    xfl.fl_set_object_callback(pobj0, done_cb, 0)

    x = y = j = 0
    for i in range(0, len(symbols)):
        if not symbols[i]:
            break

        if (i % n) == 0:
            x = x0
            y = y0 + j * (dy + ty + ysep + 1)
            j += 1
        else:
            x += dx + xsep

        pobj = xfl.fl_add_box(xfl.FL_UP_BOX, x, y, dx, dy, symbols[i])
        xfl.fl_set_object_lcol(pobj, xfl.FL_BOTTOM_BCOL)
        buf = "@" + symbols[i]
        pboxobj = xfl.fl_add_box(xfl.FL_FLAT_BOX, x, y + dy, dx, ty, buf)

        txt_x, txt_y, txt_w, txt_h = xfl.fl_get_object_geometry(pboxobj)
        w = xfl.fl_get_string_width(xfl.fl_get_object_lstyle(pboxobj), \
                xfl.fl_get_object_lsize(pboxobj), symbols[i], len(symbols[i])) \
                + 2 * xfl.fl_get_object_bw(pboxobj)
        xfl.fl_set_object_geometry(pboxobj, txt_x + (txt_w - w) / 2, txt_y, \
                w, txt_h)

    xfl.fl_end_form()

    return pform
Пример #2
0
 def move_cb(self, pobj, data):
     dx = dy = 8
     x, y, w, h = xfl.fl_get_object_geometry(self.pbut)
     xlimitup = x + w + dx
     xlimitdown = x + dx
     ylimitup = y + h + dy
     ylimitdown = y + dy
     if (xlimitdown < 0):
         dx = -dx
     if (xlimitup >= self.pbut.contents.form.contents.w):
         dx = -(dx*32)
     if (ylimitdown < 0):
         dy = -dy
     if (ylimitup >= self.pbut.contents.form.contents.h):
         dy = -(dy*16)
     x += dx
     y += dy
     xfl.fl_set_object_position(self.pbut, x, y)